diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/s/catalog/dist_lock_catalog_impl.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/s/catalog/dist_lock_catalog_impl.cpp')
-rw-r--r-- | src/mongo/s/catalog/dist_lock_catalog_impl.cpp | 580 |
1 files changed, 277 insertions, 303 deletions
diff --git a/src/mongo/s/catalog/dist_lock_catalog_impl.cpp b/src/mongo/s/catalog/dist_lock_catalog_impl.cpp index 57aab2dd2fc..e7a2830e546 100644 --- a/src/mongo/s/catalog/dist_lock_catalog_impl.cpp +++ b/src/mongo/s/catalog/dist_lock_catalog_impl.cpp @@ -49,397 +49,371 @@ namespace mongo { - using std::string; +using std::string; namespace { - const char kCmdResponseWriteConcernField[] = "writeConcernError"; - const char kFindAndModifyResponseResultDocField[] = "value"; - const char kLocalTimeField[] = "localTime"; - const ReadPreferenceSetting kReadPref(ReadPreference::PrimaryOnly, TagSet()); - - /** - * Returns the resulting new object from the findAndModify response object. - * Returns LockStateChangeFailed if value field was null, which indicates that - * the findAndModify command did not modify any document. - * This also checks for errors in the response object. - */ - StatusWith<BSONObj> extractFindAndModifyNewObj(const BSONObj& responseObj) { - auto cmdStatus = getStatusFromCommandResult(responseObj); - - if (!cmdStatus.isOK()) { - return cmdStatus; - } +const char kCmdResponseWriteConcernField[] = "writeConcernError"; +const char kFindAndModifyResponseResultDocField[] = "value"; +const char kLocalTimeField[] = "localTime"; +const ReadPreferenceSetting kReadPref(ReadPreference::PrimaryOnly, TagSet()); - BSONElement wcErrorElem; - auto wcErrStatus = bsonExtractTypedField(responseObj, - kCmdResponseWriteConcernField, - Object, - &wcErrorElem); +/** + * Returns the resulting new object from the findAndModify response object. + * Returns LockStateChangeFailed if value field was null, which indicates that + * the findAndModify command did not modify any document. + * This also checks for errors in the response object. + */ +StatusWith<BSONObj> extractFindAndModifyNewObj(const BSONObj& responseObj) { + auto cmdStatus = getStatusFromCommandResult(responseObj); - if (wcErrStatus.isOK()) { - BSONObj wcErrObj(wcErrorElem.Obj()); - WCErrorDetail wcError; + if (!cmdStatus.isOK()) { + return cmdStatus; + } - string wcErrorParseMsg; - if (!wcError.parseBSON(wcErrObj, &wcErrorParseMsg)) { - return Status(ErrorCodes::UnsupportedFormat, wcErrorParseMsg); - } + BSONElement wcErrorElem; + auto wcErrStatus = + bsonExtractTypedField(responseObj, kCmdResponseWriteConcernField, Object, &wcErrorElem); - return {ErrorCodes::WriteConcernFailed, wcError.getErrMessage()}; - } + if (wcErrStatus.isOK()) { + BSONObj wcErrObj(wcErrorElem.Obj()); + WCErrorDetail wcError; - if (wcErrStatus != ErrorCodes::NoSuchKey) { - return wcErrStatus; + string wcErrorParseMsg; + if (!wcError.parseBSON(wcErrObj, &wcErrorParseMsg)) { + return Status(ErrorCodes::UnsupportedFormat, wcErrorParseMsg); } - if (const auto& newDocElem = responseObj[kFindAndModifyResponseResultDocField]) { - if (newDocElem.isNull()) { - return {ErrorCodes::LockStateChangeFailed, - "findAndModify query predicate didn't match any lock document"}; - } + return {ErrorCodes::WriteConcernFailed, wcError.getErrMessage()}; + } - if (!newDocElem.isABSONObj()) { - return {ErrorCodes::UnsupportedFormat, - str::stream() << "expected an object from the findAndModify response '" - << kFindAndModifyResponseResultDocField << "'field, got: " - << newDocElem}; - } + if (wcErrStatus != ErrorCodes::NoSuchKey) { + return wcErrStatus; + } - return newDocElem.Obj(); + if (const auto& newDocElem = responseObj[kFindAndModifyResponseResultDocField]) { + if (newDocElem.isNull()) { + return {ErrorCodes::LockStateChangeFailed, + "findAndModify query predicate didn't match any lock document"}; } - return {ErrorCodes::LockStateChangeFailed, - str::stream() << "no '" << kFindAndModifyResponseResultDocField - << "' in findAndModify response"}; - } - - /** - * Extract the electionId from a command response. - * - * TODO: this needs to support OP_COMMAND metadata. - */ - StatusWith<OID> extractElectionId(const BSONObj& responseObj) { - - BSONElement gleStatsElem; - auto gleStatus = bsonExtractTypedField(responseObj, - "$gleStats", - Object, - &gleStatsElem); - - if (!gleStatus.isOK()) { - return {ErrorCodes::UnsupportedFormat, gleStatus.reason()}; + if (!newDocElem.isABSONObj()) { + return {ErrorCodes::UnsupportedFormat, + str::stream() << "expected an object from the findAndModify response '" + << kFindAndModifyResponseResultDocField + << "'field, got: " << newDocElem}; } - OID electionId; + return newDocElem.Obj(); + } - auto electionIdStatus = bsonExtractOIDField(gleStatsElem.Obj(), - "electionId", - &electionId); + return {ErrorCodes::LockStateChangeFailed, + str::stream() << "no '" << kFindAndModifyResponseResultDocField + << "' in findAndModify response"}; +} - if (!electionIdStatus.isOK()) { - return {ErrorCodes::UnsupportedFormat, electionIdStatus.reason()}; - } +/** + * Extract the electionId from a command response. + * + * TODO: this needs to support OP_COMMAND metadata. + */ +StatusWith<OID> extractElectionId(const BSONObj& responseObj) { + BSONElement gleStatsElem; + auto gleStatus = bsonExtractTypedField(responseObj, "$gleStats", Object, &gleStatsElem); - return electionId; + if (!gleStatus.isOK()) { + return {ErrorCodes::UnsupportedFormat, gleStatus.reason()}; } -} // unnamed namespace - - DistLockCatalogImpl::DistLockCatalogImpl(RemoteCommandTargeter* targeter, - RemoteCommandRunner* executor, - Milliseconds writeConcernTimeout): - _cmdRunner(executor), - _targeter(targeter), - _writeConcern(WriteConcernOptions(WriteConcernOptions::kMajority, - WriteConcernOptions::JOURNAL, - writeConcernTimeout.count())), - _lockPingNS(LockpingsType::ConfigNS), - _locksNS(LocksType::ConfigNS) { + OID electionId; + + auto electionIdStatus = bsonExtractOIDField(gleStatsElem.Obj(), "electionId", &electionId); + + if (!electionIdStatus.isOK()) { + return {ErrorCodes::UnsupportedFormat, electionIdStatus.reason()}; } - DistLockCatalogImpl::~DistLockCatalogImpl() = default; + return electionId; +} + +} // unnamed namespace + +DistLockCatalogImpl::DistLockCatalogImpl(RemoteCommandTargeter* targeter, + RemoteCommandRunner* executor, + Milliseconds writeConcernTimeout) + : _cmdRunner(executor), + _targeter(targeter), + _writeConcern(WriteConcernOptions(WriteConcernOptions::kMajority, + WriteConcernOptions::JOURNAL, + writeConcernTimeout.count())), + _lockPingNS(LockpingsType::ConfigNS), + _locksNS(LocksType::ConfigNS) {} + +DistLockCatalogImpl::~DistLockCatalogImpl() = default; - StatusWith<LockpingsType> DistLockCatalogImpl::getPing(StringData processID) { - invariant(false); // TODO +StatusWith<LockpingsType> DistLockCatalogImpl::getPing(StringData processID) { + invariant(false); // TODO +} + +Status DistLockCatalogImpl::ping(StringData processID, Date_t ping) { + auto targetStatus = _targeter->findHost(kReadPref); + + if (!targetStatus.isOK()) { + return targetStatus.getStatus(); } - Status DistLockCatalogImpl::ping(StringData processID, Date_t ping) { - auto targetStatus = _targeter->findHost(kReadPref); + auto request = + FindAndModifyRequest::makeUpdate(_lockPingNS, + BSON(LockpingsType::process(processID.toString())), + BSON("$set" << BSON(LockpingsType::ping(ping)))); + request.setUpsert(true); + request.setWriteConcern(_writeConcern); - if (!targetStatus.isOK()) { - return targetStatus.getStatus(); - } + auto resultStatus = _cmdRunner->runCommand( + RemoteCommandRequest(targetStatus.getValue(), _locksNS.db().toString(), request.toBSON())); - auto request = FindAndModifyRequest::makeUpdate(_lockPingNS, - BSON(LockpingsType::process(processID.toString())), - BSON("$set" << BSON(LockpingsType::ping(ping)))); - request.setUpsert(true); - request.setWriteConcern(_writeConcern); + if (!resultStatus.isOK()) { + return resultStatus.getStatus(); + } - auto resultStatus = _cmdRunner->runCommand( - RemoteCommandRequest(targetStatus.getValue(), - _locksNS.db().toString(), - request.toBSON())); + const RemoteCommandResponse& response = resultStatus.getValue(); + BSONObj responseObj(response.data); - if (!resultStatus.isOK()) { - return resultStatus.getStatus(); - } + auto cmdStatus = getStatusFromCommandResult(responseObj); - const RemoteCommandResponse& response = resultStatus.getValue(); - BSONObj responseObj(response.data); + if (!cmdStatus.isOK()) { + return cmdStatus; + } - auto cmdStatus = getStatusFromCommandResult(responseObj); + auto findAndModifyStatus = extractFindAndModifyNewObj(responseObj); + return findAndModifyStatus.getStatus(); +} - if (!cmdStatus.isOK()) { - return cmdStatus; - } +StatusWith<LocksType> DistLockCatalogImpl::grabLock(StringData lockID, + const OID& lockSessionID, + StringData who, + StringData processId, + Date_t time, + StringData why) { + auto targetStatus = _targeter->findHost(kReadPref); - auto findAndModifyStatus = extractFindAndModifyNewObj(responseObj); - return findAndModifyStatus.getStatus(); + if (!targetStatus.isOK()) { + return targetStatus.getStatus(); } - StatusWith<LocksType> DistLockCatalogImpl::grabLock(StringData lockID, - const OID& lockSessionID, - StringData who, - StringData processId, - Date_t time, - StringData why) { - auto targetStatus = _targeter->findHost(kReadPref); + BSONObj newLockDetails(BSON(LocksType::lockID(lockSessionID) + << LocksType::state(LocksType::LOCKED) << LocksType::who() << who + << LocksType::process() << processId << LocksType::when(time) + << LocksType::why() << why)); - if (!targetStatus.isOK()) { - return targetStatus.getStatus(); - } + auto request = FindAndModifyRequest::makeUpdate( + _locksNS, + BSON(LocksType::name() << lockID << LocksType::state(LocksType::UNLOCKED)), + BSON("$set" << newLockDetails)); + request.setUpsert(true); + request.setShouldReturnNew(true); + request.setWriteConcern(_writeConcern); - BSONObj newLockDetails(BSON(LocksType::lockID(lockSessionID) - << LocksType::state(LocksType::LOCKED) - << LocksType::who() << who - << LocksType::process() << processId - << LocksType::when(time) - << LocksType::why() << why)); - - auto request = FindAndModifyRequest::makeUpdate(_locksNS, - BSON(LocksType::name() << lockID << LocksType::state(LocksType::UNLOCKED)), - BSON("$set" << newLockDetails)); - request.setUpsert(true); - request.setShouldReturnNew(true); - request.setWriteConcern(_writeConcern); - - auto resultStatus = _cmdRunner->runCommand( - RemoteCommandRequest(targetStatus.getValue(), - _locksNS.db().toString(), - request.toBSON())); - - if (!resultStatus.isOK()) { - return resultStatus.getStatus(); - } + auto resultStatus = _cmdRunner->runCommand( + RemoteCommandRequest(targetStatus.getValue(), _locksNS.db().toString(), request.toBSON())); - const RemoteCommandResponse& response = resultStatus.getValue(); - BSONObj responseObj(response.data); + if (!resultStatus.isOK()) { + return resultStatus.getStatus(); + } - auto cmdStatus = getStatusFromCommandResult(responseObj); + const RemoteCommandResponse& response = resultStatus.getValue(); + BSONObj responseObj(response.data); - if (!cmdStatus.isOK()) { - return cmdStatus; - } + auto cmdStatus = getStatusFromCommandResult(responseObj); - auto findAndModifyStatus = extractFindAndModifyNewObj(responseObj); - if (!findAndModifyStatus.isOK()) { - return findAndModifyStatus.getStatus(); - } + if (!cmdStatus.isOK()) { + return cmdStatus; + } - BSONObj newDoc(findAndModifyStatus.getValue()); + auto findAndModifyStatus = extractFindAndModifyNewObj(responseObj); + if (!findAndModifyStatus.isOK()) { + return findAndModifyStatus.getStatus(); + } - if (newDoc.isEmpty()) { - return LocksType(); - } + BSONObj newDoc(findAndModifyStatus.getValue()); - LocksType lockDoc; - string errMsg; - if (!lockDoc.parseBSON(newDoc, &errMsg)) { - return {ErrorCodes::FailedToParse, errMsg}; - } + if (newDoc.isEmpty()) { + return LocksType(); + } - return lockDoc; + LocksType lockDoc; + string errMsg; + if (!lockDoc.parseBSON(newDoc, &errMsg)) { + return {ErrorCodes::FailedToParse, errMsg}; } - StatusWith<LocksType> DistLockCatalogImpl::overtakeLock(StringData lockID, - const OID& lockSessionID, - const OID& currentHolderTS, - StringData who, - StringData processId, - Date_t time, - StringData why) { - auto targetStatus = _targeter->findHost(kReadPref); - - if (!targetStatus.isOK()) { - return targetStatus.getStatus(); - } + return lockDoc; +} - BSONArrayBuilder orQueryBuilder; - orQueryBuilder.append(BSON(LocksType::name() << lockID - << LocksType::state(LocksType::UNLOCKED))); - orQueryBuilder.append(BSON(LocksType::name() << lockID - << LocksType::lockID(currentHolderTS))); - - BSONObj newLockDetails(BSON(LocksType::lockID(lockSessionID) - << LocksType::state(LocksType::LOCKED) - << LocksType::who() << who - << LocksType::process() << processId - << LocksType::when(time) - << LocksType::why() << why)); - - auto request = FindAndModifyRequest::makeUpdate(_locksNS, - BSON("$or" << orQueryBuilder.arr()), - BSON("$set" << newLockDetails)); - request.setShouldReturnNew(true); - request.setWriteConcern(_writeConcern); - - auto resultStatus = _cmdRunner->runCommand( - RemoteCommandRequest(targetStatus.getValue(), - _locksNS.db().toString(), - request.toBSON())); - - if (!resultStatus.isOK()) { - return resultStatus.getStatus(); - } +StatusWith<LocksType> DistLockCatalogImpl::overtakeLock(StringData lockID, + const OID& lockSessionID, + const OID& currentHolderTS, + StringData who, + StringData processId, + Date_t time, + StringData why) { + auto targetStatus = _targeter->findHost(kReadPref); - const RemoteCommandResponse& response = resultStatus.getValue(); - BSONObj responseObj(response.data); + if (!targetStatus.isOK()) { + return targetStatus.getStatus(); + } - auto findAndModifyStatus = extractFindAndModifyNewObj(responseObj); - if (!findAndModifyStatus.isOK()) { - return findAndModifyStatus.getStatus(); - } + BSONArrayBuilder orQueryBuilder; + orQueryBuilder.append( + BSON(LocksType::name() << lockID << LocksType::state(LocksType::UNLOCKED))); + orQueryBuilder.append(BSON(LocksType::name() << lockID << LocksType::lockID(currentHolderTS))); - BSONObj newDoc(findAndModifyStatus.getValue()); + BSONObj newLockDetails(BSON(LocksType::lockID(lockSessionID) + << LocksType::state(LocksType::LOCKED) << LocksType::who() << who + << LocksType::process() << processId << LocksType::when(time) + << LocksType::why() << why)); - if (newDoc.isEmpty()) { - return LocksType(); - } + auto request = FindAndModifyRequest::makeUpdate( + _locksNS, BSON("$or" << orQueryBuilder.arr()), BSON("$set" << newLockDetails)); + request.setShouldReturnNew(true); + request.setWriteConcern(_writeConcern); - LocksType lockDoc; - string errMsg; - if (!lockDoc.parseBSON(newDoc, &errMsg)) { - return {ErrorCodes::FailedToParse, errMsg}; - } + auto resultStatus = _cmdRunner->runCommand( + RemoteCommandRequest(targetStatus.getValue(), _locksNS.db().toString(), request.toBSON())); - return lockDoc; + if (!resultStatus.isOK()) { + return resultStatus.getStatus(); } - Status DistLockCatalogImpl::unlock(const OID& lockSessionID) { - auto targetStatus = _targeter->findHost(kReadPref); - - if (!targetStatus.isOK()) { - return targetStatus.getStatus(); - } + const RemoteCommandResponse& response = resultStatus.getValue(); + BSONObj responseObj(response.data); - auto request = FindAndModifyRequest::makeUpdate(_locksNS, - BSON(LocksType::lockID(lockSessionID)), - BSON("$set" << BSON(LocksType::state(LocksType::UNLOCKED)))); - request.setWriteConcern(_writeConcern); + auto findAndModifyStatus = extractFindAndModifyNewObj(responseObj); + if (!findAndModifyStatus.isOK()) { + return findAndModifyStatus.getStatus(); + } - auto resultStatus = _cmdRunner->runCommand( - RemoteCommandRequest(targetStatus.getValue(), - _locksNS.db().toString(), - request.toBSON())); + BSONObj newDoc(findAndModifyStatus.getValue()); - if (!resultStatus.isOK()) { - return resultStatus.getStatus(); - } + if (newDoc.isEmpty()) { + return LocksType(); + } - const RemoteCommandResponse& response = resultStatus.getValue(); - BSONObj responseObj(response.data); + LocksType lockDoc; + string errMsg; + if (!lockDoc.parseBSON(newDoc, &errMsg)) { + return {ErrorCodes::FailedToParse, errMsg}; + } - auto findAndModifyStatus = extractFindAndModifyNewObj(responseObj).getStatus(); + return lockDoc; +} - if (findAndModifyStatus == ErrorCodes::LockStateChangeFailed) { - // Did not modify any document, which implies that the lock already has a - // a different owner. This is ok since it means that the objective of - // releasing ownership of the lock has already been accomplished. - return Status::OK(); - } +Status DistLockCatalogImpl::unlock(const OID& lockSessionID) { + auto targetStatus = _targeter->findHost(kReadPref); - return findAndModifyStatus; + if (!targetStatus.isOK()) { + return targetStatus.getStatus(); } - StatusWith<DistLockCatalog::ServerInfo> DistLockCatalogImpl::getServerInfo() { - auto targetStatus = _targeter->findHost(kReadPref); + auto request = FindAndModifyRequest::makeUpdate( + _locksNS, + BSON(LocksType::lockID(lockSessionID)), + BSON("$set" << BSON(LocksType::state(LocksType::UNLOCKED)))); + request.setWriteConcern(_writeConcern); - if (!targetStatus.isOK()) { - return targetStatus.getStatus(); - } + auto resultStatus = _cmdRunner->runCommand( + RemoteCommandRequest(targetStatus.getValue(), _locksNS.db().toString(), request.toBSON())); - auto resultStatus = _cmdRunner->runCommand(RemoteCommandRequest( - targetStatus.getValue(), - "admin", - BSON("serverStatus" << 1))); + if (!resultStatus.isOK()) { + return resultStatus.getStatus(); + } - if (!resultStatus.isOK()) { - return resultStatus.getStatus(); - } + const RemoteCommandResponse& response = resultStatus.getValue(); + BSONObj responseObj(response.data); - const RemoteCommandResponse& response = resultStatus.getValue(); - BSONObj responseObj(response.data); + auto findAndModifyStatus = extractFindAndModifyNewObj(responseObj).getStatus(); - auto cmdStatus = getStatusFromCommandResult(responseObj); + if (findAndModifyStatus == ErrorCodes::LockStateChangeFailed) { + // Did not modify any document, which implies that the lock already has a + // a different owner. This is ok since it means that the objective of + // releasing ownership of the lock has already been accomplished. + return Status::OK(); + } - if (!cmdStatus.isOK()) { - return cmdStatus; - } + return findAndModifyStatus; +} - BSONElement localTimeElem; - auto localTimeStatus = bsonExtractTypedField(responseObj, - kLocalTimeField, - Date, - &localTimeElem); +StatusWith<DistLockCatalog::ServerInfo> DistLockCatalogImpl::getServerInfo() { + auto targetStatus = _targeter->findHost(kReadPref); - if (!localTimeStatus.isOK()) { - return {ErrorCodes::UnsupportedFormat, localTimeStatus.reason()}; - } + if (!targetStatus.isOK()) { + return targetStatus.getStatus(); + } - auto electionIdStatus = extractElectionId(responseObj); + auto resultStatus = _cmdRunner->runCommand( + RemoteCommandRequest(targetStatus.getValue(), "admin", BSON("serverStatus" << 1))); - if (!electionIdStatus.isOK()) { - return {ErrorCodes::UnsupportedFormat, electionIdStatus.getStatus().reason()}; - } + if (!resultStatus.isOK()) { + return resultStatus.getStatus(); + } + + const RemoteCommandResponse& response = resultStatus.getValue(); + BSONObj responseObj(response.data); - return DistLockCatalog::ServerInfo(localTimeElem.date(), electionIdStatus.getValue()); + auto cmdStatus = getStatusFromCommandResult(responseObj); + + if (!cmdStatus.isOK()) { + return cmdStatus; } - StatusWith<LocksType> DistLockCatalogImpl::getLockByTS(const OID& lockSessionID) { - invariant(false); // TODO + BSONElement localTimeElem; + auto localTimeStatus = + bsonExtractTypedField(responseObj, kLocalTimeField, Date, &localTimeElem); + + if (!localTimeStatus.isOK()) { + return {ErrorCodes::UnsupportedFormat, localTimeStatus.reason()}; } - StatusWith<LocksType> DistLockCatalogImpl::getLockByName(StringData name) { - invariant(false); // TODO + auto electionIdStatus = extractElectionId(responseObj); + + if (!electionIdStatus.isOK()) { + return {ErrorCodes::UnsupportedFormat, electionIdStatus.getStatus().reason()}; } - Status DistLockCatalogImpl::stopPing(StringData processId) { - auto targetStatus = _targeter->findHost(kReadPref); + return DistLockCatalog::ServerInfo(localTimeElem.date(), electionIdStatus.getValue()); +} - if (!targetStatus.isOK()) { - return targetStatus.getStatus(); - } +StatusWith<LocksType> DistLockCatalogImpl::getLockByTS(const OID& lockSessionID) { + invariant(false); // TODO +} - auto request = FindAndModifyRequest::makeRemove(_lockPingNS, - BSON(LockpingsType::process() << processId)); - request.setWriteConcern(_writeConcern); +StatusWith<LocksType> DistLockCatalogImpl::getLockByName(StringData name) { + invariant(false); // TODO +} - auto resultStatus = _cmdRunner->runCommand( - RemoteCommandRequest(targetStatus.getValue(), - _locksNS.db().toString(), - request.toBSON())); +Status DistLockCatalogImpl::stopPing(StringData processId) { + auto targetStatus = _targeter->findHost(kReadPref); - if (!resultStatus.isOK()) { - return resultStatus.getStatus(); - } + if (!targetStatus.isOK()) { + return targetStatus.getStatus(); + } - const RemoteCommandResponse& response = resultStatus.getValue(); - BSONObj responseObj(response.data); + auto request = + FindAndModifyRequest::makeRemove(_lockPingNS, BSON(LockpingsType::process() << processId)); + request.setWriteConcern(_writeConcern); - auto findAndModifyStatus = extractFindAndModifyNewObj(responseObj); - return findAndModifyStatus.getStatus(); + auto resultStatus = _cmdRunner->runCommand( + RemoteCommandRequest(targetStatus.getValue(), _locksNS.db().toString(), request.toBSON())); + + if (!resultStatus.isOK()) { + return resultStatus.getStatus(); } -} // namespace mongo + const RemoteCommandResponse& response = resultStatus.getValue(); + BSONObj responseObj(response.data); + + auto findAndModifyStatus = extractFindAndModifyNewObj(responseObj); + return findAndModifyStatus.getStatus(); +} + +} // namespace mongo |