summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/sharding_state.h
diff options
context:
space:
mode:
authorNathan Myers <nathan.myers@10gen.com>2017-04-18 17:46:55 -0400
committerNathan Myers <nathan.myers@10gen.com>2017-04-20 01:31:00 -0400
commitc192a1b9b1e223f8075ab5ce72dde372467f9650 (patch)
treedf2fad3682c5fce44a7f91d9a216cd912017e38b /src/mongo/db/s/sharding_state.h
parent53907c0094e26e39b813ae369be52a4e51fc3a08 (diff)
downloadmongo-c192a1b9b1e223f8075ab5ce72dde372467f9650.tar.gz
SERVER-27921 New Range Deleter
Diffstat (limited to 'src/mongo/db/s/sharding_state.h')
-rw-r--r--src/mongo/db/s/sharding_state.h37
1 files changed, 12 insertions, 25 deletions
diff --git a/src/mongo/db/s/sharding_state.h b/src/mongo/db/s/sharding_state.h
index e5a74e081a9..c6efdeaae30 100644
--- a/src/mongo/db/s/sharding_state.h
+++ b/src/mongo/db/s/sharding_state.h
@@ -73,10 +73,6 @@ public:
using GlobalInitFunc =
stdx::function<Status(OperationContext*, const ConnectionString&, StringData)>;
- // Signature for the callback function used by the MetadataManager to inform the
- // sharding subsystem that there is range cleanup work to be done.
- using RangeDeleterCleanupNotificationFunc = stdx::function<void(const NamespaceString&)>;
-
ShardingState();
~ShardingState();
@@ -242,18 +238,6 @@ public:
void scheduleCleanup(const NamespaceString& nss);
/**
- * Returns a pointer to the collection range deleter task executor.
- */
- executor::ThreadPoolTaskExecutor* getRangeDeleterTaskExecutor();
-
- /**
- * Sets the function used by scheduleWorkOnRangeDeleterTaskExecutor to
- * schedule work. Used for mocking the executor for testing. See the ShardingState
- * for the default implementation of _scheduleWorkFn.
- */
- void setScheduleCleanupFunctionForTest(RangeDeleterCleanupNotificationFunc fn);
-
- /**
* If started with --shardsvr, initializes sharding awareness from the shardIdentity document
* on disk, if there is one.
* If started with --shardsvr in queryableBackupMode, initializes sharding awareness from the
@@ -266,6 +250,11 @@ public:
*/
StatusWith<bool> initializeShardingAwarenessIfNeeded(OperationContext* opCtx);
+ /**
+ * Return the task executor to be shared by the range deleters for all collections.
+ */
+ executor::TaskExecutor* getRangeDeleterTaskExecutor();
+
private:
// Map from a namespace into the sharding state for each collection we have
typedef stdx::unordered_map<std::string, std::unique_ptr<CollectionShardingState>>
@@ -304,9 +293,6 @@ private:
*/
ChunkVersion _refreshMetadata(OperationContext* opCtx, const NamespaceString& nss);
- // Initializes a TaskExecutor for cleaning up orphaned ranges
- void _initializeRangeDeleterTaskExecutor();
-
// Manages the state of the migration recipient shard
MigrationDestinationManager _migrationDestManager;
@@ -339,12 +325,13 @@ private:
// Function for initializing the external sharding state components not owned here.
GlobalInitFunc _globalInit;
- // Function for scheduling work on the _rangeDeleterTaskExecutor.
- // Used in call to scheduleCleanup(NamespaceString).
- RangeDeleterCleanupNotificationFunc _scheduleWorkFn;
-
- // Task executor for the collection range deleter.
- std::unique_ptr<executor::ThreadPoolTaskExecutor> _rangeDeleterTaskExecutor;
+ // Task executor shared by the collection range deleters.
+ struct RangeDeleterExecutor {
+ stdx::mutex lock{};
+ std::unique_ptr<executor::TaskExecutor> taskExecutor{nullptr};
+ ~RangeDeleterExecutor();
+ };
+ RangeDeleterExecutor _rangeDeleterExecutor;
};
} // namespace mongo