diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-05-15 18:22:26 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2019-07-03 08:53:14 -0400 |
commit | 6fa35fa8ffa5edd47a2e78e11f524a03fd99567d (patch) | |
tree | 447a2e5cdbf76c6b11ff828c9dd5d17aab400810 | |
parent | 059b8a9dc777e3940caa26f2a909d4988b605645 (diff) | |
download | mongo-6fa35fa8ffa5edd47a2e78e11f524a03fd99567d.tar.gz |
SERVER-41869 Rename `struct dbTask` to DBTask
... to follow naming conventions
(cherry picked from commit b919fb48eb611b3c8cbba9d7f03f6df1d25d4cd5)
-rw-r--r-- | src/mongo/db/s/shard_server_catalog_cache_loader.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/s/shard_server_catalog_cache_loader.h | 68 |
2 files changed, 40 insertions, 41 deletions
diff --git a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp index 24f42034580..81f8adef9cf 100644 --- a/src/mongo/db/s/shard_server_catalog_cache_loader.cpp +++ b/src/mongo/db/s/shard_server_catalog_cache_loader.cpp @@ -744,7 +744,7 @@ void ShardServerCatalogCacheLoader::_schedulePrimaryGetDatabase( OperationContext * opCtx, StatusWith<DatabaseType> swDatabaseType) { if (swDatabaseType == ErrorCodes::NamespaceNotFound) { Status scheduleStatus = _ensureMajorityPrimaryAndScheduleDbTask( - opCtx, name, dbTask{swDatabaseType, termScheduled}); + opCtx, name, DBTask{swDatabaseType, termScheduled}); if (!scheduleStatus.isOK()) { callbackFn(opCtx, scheduleStatus); return; @@ -755,7 +755,7 @@ void ShardServerCatalogCacheLoader::_schedulePrimaryGetDatabase( } else if (swDatabaseType.isOK()) { Status scheduleStatus = _ensureMajorityPrimaryAndScheduleDbTask( - opCtx, name, dbTask{swDatabaseType, termScheduled}); + opCtx, name, DBTask{swDatabaseType, termScheduled}); if (!scheduleStatus.isOK()) { callbackFn(opCtx, scheduleStatus); return; @@ -907,8 +907,7 @@ Status ShardServerCatalogCacheLoader::_ensureMajorityPrimaryAndScheduleCollAndCh } Status ShardServerCatalogCacheLoader::_ensureMajorityPrimaryAndScheduleDbTask( - OperationContext* opCtx, StringData dbName, dbTask task) { - + OperationContext* opCtx, StringData dbName, DBTask task) { stdx::lock_guard<stdx::mutex> lock(_mutex); const bool wasEmpty = _dbTaskLists[dbName.toString()].empty(); _dbTaskLists[dbName.toString()].addTask(std::move(task)); @@ -1052,7 +1051,7 @@ void ShardServerCatalogCacheLoader::_updatePersistedDbMetadata(OperationContext* StringData dbName) { stdx::unique_lock<stdx::mutex> lock(_mutex); - const dbTask& task = _dbTaskLists[dbName.toString()].front(); + const DBTask& task = _dbTaskLists[dbName.toString()].front(); // If this task is from an old term and no longer valid, do not execute and return true so that // the task gets removed from the task list @@ -1138,7 +1137,7 @@ ShardServerCatalogCacheLoader::collAndChunkTask::collAndChunkTask( } } -ShardServerCatalogCacheLoader::dbTask::dbTask(StatusWith<DatabaseType> swDatabaseType, +ShardServerCatalogCacheLoader::DBTask::DBTask(StatusWith<DatabaseType> swDatabaseType, long long currentTerm) : taskNum(taskIdGenerator.fetchAndAdd(1)), termCreated(currentTerm) { if (swDatabaseType.isOK()) { @@ -1182,7 +1181,7 @@ void ShardServerCatalogCacheLoader::CollAndChunkTaskList::addTask(collAndChunkTa } } -void ShardServerCatalogCacheLoader::DbTaskList::addTask(dbTask task) { +void ShardServerCatalogCacheLoader::DbTaskList::addTask(DBTask task) { if (_tasks.empty()) { _tasks.emplace_back(std::move(task)); return; diff --git a/src/mongo/db/s/shard_server_catalog_cache_loader.h b/src/mongo/db/s/shard_server_catalog_cache_loader.h index 045e9e0c1aa..d42245cfddc 100644 --- a/src/mongo/db/s/shard_server_catalog_cache_loader.h +++ b/src/mongo/db/s/shard_server_catalog_cache_loader.h @@ -145,36 +145,6 @@ private: }; /** - * This represents an update task for the persisted database metadata. The task will either be - * to persist an update to the shard persisted metadata store or to drop the persisted - * metadata for a specific database. - */ - struct dbTask { - MONGO_DISALLOW_COPYING(dbTask); - dbTask(dbTask&&) = default; - - /** - * Initializes a task for either dropping or updating the persisted metadata for the - * associated database. Which type of task is determined by the Status of 'swDatabaseType', - * whether it is NamespaceNotFound or OK. - * - * Note: swDatabaseType must always be NamespaceNotFound or OK, otherwise the constructor - * will invariant because there is no task to complete. - */ - dbTask(StatusWith<DatabaseType> swDatabaseType, long long currentTerm); - - // Always-incrementing task number to uniquely identify different tasks - uint64_t taskNum; - - // If boost::none, indicates this task is for a drop. Otherwise, contains the refreshed - // database entry. - boost::optional<DatabaseType> dbType; - - // The term in which the loader scheduled this task. - uint32_t termCreated; - }; - - /** * A list (work queue) of updates to apply to the shard persisted metadata store for a specific * collection. Enforces that tasks that are added to the list are either consistent: * @@ -260,6 +230,36 @@ private: }; /** + * This represents an update task for the persisted database metadata. The task will either be + * to persist an update to the shard persisted metadata store or to drop the persisted + * metadata for a specific database. + */ + struct DBTask { + MONGO_DISALLOW_COPYING(DBTask); + DBTask(DBTask&&) = default; + + /** + * Initializes a task for either dropping or updating the persisted metadata for the + * associated database. Which type of task is determined by the Status of 'swDatabaseType', + * whether it is NamespaceNotFound or OK. + * + * Note: swDatabaseType must always be NamespaceNotFound or OK, otherwise the constructor + * will invariant because there is no task to complete. + */ + DBTask(StatusWith<DatabaseType> swDatabaseType, long long currentTerm); + + // Always-incrementing task number to uniquely identify different tasks + uint64_t taskNum; + + // If boost::none, indicates this task is for a drop. Otherwise, contains the refreshed + // database entry. + boost::optional<DatabaseType> dbType; + + // The term in which the loader scheduled this task. + uint32_t termCreated; + }; + + /** * A list (work queue) of updates to apply to the shard persisted metadata store for a specific * database. */ @@ -274,7 +274,7 @@ private: * don't waste time applying changes we will just delete. If the one remaining task in the * list is already a drop task, the new one isn't added because it is redundant. */ - void addTask(dbTask task); + void addTask(DBTask task); auto& front() { invariant(!_tasks.empty()); @@ -320,15 +320,15 @@ private: bool hasTasksFromThisTerm(long long term) const; private: - std::list<dbTask> _tasks{}; + std::list<DBTask> _tasks{}; // Condition variable which will be signaled whenever the active task from the tasks list is // completed. Must be used in conjunction with the loader's mutex. std::shared_ptr<stdx::condition_variable> _activeTaskCompletedCondVar; }; + typedef std::map<std::string, DbTaskList> DbTaskLists; typedef std::map<NamespaceString, CollAndChunkTaskList> CollAndChunkTaskLists; - typedef std::map<std::string, DbTaskList> DbTaskLists; /** * Forces the primary to refresh its metadata for 'nss' and waits until this node's metadata @@ -437,7 +437,7 @@ private: Status _ensureMajorityPrimaryAndScheduleDbTask(OperationContext* opCtx, StringData dbName, - dbTask task); + DBTask task); /** * Schedules tasks in the 'nss' task list to execute until the task list is depleted. * |