diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-07-24 17:48:20 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-07-28 16:32:57 -0400 |
commit | 356a36dea183db5afedb932ed4c086f17c4173d0 (patch) | |
tree | 59128eb8d15f8ed2e0b7c0bc0d2596c756859d23 /src/mongo/s/catalog_cache_loader.cpp | |
parent | 2a910e6c65327a71f6656ecacf6fbca66baeb517 (diff) | |
download | mongo-356a36dea183db5afedb932ed4c086f17c4173d0.tar.gz |
SERVER-29672 Make Config/ShardCatalogCacheLoader decorations on ServiceContext
Diffstat (limited to 'src/mongo/s/catalog_cache_loader.cpp')
-rw-r--r-- | src/mongo/s/catalog_cache_loader.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/mongo/s/catalog_cache_loader.cpp b/src/mongo/s/catalog_cache_loader.cpp index 0f535b158ee..ba81c0fe771 100644 --- a/src/mongo/s/catalog_cache_loader.cpp +++ b/src/mongo/s/catalog_cache_loader.cpp @@ -31,6 +31,12 @@ #include "mongo/s/catalog_cache_loader.h" namespace mongo { +namespace { + +const auto catalogCacheLoaderDecoration = + ServiceContext::declareDecoration<std::unique_ptr<CatalogCacheLoader>>(); + +} // namespace CatalogCacheLoader::CollectionAndChangedChunks::CollectionAndChangedChunks() = default; @@ -46,4 +52,30 @@ CatalogCacheLoader::CollectionAndChangedChunks::CollectionAndChangedChunks( shardKeyIsUnique(collShardKeyIsUnique), changedChunks(chunks) {} +void CatalogCacheLoader::set(ServiceContext* serviceContext, + std::unique_ptr<CatalogCacheLoader> loader) { + auto& catalogCacheLoader = catalogCacheLoaderDecoration(serviceContext); + invariant(!catalogCacheLoader); + + catalogCacheLoader = std::move(loader); +} + +void CatalogCacheLoader::clearForTests(ServiceContext* serviceContext) { + auto& catalogCacheLoader = catalogCacheLoaderDecoration(serviceContext); + invariant(catalogCacheLoader); + + catalogCacheLoader.reset(); +} + +CatalogCacheLoader& CatalogCacheLoader::get(ServiceContext* serviceContext) { + auto& catalogCacheLoader = catalogCacheLoaderDecoration(serviceContext); + invariant(catalogCacheLoader); + + return *catalogCacheLoader; +} + +CatalogCacheLoader& CatalogCacheLoader::get(OperationContext* opCtx) { + return get(opCtx->getServiceContext()); +} + } // namespace mongo |