diff options
author | Benety Goh <benety@mongodb.com> | 2015-08-10 17:21:52 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2015-08-11 10:24:50 -0400 |
commit | 0f885432ed34bbcb0a4bc425b6044f8451d6d1cf (patch) | |
tree | d034326afa8949f3ab21e6b5bcb4bfce0fbf7d52 /src/mongo/db | |
parent | 67b5319f3f7c028f2a629b8aaa77b6da33707adb (diff) | |
download | mongo-0f885432ed34bbcb0a4bc425b6044f8451d6d1cf.tar.gz |
SERVER-19861 converted uses of std::chrono::duration::count() to mongo::durationCount()
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/commands/getmore_cmd.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/repl/bgsync.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/repl/data_replicator.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/oplogreader.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/replica_set_config.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl_elect.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/rs_rollback.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/sync_source_feedback.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/repl/sync_tail.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/repl/topology_coordinator_impl.cpp | 23 | ||||
-rw-r--r-- | src/mongo/db/repl/topology_coordinator_impl_test.cpp | 46 | ||||
-rw-r--r-- | src/mongo/db/storage/mmap_v1/data_file_sync.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/write_concern.cpp | 4 |
13 files changed, 60 insertions, 49 deletions
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp index 987c5fb536d..ded3f47c186 100644 --- a/src/mongo/db/commands/getmore_cmd.cpp +++ b/src/mongo/db/commands/getmore_cmd.cpp @@ -251,8 +251,7 @@ public: // applying it to this getMore. if (isCursorAwaitData(cursor)) { Seconds awaitDataTimeout(1); - CurOp::get(txn) - ->setMaxTimeMicros(duration_cast<Microseconds>(awaitDataTimeout).count()); + CurOp::get(txn)->setMaxTimeMicros(durationCount<Microseconds>(awaitDataTimeout)); } else { CurOp::get(txn)->setMaxTimeMicros(cursor->getLeftoverMaxTimeMicros()); } diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp index cdabe17c6bf..cd82cdf5059 100644 --- a/src/mongo/db/repl/bgsync.cpp +++ b/src/mongo/db/repl/bgsync.cpp @@ -331,7 +331,7 @@ void BackgroundSync::_produce(OperationContext* txn, executor::TaskExecutor* tas auto cmdObj = BSON("find" << nsToCollectionSubstring(rsOplogName) << "filter" << BSON("ts" << BSON("$gte" << lastOpTimeFetched.getTimestamp())) << "tailable" << true << "oplogReplay" << true << "awaitData" << true - << "maxTimeMS" << int(fetcherMaxTimeMS.count())); + << "maxTimeMS" << durationCount<Milliseconds>(fetcherMaxTimeMS)); Fetcher fetcher(taskExecutor, source, nsToDatabase(rsOplogName), @@ -467,7 +467,7 @@ void BackgroundSync::_fetcherCallback(const StatusWith<Fetcher::QueryResponse>& } // record time for each batch - getmoreReplStats.recordMillis(queryResponse.elapsedMillis.count()); + getmoreReplStats.recordMillis(durationCount<Milliseconds>(queryResponse.elapsedMillis)); networkByteStats.increment(currentBatchMessageSize); @@ -506,7 +506,7 @@ void BackgroundSync::_fetcherCallback(const StatusWith<Fetcher::QueryResponse>& invariant(bob); bob->append("getMore", queryResponse.cursorId); bob->append("collection", queryResponse.nss.coll()); - bob->append("maxTimeMS", int(fetcherMaxTimeMS.count())); + bob->append("maxTimeMS", durationCount<Milliseconds>(fetcherMaxTimeMS)); } bool BackgroundSync::_shouldChangeSyncSource(const HostAndPort& syncSource) { diff --git a/src/mongo/db/repl/data_replicator.cpp b/src/mongo/db/repl/data_replicator.cpp index 24031a04f79..459bcdeaeaa 100644 --- a/src/mongo/db/repl/data_replicator.cpp +++ b/src/mongo/db/repl/data_replicator.cpp @@ -788,7 +788,7 @@ TimestampStatus DataReplicator::initialSync() { // Sleep for retry time lk.unlock(); - sleepmillis(_opts.initialSyncRetryWait.count()); + sleepmillis(durationCount<Milliseconds>(_opts.initialSyncRetryWait)); lk.lock(); // No need to print a stack diff --git a/src/mongo/db/repl/oplogreader.cpp b/src/mongo/db/repl/oplogreader.cpp index f7c417abada..06f2da78101 100644 --- a/src/mongo/db/repl/oplogreader.cpp +++ b/src/mongo/db/repl/oplogreader.cpp @@ -91,8 +91,8 @@ OplogReader::OplogReader() { bool OplogReader::connect(const HostAndPort& host) { if (conn() == NULL || _host != host) { resetConnection(); - _conn = - shared_ptr<DBClientConnection>(new DBClientConnection(false, kSocketTimeout.count())); + _conn = shared_ptr<DBClientConnection>( + new DBClientConnection(false, durationCount<Seconds>(kSocketTimeout))); string errmsg; if (!_conn->connect(host, errmsg) || (getGlobalAuthorizationManager()->isAuthEnabled() && !replAuthenticate(_conn.get()))) { diff --git a/src/mongo/db/repl/replica_set_config.cpp b/src/mongo/db/repl/replica_set_config.cpp index 2038e9abe7f..41e21756e0c 100644 --- a/src/mongo/db/repl/replica_set_config.cpp +++ b/src/mongo/db/repl/replica_set_config.cpp @@ -279,7 +279,8 @@ Status ReplicaSetConfig::validate() const { return Status(ErrorCodes::BadValue, str::stream() << kSettingsFieldName << '.' << kHeartbeatTimeoutFieldName << " field value must be non-negative, " - "but found " << _heartbeatTimeoutPeriod.count()); + "but found " + << durationCount<Seconds>(_heartbeatTimeoutPeriod)); } if (_members.size() > kMaxMembers || _members.empty()) { return Status(ErrorCodes::BadValue, @@ -547,7 +548,8 @@ BSONObj ReplicaSetConfig::toBSON() const { BSONObjBuilder settingsBuilder(configBuilder.subobjStart(kSettingsFieldName)); settingsBuilder.append(kChainingAllowedFieldName, _chainingAllowed); - settingsBuilder.appendIntOrLL(kHeartbeatTimeoutFieldName, _heartbeatTimeoutPeriod.count()); + settingsBuilder.appendIntOrLL(kHeartbeatTimeoutFieldName, + durationCount<Seconds>(_heartbeatTimeoutPeriod)); BSONObjBuilder gleModes(settingsBuilder.subobjStart(kGetLastErrorModesFieldName)); for (StringMap<ReplicaSetTagPattern>::const_iterator mode = _customWriteConcernModes.begin(); diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect.cpp index d298decf65f..4d07c52a89f 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_elect.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_elect.cpp @@ -176,7 +176,7 @@ void ReplicationCoordinatorImpl::_onFreshnessCheckComplete() { if ((_selfIndex != 0) && !_sleptLastElection) { const auto ms = Milliseconds(_replExecutor.nextRandomInt64(1000) + 50); const Date_t nextCandidateTime = now + ms; - log() << "possible election tie; sleeping " << ms.count() << "ms until " + log() << "possible election tie; sleeping " << ms << " until " << dateToISOStringLocal(nextCandidateTime); _topCoord->setElectionSleepUntil(nextCandidateTime); _replExecutor.scheduleWorkAt( diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index ce48224e1f6..e776e0f9d41 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -817,7 +817,7 @@ Status syncRollback(OperationContext* txn, localOplog, rollbackSource, replCoord, - [](Seconds seconds) { sleepsecs(seconds.count()); }); + [](Seconds seconds) { sleepsecs(durationCount<Seconds>(seconds)); }); } } // namespace repl diff --git a/src/mongo/db/repl/sync_source_feedback.cpp b/src/mongo/db/repl/sync_source_feedback.cpp index 75b729c85ad..b8e137810c0 100644 --- a/src/mongo/db/repl/sync_source_feedback.cpp +++ b/src/mongo/db/repl/sync_source_feedback.cpp @@ -79,7 +79,8 @@ bool SyncSourceFeedback::_connect(OperationContext* txn, const HostAndPort& host return true; } log() << "setting syncSourceFeedback to " << host.toString(); - _connection.reset(new DBClientConnection(false, OplogReader::kSocketTimeout.count())); + _connection.reset( + new DBClientConnection(false, durationCount<Seconds>(OplogReader::kSocketTimeout))); string errmsg; try { if (!_connection->connect(host, errmsg) || diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp index 59ef1b01ddb..65edf1cf5c6 100644 --- a/src/mongo/db/repl/sync_tail.cpp +++ b/src/mongo/db/repl/sync_tail.cpp @@ -551,7 +551,7 @@ void SyncTail::oplogApplication() { tryToGoLiveAsASecondary(&txn, replCoord); } - const int slaveDelaySecs = replCoord->getSlaveDelaySecs().count(); + const int slaveDelaySecs = durationCount<Seconds>(replCoord->getSlaveDelaySecs()); if (!ops.empty() && slaveDelaySecs > 0) { const BSONObj lastOp = ops.back(); const unsigned int opTimestampSecs = lastOp["ts"].timestamp().getSecs(); @@ -680,7 +680,7 @@ bool SyncTail::tryPopAndWaitForMore(OperationContext* txn, void SyncTail::handleSlaveDelay(const BSONObj& lastOp) { ReplicationCoordinator* replCoord = getGlobalReplicationCoordinator(); - int slaveDelaySecs = replCoord->getSlaveDelaySecs().count(); + int slaveDelaySecs = durationCount<Seconds>(replCoord->getSlaveDelaySecs()); // ignore slaveDelay if the box is still initializing. once // it becomes secondary we can worry about it. @@ -704,7 +704,7 @@ void SyncTail::handleSlaveDelay(const BSONObj& lastOp) { sleepsecs(6); // Handle reconfigs that changed the slave delay - if (replCoord->getSlaveDelaySecs().count() != slaveDelaySecs) + if (durationCount<Seconds>(replCoord->getSlaveDelaySecs()) != slaveDelaySecs) break; } } diff --git a/src/mongo/db/repl/topology_coordinator_impl.cpp b/src/mongo/db/repl/topology_coordinator_impl.cpp index 5ce753e8ea9..805d664ba86 100644 --- a/src/mongo/db/repl/topology_coordinator_impl.cpp +++ b/src/mongo/db/repl/topology_coordinator_impl.cpp @@ -216,7 +216,8 @@ HostAndPort TopologyCoordinatorImpl::chooseNewSyncSource(Date_t now, // Check if primaryOpTime is still close to 0 because we haven't received // our first heartbeat from a new primary yet. - unsigned int maxLag = static_cast<unsigned int>(_options.maxSyncSourceLagSecs.count()); + unsigned int maxLag = + static_cast<unsigned int>(durationCount<Seconds>(_options.maxSyncSourceLagSecs)); if (primaryOpTime.getSecs() >= maxLag) { oldestSyncOpTime = OpTime(Timestamp(primaryOpTime.getSecs() - maxLag, 0), primaryOpTime.getTerm()); @@ -865,11 +866,11 @@ std::pair<ReplSetHeartbeatArgsV1, Milliseconds> TopologyCoordinatorImpl::prepare } hbArgs.setTerm(_term); - const Milliseconds timeoutPeriod( - _rsConfig.isInitialized() - ? _rsConfig.getHeartbeatTimeoutPeriodMillis() - : Milliseconds(ReplicaSetConfig::kDefaultHeartbeatTimeoutPeriod.count())); - const Milliseconds timeout(timeoutPeriod.count() - alreadyElapsed.count()); + const Milliseconds timeoutPeriod(_rsConfig.isInitialized() + ? _rsConfig.getHeartbeatTimeoutPeriodMillis() + : Milliseconds(durationCount<Seconds>( + ReplicaSetConfig::kDefaultHeartbeatTimeoutPeriod))); + const Milliseconds timeout(timeoutPeriod - alreadyElapsed); return std::make_pair(hbArgs, timeout); } @@ -885,7 +886,7 @@ HeartbeatResponseAction TopologyCoordinatorImpl::processHeartbeatResponse( if (!hbResponse.isOK()) { hbStats.miss(); } else { - hbStats.hit(networkRoundTripTime.count()); + hbStats.hit(durationCount<Milliseconds>(networkRoundTripTime)); // Log diagnostics. if (hbResponse.getValue().isStateDisagreement()) { LOG(1) << target << " thinks that we are down because they cannot send us heartbeats."; @@ -970,7 +971,7 @@ HeartbeatResponseAction TopologyCoordinatorImpl::processHeartbeatResponse( } else { LOG(3) << "Bad heartbeat response from " << target << "; trying again; Retries left: " << (kMaxHeartbeatRetries - hbStats.getNumFailuresSinceLastStart()) << "; " - << alreadyElapsed.count() << "ms have already elapsed"; + << alreadyElapsed << " have already elapsed"; } } else { ReplSetHeartbeatResponse hbr = hbResponse.getValue(); @@ -1566,7 +1567,7 @@ void TopologyCoordinatorImpl::fillIsMasterForReplSet(IsMasterResponse* response) } else if (selfConfig.getPriority() == 0) { response->setIsPassive(true); } - if (selfConfig.getSlaveDelay().count()) { + if (selfConfig.getSlaveDelay() > Seconds(0)) { response->setSlaveDelay(selfConfig.getSlaveDelay()); } if (selfConfig.isHidden()) { @@ -2137,7 +2138,7 @@ bool TopologyCoordinatorImpl::shouldChangeSyncSource(const HostAndPort& currentS return false; } unsigned int currentSecs = currentOpTime.getSecs(); - unsigned int goalSecs = currentSecs + _options.maxSyncSourceLagSecs.count(); + unsigned int goalSecs = currentSecs + durationCount<Seconds>(_options.maxSyncSourceLagSecs); for (std::vector<MemberHeartbeatData>::const_iterator it = _hbdata.begin(); it != _hbdata.end(); ++it) { @@ -2149,7 +2150,7 @@ bool TopologyCoordinatorImpl::shouldChangeSyncSource(const HostAndPort& currentS goalSecs < it->getOpTime().getSecs()) { log() << "changing sync target because current sync target's most recent OpTime is " << currentOpTime.toString() << " which is more than " - << _options.maxSyncSourceLagSecs.count() << " seconds behind member " + << _options.maxSyncSourceLagSecs << " behind member " << candidateConfig.getHostAndPort().toString() << " whose most recent OpTime is " << it->getOpTime().toString(); invariant(itIndex != _selfIndex); diff --git a/src/mongo/db/repl/topology_coordinator_impl_test.cpp b/src/mongo/db/repl/topology_coordinator_impl_test.cpp index f438b352476..1beecb903da 100644 --- a/src/mongo/db/repl/topology_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/topology_coordinator_impl_test.cpp @@ -1051,8 +1051,12 @@ TEST_F(TopoCoordTest, ReplSetGetStatus) { // Now node 0 is down, node 1 is up, and for node 2 we have no heartbeat data yet. BSONObjBuilder statusBuilder; Status resultStatus(ErrorCodes::InternalError, "prepareStatusResponse didn't set result"); - getTopoCoord().prepareStatusResponse( - cbData(), curTime, uptimeSecs.count(), oplogProgress, &statusBuilder, &resultStatus); + getTopoCoord().prepareStatusResponse(cbData(), + curTime, + durationCount<Seconds>(uptimeSecs), + oplogProgress, + &statusBuilder, + &resultStatus); ASSERT_OK(resultStatus); BSONObj rsStatus = statusBuilder.obj(); @@ -1086,7 +1090,7 @@ TEST_F(TopoCoordTest, ReplSetGetStatus) { ASSERT_EQUALS(MemberState::RS_SECONDARY, member1Status["state"].numberInt()); ASSERT_EQUALS(MemberState(MemberState::RS_SECONDARY).toString(), member1Status["stateStr"].String()); - ASSERT_EQUALS(uptimeSecs.count(), member1Status["uptime"].numberInt()); + ASSERT_EQUALS(durationCount<Seconds>(uptimeSecs), member1Status["uptime"].numberInt()); ASSERT_EQUALS(oplogProgress.getTimestamp(), Timestamp(member1Status["optime"].timestampValue())); ASSERT_TRUE(member1Status.hasField("optimeDate")); @@ -1117,7 +1121,7 @@ TEST_F(TopoCoordTest, ReplSetGetStatus) { ASSERT_EQUALS(1, selfStatus["health"].numberDouble()); ASSERT_EQUALS(MemberState::RS_PRIMARY, selfStatus["state"].numberInt()); ASSERT_EQUALS(MemberState(MemberState::RS_PRIMARY).toString(), selfStatus["stateStr"].str()); - ASSERT_EQUALS(uptimeSecs.count(), selfStatus["uptime"].numberInt()); + ASSERT_EQUALS(durationCount<Seconds>(uptimeSecs), selfStatus["uptime"].numberInt()); ASSERT_EQUALS(oplogProgress.getTimestamp(), Timestamp(selfStatus["optime"].timestampValue())); ASSERT_TRUE(selfStatus.hasField("optimeDate")); ASSERT_EQUALS(Date_t::fromMillisSinceEpoch(oplogProgress.getSecs() * 1000ULL), @@ -1148,8 +1152,12 @@ TEST_F(TopoCoordTest, ReplSetGetStatusFails) { BSONObjBuilder statusBuilder; Status resultStatus(ErrorCodes::InternalError, "prepareStatusResponse didn't set result"); - getTopoCoord().prepareStatusResponse( - cbData(), curTime, uptimeSecs.count(), oplogProgress, &statusBuilder, &resultStatus); + getTopoCoord().prepareStatusResponse(cbData(), + curTime, + durationCount<Seconds>(uptimeSecs), + oplogProgress, + &statusBuilder, + &resultStatus); ASSERT_NOT_OK(resultStatus); ASSERT_EQUALS(ErrorCodes::InvalidReplicaSetConfig, resultStatus); } @@ -1458,7 +1466,7 @@ public: std::pair<ReplSetHeartbeatArgs, Milliseconds> request = getTopoCoord().prepareHeartbeatRequest(_firstRequestDate, "rs0", _target); // 5 seconds to successfully complete the heartbeat before the timeout expires. - ASSERT_EQUALS(5000, request.second.count()); + ASSERT_EQUALS(5000, durationCount<Milliseconds>(request.second)); // Initial heartbeat request fails at t + 4000ms HeartbeatResponseAction action = getTopoCoord().processHeartbeatResponse( @@ -1477,7 +1485,7 @@ public: request = getTopoCoord().prepareHeartbeatRequest( _firstRequestDate + Milliseconds(4000), "rs0", _target); // One second left to complete the heartbeat. - ASSERT_EQUALS(1000, request.second.count()); + ASSERT_EQUALS(1000, durationCount<Milliseconds>(request.second)); // Ensure a single failed heartbeat did not cause the node to be marked down BSONObjBuilder statusBuilder; @@ -1532,7 +1540,7 @@ public: getTopoCoord().prepareHeartbeatRequest( firstRequestDate() + Milliseconds(4500), "rs0", target()); // 500ms left to complete the heartbeat. - ASSERT_EQUALS(500, request.second.count()); + ASSERT_EQUALS(500, durationCount<Milliseconds>(request.second)); // Ensure a second failed heartbeat did not cause the node to be marked down BSONObjBuilder statusBuilder; @@ -1973,7 +1981,7 @@ TEST_F(HeartbeatResponseTest, HeartbeatTimeoutSuppressesFirstRetry) { std::pair<ReplSetHeartbeatArgs, Milliseconds> request = getTopoCoord().prepareHeartbeatRequest(firstRequestDate, "rs0", target); // 5 seconds to successfully complete the heartbeat before the timeout expires. - ASSERT_EQUALS(5000, request.second.count()); + ASSERT_EQUALS(5000, durationCount<Milliseconds>(request.second)); // Initial heartbeat request fails at t + 5000ms HeartbeatResponseAction action = getTopoCoord().processHeartbeatResponse( @@ -3796,7 +3804,7 @@ TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseSenderIDMissing) { ASSERT_TRUE(response.isReplSet()); ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s); ASSERT_EQUALS(OpTime(), response.getOpTime()); - ASSERT_EQUALS(0, response.getTime().count()); + ASSERT_EQUALS(0, durationCount<Seconds>(response.getTime())); ASSERT_EQUALS("", response.getHbMsg()); ASSERT_EQUALS("rs0", response.getReplicaSetName()); ASSERT_EQUALS(1, response.getConfigVersion()); @@ -3819,7 +3827,7 @@ TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseSenderIDNotInConfig ASSERT_TRUE(response.isReplSet()); ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s); ASSERT_EQUALS(OpTime(), response.getOpTime()); - ASSERT_EQUALS(0, response.getTime().count()); + ASSERT_EQUALS(0, durationCount<Seconds>(response.getTime())); ASSERT_EQUALS("", response.getHbMsg()); ASSERT_EQUALS("rs0", response.getReplicaSetName()); ASSERT_EQUALS(1, response.getConfigVersion()); @@ -3843,7 +3851,7 @@ TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseConfigVersionLow) { ASSERT_TRUE(response.isReplSet()); ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s); ASSERT_EQUALS(OpTime(), response.getOpTime()); - ASSERT_EQUALS(0, response.getTime().count()); + ASSERT_EQUALS(0, durationCount<Seconds>(response.getTime())); ASSERT_EQUALS("", response.getHbMsg()); ASSERT_EQUALS("rs0", response.getReplicaSetName()); ASSERT_EQUALS(1, response.getConfigVersion()); @@ -3867,7 +3875,7 @@ TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseConfigVersionHigh) ASSERT_TRUE(response.isReplSet()); ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s); ASSERT_EQUALS(OpTime(), response.getOpTime()); - ASSERT_EQUALS(0, response.getTime().count()); + ASSERT_EQUALS(0, durationCount<Seconds>(response.getTime())); ASSERT_EQUALS("", response.getHbMsg()); ASSERT_EQUALS("rs0", response.getReplicaSetName()); ASSERT_EQUALS(1, response.getConfigVersion()); @@ -3890,7 +3898,7 @@ TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseSenderDown) { ASSERT_TRUE(response.isReplSet()); ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s); ASSERT_EQUALS(OpTime(), response.getOpTime()); - ASSERT_EQUALS(0, response.getTime().count()); + ASSERT_EQUALS(0, durationCount<Seconds>(response.getTime())); ASSERT_EQUALS("", response.getHbMsg()); ASSERT_EQUALS("rs0", response.getReplicaSetName()); ASSERT_EQUALS(1, response.getConfigVersion()); @@ -3916,7 +3924,7 @@ TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseSenderUp) { ASSERT_TRUE(response.isReplSet()); ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s); ASSERT_EQUALS(OpTime(Timestamp(100, 0), 0), response.getOpTime()); - ASSERT_EQUALS(0, response.getTime().count()); + ASSERT_EQUALS(0, durationCount<Seconds>(response.getTime())); ASSERT_EQUALS("", response.getHbMsg()); ASSERT_EQUALS("rs0", response.getReplicaSetName()); ASSERT_EQUALS(1, response.getConfigVersion()); @@ -3939,7 +3947,7 @@ TEST_F(TopoCoordTest, PrepareHeartbeatResponseNoConfigYet) { ASSERT_TRUE(response.isReplSet()); ASSERT_EQUALS(MemberState::RS_STARTUP, response.getState().s); ASSERT_EQUALS(OpTime(), response.getOpTime()); - ASSERT_EQUALS(0, response.getTime().count()); + ASSERT_EQUALS(0, durationCount<Seconds>(response.getTime())); ASSERT_EQUALS("", response.getHbMsg()); ASSERT_EQUALS("rs0", response.getReplicaSetName()); ASSERT_EQUALS(-2, response.getConfigVersion()); @@ -3966,7 +3974,7 @@ TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseAsPrimary) { ASSERT_EQUALS(MemberState::RS_PRIMARY, response.getState().s); ASSERT_EQUALS(OpTime(Timestamp(11, 0), 0), response.getOpTime()); ASSERT_EQUALS(Timestamp(10, 0), response.getElectionTime()); - ASSERT_EQUALS(0, response.getTime().count()); + ASSERT_EQUALS(0, durationCount<Seconds>(response.getTime())); ASSERT_EQUALS("", response.getHbMsg()); ASSERT_EQUALS("rs0", response.getReplicaSetName()); ASSERT_EQUALS(1, response.getConfigVersion()); @@ -3998,7 +4006,7 @@ TEST_F(PrepareHeartbeatResponseTest, PrepareHeartbeatResponseWithSyncSource) { ASSERT_TRUE(response.isReplSet()); ASSERT_EQUALS(MemberState::RS_SECONDARY, response.getState().s); ASSERT_EQUALS(OpTime(Timestamp(100, 0), 0), response.getOpTime()); - ASSERT_EQUALS(0, response.getTime().count()); + ASSERT_EQUALS(0, durationCount<Seconds>(response.getTime())); // changed to a syncing message because our sync source changed recently ASSERT_EQUALS("syncing from: h2:27017", response.getHbMsg()); ASSERT_EQUALS("rs0", response.getReplicaSetName()); diff --git a/src/mongo/db/storage/mmap_v1/data_file_sync.cpp b/src/mongo/db/storage/mmap_v1/data_file_sync.cpp index 013877cb08b..52d5953f673 100644 --- a/src/mongo/db/storage/mmap_v1/data_file_sync.cpp +++ b/src/mongo/db/storage/mmap_v1/data_file_sync.cpp @@ -82,7 +82,7 @@ void DataFileSync::run() { Date_t start = jsTime(); StorageEngine* storageEngine = getGlobalServiceContext()->getGlobalStorageEngine(); int numFiles = storageEngine->flushAllFiles(true); - time_flushing = (jsTime() - start).count(); + time_flushing = durationCount<Milliseconds>(jsTime() - start); _flushed(time_flushing); diff --git a/src/mongo/db/write_concern.cpp b/src/mongo/db/write_concern.cpp index 7ced5c064cf..6455834fffd 100644 --- a/src/mongo/db/write_concern.cpp +++ b/src/mongo/db/write_concern.cpp @@ -256,8 +256,8 @@ Status waitForWriteConcern(OperationContext* txn, } // Add stats result->writtenTo = repl::getGlobalReplicationCoordinator()->getHostsWrittenTo(replOpTime); - gleWtimeStats.recordMillis(replStatus.duration.count()); - result->wTime = replStatus.duration.count(); + gleWtimeStats.recordMillis(durationCount<Milliseconds>(replStatus.duration)); + result->wTime = durationCount<Milliseconds>(replStatus.duration); return replStatus.status; } |