summaryrefslogtreecommitdiff
path: root/src/mongo/db/views/durable_view_catalog.h
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2016-07-29 10:53:21 -0400
committerGeert Bosch <geert@mongodb.com>2016-08-01 16:32:15 -0400
commit3f68c01861b33b76965d39ba5bcbd84e2851afe3 (patch)
tree217c036189e064367cba2b5b652db20dd17dd8c1 /src/mongo/db/views/durable_view_catalog.h
parent18b74d535c944a1b03effd7624ed3e3f08688da7 (diff)
downloadmongo-3f68c01861b33b76965d39ba5bcbd84e2851afe3.tar.gz
SERVER-24767 Replicate views
Diffstat (limited to 'src/mongo/db/views/durable_view_catalog.h')
-rw-r--r--src/mongo/db/views/durable_view_catalog.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/mongo/db/views/durable_view_catalog.h b/src/mongo/db/views/durable_view_catalog.h
index 68dec43255f..1ea7268f2ee 100644
--- a/src/mongo/db/views/durable_view_catalog.h
+++ b/src/mongo/db/views/durable_view_catalog.h
@@ -28,6 +28,10 @@
#pragma once
+#include <string>
+
+#include "mongo/base/status.h"
+#include "mongo/base/string_data.h"
#include "mongo/stdx/functional.h"
namespace mongo {
@@ -39,15 +43,28 @@ class OperationContext;
/**
* Interface for system.views collection operations associated with view catalog management.
- * Methods must be called from within a WriteUnitOfWork, and with the DBLock held.
+ * All methods must be called from within a WriteUnitOfWork, and with the DBLock held in at
+ * least intent mode.
*/
class DurableViewCatalog {
public:
- using Callback = stdx::function<void(const BSONObj& view)>;
+ static constexpr StringData viewsCollectionName() {
+ return "system.views"_sd;
+ }
- virtual void iterate(OperationContext* txn, Callback callback) = 0;
- virtual void insert(OperationContext* txn, const BSONObj& view) = 0;
+ /**
+ * Thread-safe method to mark a catalog name was changed. This will cause the in-memory
+ * view catalog to be marked invalid
+ */
+ static void onExternalChange(OperationContext* txn, const NamespaceString& name);
+
+ using Callback = stdx::function<void(const BSONObj& view)>;
+ virtual Status iterate(OperationContext* txn, Callback callback) = 0;
+ virtual void upsert(OperationContext* txn,
+ const NamespaceString& name,
+ const BSONObj& view) = 0;
virtual void remove(OperationContext* txn, const NamespaceString& name) = 0;
+ virtual const std::string& getName() const = 0;
};
/**
@@ -58,9 +75,10 @@ class DurableViewCatalogImpl final : public DurableViewCatalog {
public:
explicit DurableViewCatalogImpl(Database* db) : _db(db) {}
- void iterate(OperationContext* txn, Callback callback);
- void insert(OperationContext* txn, const BSONObj& view);
+ Status iterate(OperationContext* txn, Callback callback);
+ void upsert(OperationContext* txn, const NamespaceString& name, const BSONObj& view);
void remove(OperationContext* txn, const NamespaceString& name);
+ const std::string& getName() const;
private:
Database* const _db;