summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2017-12-15 11:33:30 -0500
committerHenrik Edin <henrik.edin@mongodb.com>2018-01-22 13:51:26 -0500
commitc376f4b80d26028b6a8746f8545a35e390b59bf2 (patch)
treebffed1afdcc737dcbc899af35c84ccd6cbc4d100 /src/mongo/db/repl
parent50921266423bf59267b08e0f8ee23469ea03d768 (diff)
downloadmongo-c376f4b80d26028b6a8746f8545a35e390b59bf2.tar.gz
SERVER-29519 Removed many usages of getGlobalReplicationCoordinator
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/apply_ops_test.cpp2
-rw-r--r--src/mongo/db/repl/bgsync.cpp3
-rw-r--r--src/mongo/db/repl/bgsync.h3
-rw-r--r--src/mongo/db/repl/do_txn_test.cpp2
-rw-r--r--src/mongo/db/repl/master_slave.cpp23
-rw-r--r--src/mongo/db/repl/master_slave.h2
-rw-r--r--src/mongo/db/repl/mock_repl_coord_server_fixture.cpp2
-rw-r--r--src/mongo/db/repl/oplog.cpp4
-rw-r--r--src/mongo/db/repl/oplog.h2
-rw-r--r--src/mongo/db/repl/oplog_test.cpp2
-rw-r--r--src/mongo/db/repl/repl_set_commands.cpp55
-rw-r--r--src/mongo/db/repl/repl_set_request_votes.cpp4
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp10
-rw-r--r--src/mongo/db/repl/replication_info.cpp8
-rw-r--r--src/mongo/db/repl/resync.cpp4
-rw-r--r--src/mongo/db/repl/rollback_test_fixture.cpp2
-rw-r--r--src/mongo/db/repl/sync_tail_test_fixture.cpp2
17 files changed, 67 insertions, 63 deletions
diff --git a/src/mongo/db/repl/apply_ops_test.cpp b/src/mongo/db/repl/apply_ops_test.cpp
index cc56d823fa6..5a799beed44 100644
--- a/src/mongo/db/repl/apply_ops_test.cpp
+++ b/src/mongo/db/repl/apply_ops_test.cpp
@@ -91,7 +91,7 @@ void ApplyOpsTest::setUp() {
// Set up ReplicationCoordinator and create oplog.
ReplicationCoordinator::set(service, stdx::make_unique<ReplicationCoordinatorMock>(service));
- setOplogCollectionName();
+ setOplogCollectionName(service);
createOplog(opCtx.get());
// Ensure that we are primary.
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp
index 7a411a498b3..452b3c24941 100644
--- a/src/mongo/db/repl/bgsync.cpp
+++ b/src/mongo/db/repl/bgsync.cpp
@@ -139,11 +139,12 @@ static ServerStatusMetricField<Counter64> displayBufferMaxSize("repl.buffer.maxS
BackgroundSync::BackgroundSync(
+ ReplicationCoordinator* replicationCoordinator,
ReplicationCoordinatorExternalState* replicationCoordinatorExternalState,
ReplicationProcess* replicationProcess,
std::unique_ptr<OplogBuffer> oplogBuffer)
: _oplogBuffer(std::move(oplogBuffer)),
- _replCoord(getGlobalReplicationCoordinator()),
+ _replCoord(replicationCoordinator),
_replicationCoordinatorExternalState(replicationCoordinatorExternalState),
_replicationProcess(replicationProcess) {
// Update "repl.buffer.maxSizeBytes" server status metric to reflect the current oplog buffer's
diff --git a/src/mongo/db/repl/bgsync.h b/src/mongo/db/repl/bgsync.h
index 427d195149c..cf1f064c4f5 100644
--- a/src/mongo/db/repl/bgsync.h
+++ b/src/mongo/db/repl/bgsync.h
@@ -77,7 +77,8 @@ public:
*/
enum class ProducerState { Starting, Running, Stopped };
- BackgroundSync(ReplicationCoordinatorExternalState* replicationCoordinatorExternalState,
+ BackgroundSync(ReplicationCoordinator* replicationCoordinator,
+ ReplicationCoordinatorExternalState* replicationCoordinatorExternalState,
ReplicationProcess* replicationProcess,
std::unique_ptr<OplogBuffer> oplogBuffer);
diff --git a/src/mongo/db/repl/do_txn_test.cpp b/src/mongo/db/repl/do_txn_test.cpp
index de0de6ab4b9..419b28a82e2 100644
--- a/src/mongo/db/repl/do_txn_test.cpp
+++ b/src/mongo/db/repl/do_txn_test.cpp
@@ -90,7 +90,7 @@ void DoTxnTest::setUp() {
// Set up ReplicationCoordinator and create oplog.
ReplicationCoordinator::set(service, stdx::make_unique<ReplicationCoordinatorMock>(service));
- setOplogCollectionName();
+ setOplogCollectionName(service);
createOplog(opCtx.get());
// Ensure that we are primary.
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index 08961a2c840..63210ca1bed 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -270,7 +270,7 @@ void ReplSource::loadAll(OperationContext* opCtx, SourceVector& v) {
SourceVector old = v;
v.clear();
- const ReplSettings& replSettings = getGlobalReplicationCoordinator()->getSettings();
+ const ReplSettings& replSettings = ReplicationCoordinator::get(opCtx)->getSettings();
if (!replSettings.getSource().empty()) {
// --source <host> specified.
// check that no items are in sources other than that
@@ -394,7 +394,7 @@ public:
ReplClientInfo::forClient(opCtx->getClient()).setRemoteID(handshake.getRid());
- status = getGlobalReplicationCoordinator()->processHandshake(opCtx, handshake);
+ status = ReplicationCoordinator::get(opCtx)->processHandshake(opCtx, handshake);
return CommandHelpers::appendCommandStatus(result, status);
}
@@ -439,7 +439,7 @@ void ReplSource::forceResync(OperationContext* opCtx, const char* requester) {
if (!_connect(&oplogReader,
HostAndPort(hostName),
- getGlobalReplicationCoordinator()->getMyRID())) {
+ ReplicationCoordinator::get(opCtx)->getMyRID())) {
msgasserted(14051, "unable to connect to resync");
}
bool ok = oplogReader.conn()->runCommand(
@@ -466,12 +466,12 @@ void ReplSource::forceResync(OperationContext* opCtx, const char* requester) {
save(opCtx);
}
-Status ReplSource::_updateIfDoneWithInitialSync() {
+Status ReplSource::_updateIfDoneWithInitialSync(OperationContext* opCtx) {
const auto usedToDoHandshake = _doHandshake;
if (!usedToDoHandshake && addDbNextPass.empty() && incompleteCloneDbs.empty()) {
_doHandshake = true;
oplogReader.resetConnection();
- const auto myRID = getGlobalReplicationCoordinator()->getMyRID();
+ const auto myRID = ReplicationCoordinator::get(opCtx)->getMyRID();
if (!_connect(&oplogReader, HostAndPort{hostName}, myRID)) {
return {ErrorCodes::MasterSlaveConnectionFailure,
str::stream() << "could not connect to " << hostName << " with rid: "
@@ -727,7 +727,7 @@ void ReplSource::_sync_pullOpLog_applyOperation(OperationContext* opCtx,
// reported.
CurOp individualOp(opCtx);
UnreplicatedWritesBlock uwb(opCtx);
- const ReplSettings& replSettings = getGlobalReplicationCoordinator()->getSettings();
+ const ReplSettings& replSettings = ReplicationCoordinator::get(opCtx)->getSettings();
if (replSettings.getPretouch() &&
!alreadyLocked /*doesn't make sense if in write lock already*/) {
if (replSettings.getPretouch() > 1) {
@@ -949,7 +949,7 @@ int ReplSource::_sync_pullOpLog(OperationContext* opCtx, int& nApplied) {
}
}
- auto status = _updateIfDoneWithInitialSync();
+ auto status = _updateIfDoneWithInitialSync(opCtx);
if (!status.isOK()) {
switch (status.code()) {
case ErrorCodes::Interrupted: {
@@ -1089,7 +1089,8 @@ int ReplSource::_sync_pullOpLog(OperationContext* opCtx, int& nApplied) {
"replication error last applied optime at slave >= nextOpTime from master",
false);
}
- const ReplSettings& replSettings = getGlobalReplicationCoordinator()->getSettings();
+ const ReplSettings& replSettings =
+ ReplicationCoordinator::get(opCtx)->getSettings();
if (replSettings.getSlaveDelaySecs() != Seconds(0) &&
(Seconds(time(0)) <
Seconds(nextOpTime.getSecs()) + replSettings.getSlaveDelaySecs())) {
@@ -1154,7 +1155,7 @@ int ReplSource::sync(OperationContext* opCtx, int& nApplied) {
}
if (!_connect(
- &oplogReader, HostAndPort(hostName), getGlobalReplicationCoordinator()->getMyRID())) {
+ &oplogReader, HostAndPort(hostName), ReplicationCoordinator::get(opCtx)->getMyRID())) {
LOG(4) << "can't connect to sync source" << endl;
return -1;
}
@@ -1236,7 +1237,7 @@ static void replMain(OperationContext* opCtx) {
Lock::GlobalWrite lk(opCtx);
if (replAllDead) {
// throttledForceResyncDead can throw
- if (!getGlobalReplicationCoordinator()->getSettings().isAutoResyncEnabled() ||
+ if (!ReplicationCoordinator::get(opCtx)->getSettings().isAutoResyncEnabled() ||
!ReplSource::throttledForceResyncDead(opCtx, "auto")) {
log() << "all sources dead: " << replAllDead << ", sleeping for 5 seconds"
<< endl;
@@ -1348,7 +1349,7 @@ static void replSlaveThread() {
}
void startMasterSlave(OperationContext* opCtx) {
- const ReplSettings& replSettings = getGlobalReplicationCoordinator()->getSettings();
+ const ReplSettings& replSettings = ReplicationCoordinator::get(opCtx)->getSettings();
if (!replSettings.isSlave() && !replSettings.isMaster())
return;
diff --git a/src/mongo/db/repl/master_slave.h b/src/mongo/db/repl/master_slave.h
index 84c41df95ba..81d56aadac6 100644
--- a/src/mongo/db/repl/master_slave.h
+++ b/src/mongo/db/repl/master_slave.h
@@ -136,7 +136,7 @@ class ReplSource {
bool _connect(OplogReader* reader, const HostAndPort& host, const OID& myRID);
- Status _updateIfDoneWithInitialSync();
+ Status _updateIfDoneWithInitialSync(OperationContext* opCtx);
public:
OplogReader oplogReader;
diff --git a/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp b/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp
index d690484b0ce..95dd56ea92b 100644
--- a/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp
+++ b/src/mongo/db/repl/mock_repl_coord_server_fixture.cpp
@@ -81,7 +81,7 @@ void MockReplCoordServerFixture::setUp() {
ASSERT_TRUE(
client.createCollection(NamespaceString::kRsOplogNamespace.ns(), 1024 * 1024, true));
- repl::setOplogCollectionName();
+ repl::setOplogCollectionName(service);
repl::acquireOplogCollectionForLogging(opCtx());
}
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 0c7c5e29efd..0deb0def76f 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -218,8 +218,8 @@ private:
} // namespace
-void setOplogCollectionName() {
- switch (getGlobalReplicationCoordinator()->getReplicationMode()) {
+void setOplogCollectionName(ServiceContext* service) {
+ switch (ReplicationCoordinator::get(service)->getReplicationMode()) {
case ReplicationCoordinator::modeReplSet:
_oplogCollectionName = NamespaceString::kRsOplogNamespace.ns();
break;
diff --git a/src/mongo/db/repl/oplog.h b/src/mongo/db/repl/oplog.h
index 6f773694945..6a2de1c6bc4 100644
--- a/src/mongo/db/repl/oplog.h
+++ b/src/mongo/db/repl/oplog.h
@@ -245,7 +245,7 @@ void setNewTimestamp(ServiceContext* opCtx, const Timestamp& newTime);
/**
* Detects the current replication mode and sets the "_oplogCollectionName" accordingly.
*/
-void setOplogCollectionName();
+void setOplogCollectionName(ServiceContext* service);
/**
* Signal any waiting AwaitData queries on the oplog that there is new data or metadata available.
diff --git a/src/mongo/db/repl/oplog_test.cpp b/src/mongo/db/repl/oplog_test.cpp
index 7666e026955..9a38b77d489 100644
--- a/src/mongo/db/repl/oplog_test.cpp
+++ b/src/mongo/db/repl/oplog_test.cpp
@@ -67,7 +67,7 @@ void OplogTest::setUp() {
// Set up ReplicationCoordinator and create oplog.
ReplicationCoordinator::set(service, stdx::make_unique<ReplicationCoordinatorMock>(service));
- setOplogCollectionName();
+ setOplogCollectionName(service);
createOplog(opCtx.get());
// Ensure that we are primary.
diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp
index e2d28cadb6f..f9917d98177 100644
--- a/src/mongo/db/repl/repl_set_commands.cpp
+++ b/src/mongo/db/repl/repl_set_commands.cpp
@@ -167,7 +167,7 @@ public:
const string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
@@ -196,7 +196,7 @@ public:
if (cmdObj["forShell"].trueValue())
LastError::get(opCtx->getClient()).disable();
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
@@ -211,7 +211,8 @@ public:
if (includeInitialSync) {
responseStyle = ReplicationCoordinator::ReplSetGetStatusResponseStyle::kInitialSync;
}
- status = getGlobalReplicationCoordinator()->processReplSetGetStatus(&result, responseStyle);
+ status =
+ ReplicationCoordinator::get(opCtx)->processReplSetGetStatus(&result, responseStyle);
return CommandHelpers::appendCommandStatus(result, status);
}
@@ -233,11 +234,11 @@ public:
const string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
- getGlobalReplicationCoordinator()->processReplSetGetConfig(&result);
+ ReplicationCoordinator::get(opCtx)->processReplSetGetConfig(&result);
return true;
}
@@ -403,7 +404,7 @@ public:
}
Status status =
- getGlobalReplicationCoordinator()->processReplSetInitiate(opCtx, configObj, &result);
+ ReplicationCoordinator::get(opCtx)->processReplSetInitiate(opCtx, configObj, &result);
return CommandHelpers::appendCommandStatus(result, status);
}
@@ -425,7 +426,7 @@ public:
const string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK()) {
return CommandHelpers::appendCommandStatus(result, status);
}
@@ -439,7 +440,7 @@ public:
parsedArgs.newConfigObj = cmdObj["replSetReconfig"].Obj();
parsedArgs.force = cmdObj.hasField("force") && cmdObj["force"].trueValue();
status =
- getGlobalReplicationCoordinator()->processReplSetReconfig(opCtx, parsedArgs, &result);
+ ReplicationCoordinator::get(opCtx)->processReplSetReconfig(opCtx, parsedArgs, &result);
Lock::GlobalWrite globalWrite(opCtx);
@@ -482,13 +483,13 @@ public:
const string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
int secs = (int)cmdObj.firstElement().numberInt();
return CommandHelpers::appendCommandStatus(
- result, getGlobalReplicationCoordinator()->processReplSetFreeze(secs, &result));
+ result, ReplicationCoordinator::get(opCtx)->processReplSetFreeze(secs, &result));
}
private:
@@ -512,7 +513,7 @@ public:
const string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
@@ -554,7 +555,7 @@ public:
log() << "Attempting to step down in response to replSetStepDown command";
- status = getGlobalReplicationCoordinator()->stepDown(
+ status = ReplicationCoordinator::get(opCtx)->stepDown(
opCtx, force, Seconds(secondaryCatchUpPeriodSecs), Seconds(stepDownForSecs));
return CommandHelpers::appendCommandStatus(result, status);
}
@@ -576,13 +577,13 @@ public:
const string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
return CommandHelpers::appendCommandStatus(
result,
- getGlobalReplicationCoordinator()->setMaintenanceMode(
+ ReplicationCoordinator::get(opCtx)->setMaintenanceMode(
cmdObj["replSetMaintenance"].trueValue()));
}
@@ -604,7 +605,7 @@ public:
const string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
@@ -615,7 +616,7 @@ public:
return CommandHelpers::appendCommandStatus(
result,
- getGlobalReplicationCoordinator()->processReplSetSyncFrom(
+ ReplicationCoordinator::get(opCtx)->processReplSetSyncFrom(
opCtx, targetHostAndPort, &result));
}
@@ -727,7 +728,7 @@ public:
Status status = Status(ErrorCodes::InternalError, "status not set in heartbeat code");
/* we don't call ReplSetCommand::check() here because heartbeat
checks many things that are pre-initialization. */
- if (!getGlobalReplicationCoordinator()->getSettings().usingReplSets()) {
+ if (!ReplicationCoordinator::get(opCtx)->getSettings().usingReplSets()) {
status = Status(ErrorCodes::NoReplicationEnabled, "not running with --replSet");
return CommandHelpers::appendCommandStatus(result, status);
}
@@ -739,7 +740,7 @@ public:
status = args.initialize(cmdObj);
if (status.isOK()) {
ReplSetHeartbeatResponse response;
- status = getGlobalReplicationCoordinator()->processHeartbeatV1(args, &response);
+ status = ReplicationCoordinator::get(opCtx)->processHeartbeatV1(args, &response);
if (status.isOK())
response.addToBSON(&result, true);
@@ -764,7 +765,7 @@ public:
}
ReplSetHeartbeatResponse response;
- status = getGlobalReplicationCoordinator()->processHeartbeat(args, &response);
+ status = ReplicationCoordinator::get(opCtx)->processHeartbeat(args, &response);
if (status.isOK())
response.addToBSON(&result, false);
@@ -785,7 +786,7 @@ public:
const string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
@@ -802,7 +803,7 @@ public:
parsedArgs.cfgver = cfgverElement.safeNumberLong();
parsedArgs.opTime = Timestamp(cmdObj["opTime"].Date());
- status = getGlobalReplicationCoordinator()->processReplSetFresh(parsedArgs, &result);
+ status = ReplicationCoordinator::get(opCtx)->processReplSetFresh(parsedArgs, &result);
return CommandHelpers::appendCommandStatus(result, status);
}
} cmdReplSetFresh;
@@ -819,7 +820,7 @@ private:
DEV log() << "received elect msg " << cmdObj.toString();
else LOG(2) << "received elect msg " << cmdObj.toString();
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
@@ -835,7 +836,7 @@ private:
parsedArgs.cfgver = cfgverElement.safeNumberLong();
parsedArgs.round = cmdObj["round"].OID();
- status = getGlobalReplicationCoordinator()->processReplSetElect(parsedArgs, &result);
+ status = ReplicationCoordinator::get(opCtx)->processReplSetElect(parsedArgs, &result);
return CommandHelpers::appendCommandStatus(result, status);
}
} cmdReplSetElect;
@@ -848,13 +849,13 @@ public:
const string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
log() << "Received replSetStepUp request";
- status = getGlobalReplicationCoordinator()->stepUpIfEligible();
+ status = ReplicationCoordinator::get(opCtx)->stepUpIfEligible();
if (!status.isOK()) {
log() << "replSetStepUp request failed" << causedBy(status);
@@ -883,12 +884,12 @@ public:
const string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) override {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK())
return CommandHelpers::appendCommandStatus(result, status);
log() << "Received replSetAbortPrimaryCatchUp request";
- status = getGlobalReplicationCoordinator()->abortCatchupIfNeeded();
+ status = ReplicationCoordinator::get(opCtx)->abortCatchupIfNeeded();
if (!status.isOK()) {
log() << "replSetAbortPrimaryCatchUp request failed" << causedBy(status);
}
diff --git a/src/mongo/db/repl/repl_set_request_votes.cpp b/src/mongo/db/repl/repl_set_request_votes.cpp
index 70b7c3d9b4b..1ceda277eb7 100644
--- a/src/mongo/db/repl/repl_set_request_votes.cpp
+++ b/src/mongo/db/repl/repl_set_request_votes.cpp
@@ -51,7 +51,7 @@ private:
const std::string&,
const BSONObj& cmdObj,
BSONObjBuilder& result) final {
- Status status = getGlobalReplicationCoordinator()->checkReplEnabledForCommand(&result);
+ Status status = ReplicationCoordinator::get(opCtx)->checkReplEnabledForCommand(&result);
if (!status.isOK()) {
return CommandHelpers::appendCommandStatus(result, status);
}
@@ -63,7 +63,7 @@ private:
}
ReplSetRequestVotesResponse response;
- status = getGlobalReplicationCoordinator()->processReplSetRequestVotes(
+ status = ReplicationCoordinator::get(opCtx)->processReplSetRequestVotes(
opCtx, parsedArgs, &response);
response.addToBSON(&result);
return CommandHelpers::appendCommandStatus(result, status);
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
index 92cf503c0c3..421f71f48e1 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -233,7 +233,7 @@ void ReplicationCoordinatorExternalStateImpl::startSteadyStateReplication(
invariant(!_bgSync);
log() << "Starting replication fetcher thread";
_bgSync = stdx::make_unique<BackgroundSync>(
- this, _replicationProcess, makeSteadyStateOplogBuffer(opCtx));
+ replCoord, this, _replicationProcess, makeSteadyStateOplogBuffer(opCtx));
_bgSync->startup(opCtx);
log() << "Starting replication applier thread";
@@ -348,7 +348,7 @@ void ReplicationCoordinatorExternalStateImpl::shutdown(OperationContext* opCtx)
// oplog. We record this update at the 'lastAppliedOpTime'. If there are any outstanding
// checkpoints being taken, they should only reflect this write if they see all writes up
// to our 'lastAppliedOpTime'.
- auto lastAppliedOpTime = repl::getGlobalReplicationCoordinator()->getMyLastAppliedOpTime();
+ auto lastAppliedOpTime = repl::ReplicationCoordinator::get(opCtx)->getMyLastAppliedOpTime();
_replicationProcess->getConsistencyMarkers()->clearAppliedThrough(
opCtx, lastAppliedOpTime.getTimestamp());
}
@@ -466,7 +466,7 @@ OpTime ReplicationCoordinatorExternalStateImpl::onTransitionToPrimary(OperationC
// to our 'lastAppliedOpTime'.
invariant(
_replicationProcess->getConsistencyMarkers()->getOplogTruncateAfterPoint(opCtx).isNull());
- auto lastAppliedOpTime = repl::getGlobalReplicationCoordinator()->getMyLastAppliedOpTime();
+ auto lastAppliedOpTime = repl::ReplicationCoordinator::get(opCtx)->getMyLastAppliedOpTime();
_replicationProcess->getConsistencyMarkers()->clearAppliedThrough(
opCtx, lastAppliedOpTime.getTimestamp());
@@ -912,11 +912,11 @@ std::size_t ReplicationCoordinatorExternalStateImpl::getOplogFetcherMaxFetcherRe
}
JournalListener::Token ReplicationCoordinatorExternalStateImpl::getToken() {
- return repl::getGlobalReplicationCoordinator()->getMyLastAppliedOpTime();
+ return repl::ReplicationCoordinator::get(_service)->getMyLastAppliedOpTime();
}
void ReplicationCoordinatorExternalStateImpl::onDurable(const JournalListener::Token& token) {
- repl::getGlobalReplicationCoordinator()->setMyLastDurableOpTimeForward(token);
+ repl::ReplicationCoordinator::get(_service)->setMyLastDurableOpTimeForward(token);
}
void ReplicationCoordinatorExternalStateImpl::startNoopWriter(OpTime opTime) {
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index 2a772d192dd..b33a9e54d46 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -69,7 +69,7 @@ using std::stringstream;
namespace repl {
void appendReplicationInfo(OperationContext* opCtx, BSONObjBuilder& result, int level) {
- ReplicationCoordinator* replCoord = getGlobalReplicationCoordinator();
+ ReplicationCoordinator* replCoord = ReplicationCoordinator::get(opCtx);
if (replCoord->getSettings().usingReplSets()) {
IsMasterResponse isMasterResponse;
replCoord->fillIsMasterForReplSet(&isMasterResponse);
@@ -87,7 +87,7 @@ void appendReplicationInfo(OperationContext* opCtx, BSONObjBuilder& result, int
result.append("info", s);
} else {
result.appendBool("ismaster",
- getGlobalReplicationCoordinator()->isMasterForReportingPurposes());
+ ReplicationCoordinator::get(opCtx)->isMasterForReportingPurposes());
}
if (level) {
@@ -162,7 +162,7 @@ public:
}
BSONObj generateSection(OperationContext* opCtx, const BSONElement& configElement) const {
- if (!getGlobalReplicationCoordinator()->isReplEnabled()) {
+ if (!ReplicationCoordinator::get(opCtx)->isReplEnabled()) {
return BSONObj();
}
@@ -189,7 +189,7 @@ public:
}
BSONObj generateSection(OperationContext* opCtx, const BSONElement& configElement) const {
- ReplicationCoordinator* replCoord = getGlobalReplicationCoordinator();
+ ReplicationCoordinator* replCoord = ReplicationCoordinator::get(opCtx);
if (!replCoord->isReplEnabled()) {
return BSONObj();
}
diff --git a/src/mongo/db/repl/resync.cpp b/src/mongo/db/repl/resync.cpp
index 13cc0ffbbd9..dbcdcbcb203 100644
--- a/src/mongo/db/repl/resync.cpp
+++ b/src/mongo/db/repl/resync.cpp
@@ -80,8 +80,8 @@ public:
bool waitForResync = !cmdObj.hasField(kWaitFieldName) || cmdObj[kWaitFieldName].trueValue();
// Replica set resync.
- ReplicationCoordinator* replCoord = getGlobalReplicationCoordinator();
- if (getGlobalReplicationCoordinator()->getSettings().usingReplSets()) {
+ ReplicationCoordinator* replCoord = ReplicationCoordinator::get(opCtx);
+ if (replCoord->getSettings().usingReplSets()) {
// Resync is disabled in production on replica sets until it stabilizes (SERVER-27081).
if (!Command::testCommandsEnabled) {
return CommandHelpers::appendCommandStatus(
diff --git a/src/mongo/db/repl/rollback_test_fixture.cpp b/src/mongo/db/repl/rollback_test_fixture.cpp
index 2731343178f..ed38f2453b4 100644
--- a/src/mongo/db/repl/rollback_test_fixture.cpp
+++ b/src/mongo/db/repl/rollback_test_fixture.cpp
@@ -81,7 +81,7 @@ void RollbackTest::setUp() {
_coordinator = new ReplicationCoordinatorRollbackMock(serviceContext);
ReplicationCoordinator::set(serviceContext,
std::unique_ptr<ReplicationCoordinator>(_coordinator));
- setOplogCollectionName();
+ setOplogCollectionName(serviceContext);
SessionCatalog::create(serviceContext);
diff --git a/src/mongo/db/repl/sync_tail_test_fixture.cpp b/src/mongo/db/repl/sync_tail_test_fixture.cpp
index f101cfe59d8..eec7a5ea456 100644
--- a/src/mongo/db/repl/sync_tail_test_fixture.cpp
+++ b/src/mongo/db/repl/sync_tail_test_fixture.cpp
@@ -70,7 +70,7 @@ void SyncTailTest::setUp() {
StorageInterface::set(service, std::move(storageInterface));
DropPendingCollectionReaper::set(
service, stdx::make_unique<DropPendingCollectionReaper>(_storageInterface));
- repl::setOplogCollectionName();
+ repl::setOplogCollectionName(service);
repl::createOplog(_opCtx.get());
service->setOpObserver(stdx::make_unique<OpObserverImpl>());