diff options
author | Jason Carey <jcarey@argv.me> | 2017-09-12 17:54:48 -0400 |
---|---|---|
committer | Jason Carey <jcarey@argv.me> | 2017-09-20 12:09:23 -0400 |
commit | 79df037ceb43882726e9484b9ab8b1c23c538034 (patch) | |
tree | f885c270b723f35520bd357b626a43bb44a5c16f /src/mongo/db/logical_session_cache_factory_mongod.cpp | |
parent | 976371fdd34ade74f59ee9f3863bf9047421666e (diff) | |
download | mongo-79df037ceb43882726e9484b9ab8b1c23c538034.tar.gz |
SERVER-31011 Provide transaction record deletion hook
Diffstat (limited to 'src/mongo/db/logical_session_cache_factory_mongod.cpp')
-rw-r--r-- | src/mongo/db/logical_session_cache_factory_mongod.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/mongo/db/logical_session_cache_factory_mongod.cpp b/src/mongo/db/logical_session_cache_factory_mongod.cpp index 7f958e547a7..0fdc1135d56 100644 --- a/src/mongo/db/logical_session_cache_factory_mongod.cpp +++ b/src/mongo/db/logical_session_cache_factory_mongod.cpp @@ -26,6 +26,8 @@ * it in the license file. */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kControl + #include "mongo/platform/basic.h" #include <memory> @@ -37,20 +39,22 @@ #include "mongo/db/sessions_collection_rs.h" #include "mongo/db/sessions_collection_sharded.h" #include "mongo/db/sessions_collection_standalone.h" +#include "mongo/db/transaction_reaper.h" #include "mongo/stdx/memory.h" +#include "mongo/util/log.h" namespace mongo { namespace { -std::unique_ptr<SessionsCollection> makeSessionsCollection(LogicalSessionCacheServer state) { +std::shared_ptr<SessionsCollection> makeSessionsCollection(LogicalSessionCacheServer state) { switch (state) { case LogicalSessionCacheServer::kSharded: - return stdx::make_unique<SessionsCollectionSharded>(); + return std::make_shared<SessionsCollectionSharded>(); case LogicalSessionCacheServer::kReplicaSet: - return stdx::make_unique<SessionsCollectionRS>(); + return std::make_shared<SessionsCollectionRS>(); case LogicalSessionCacheServer::kStandalone: - return stdx::make_unique<SessionsCollectionStandalone>(); + return std::make_shared<SessionsCollectionStandalone>(); default: MONGO_UNREACHABLE; } @@ -58,13 +62,28 @@ std::unique_ptr<SessionsCollection> makeSessionsCollection(LogicalSessionCacheSe } // namespace -std::unique_ptr<LogicalSessionCache> makeLogicalSessionCacheD(LogicalSessionCacheServer state) { +std::unique_ptr<LogicalSessionCache> makeLogicalSessionCacheD(ServiceContext* svc, + LogicalSessionCacheServer state) { auto liason = stdx::make_unique<ServiceLiasonMongod>(); // Set up the logical session cache auto sessionsColl = makeSessionsCollection(state); - return stdx::make_unique<LogicalSessionCacheImpl>( - std::move(liason), std::move(sessionsColl), LogicalSessionCacheImpl::Options{}); + + auto reaper = [&]() -> std::shared_ptr<TransactionReaper> { + switch (state) { + case LogicalSessionCacheServer::kSharded: + return TransactionReaper::make(TransactionReaper::Type::kSharded, sessionsColl); + case LogicalSessionCacheServer::kReplicaSet: + return TransactionReaper::make(TransactionReaper::Type::kReplicaSet, sessionsColl); + default: + return nullptr; + } + }(); + + return stdx::make_unique<LogicalSessionCacheImpl>(std::move(liason), + std::move(sessionsColl), + std::move(reaper), + LogicalSessionCacheImpl::Options{}); } } // namespace mongo |