summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/collection_cloner.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/collection_cloner.h')
-rw-r--r--src/mongo/db/repl/collection_cloner.h42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/mongo/db/repl/collection_cloner.h b/src/mongo/db/repl/collection_cloner.h
index e31d8d1f075..f4f9d9867ec 100644
--- a/src/mongo/db/repl/collection_cloner.h
+++ b/src/mongo/db/repl/collection_cloner.h
@@ -28,7 +28,6 @@
#pragma once
-#include <boost/thread/mutex.hpp>
#include <memory>
#include <string>
#include <vector>
@@ -42,6 +41,8 @@
#include "mongo/db/repl/fetcher.h"
#include "mongo/db/repl/replication_executor.h"
#include "mongo/stdx/functional.h"
+#include "mongo/stdx/condition_variable.h"
+#include "mongo/stdx/mutex.h"
#include "mongo/util/net/hostandport.h"
namespace mongo {
@@ -71,9 +72,9 @@ namespace repl {
/**
* Creates CollectionCloner task in inactive state. Use start() to activate cloner.
*
- * The cloner calls 'work' when the collection cloning has completed or failed.
+ * The cloner calls 'onCompletion' when the collection cloning has completed or failed.
*
- * 'work' will be called exactly once.
+ * 'onCompletion' will be called exactly once.
*
* Takes ownership of the passed StorageInterface object.
*/
@@ -81,10 +82,10 @@ namespace repl {
const HostAndPort& source,
const NamespaceString& sourceNss,
const CollectionOptions& options,
- const CallbackFn& work,
+ const CallbackFn& onCompletion,
StorageInterface* storageInterface);
- virtual ~CollectionCloner() = default;
+ virtual ~CollectionCloner();
const NamespaceString& getSourceNamespace() const;
@@ -96,12 +97,12 @@ namespace repl {
void cancel() override;
+ void wait() override;
+
//
// Testing only functions below.
//
- void wait() override;
-
/**
* Waits for database worker to complete.
* Returns immediately if collection cloner is not active.
@@ -154,6 +155,13 @@ namespace repl {
void _insertDocumentsCallback(const ReplicationExecutor::CallbackData& callbackData,
bool lastBatch);
+ /**
+ * Reports completion status.
+ * Commits/aborts collection building.
+ * Sets cloner to inactive.
+ */
+ void _finishCallback(OperationContext* txn, const Status& status);
+
// Not owned by us.
ReplicationExecutor* _executor;
@@ -163,13 +171,15 @@ namespace repl {
CollectionOptions _options;
// Invoked once when cloning completes or fails.
- CallbackFn _work;
+ CallbackFn _onCompletion;
- // Owned by us.
- std::unique_ptr<StorageInterface> _storageInterface;
+ // Not owned by us.
+ StorageInterface* _storageInterface;
// Protects member data of this collection cloner.
- mutable boost::mutex _mutex;
+ mutable stdx::mutex _mutex;
+
+ mutable stdx::condition_variable _condition;
// _active is true when Collection Cloner is started.
bool _active;
@@ -204,9 +214,6 @@ namespace repl {
class CollectionCloner::StorageInterface {
public:
- /**
- * When the storage interface is destroyed, it will commit the index builder.
- */
virtual ~StorageInterface() = default;
/**
@@ -230,6 +237,13 @@ namespace repl {
const NamespaceString& nss,
const std::vector<BSONObj>& documents) = 0;
+ /**
+ * Commits changes to collection. No effect if collection building has not begun.
+ * Operation context could be null.
+ */
+ virtual Status commitCollection(OperationContext* txn,
+ const NamespaceString& nss) = 0;
+
};
} // namespace repl