summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2015-08-10 17:21:52 -0400
committerBenety Goh <benety@mongodb.com>2015-08-11 10:24:50 -0400
commit0f885432ed34bbcb0a4bc425b6044f8451d6d1cf (patch)
treed034326afa8949f3ab21e6b5bcb4bfce0fbf7d52
parent67b5319f3f7c028f2a629b8aaa77b6da33707adb (diff)
downloadmongo-0f885432ed34bbcb0a4bc425b6044f8451d6d1cf.tar.gz
SERVER-19861 converted uses of std::chrono::duration::count() to mongo::durationCount()
-rw-r--r--src/mongo/client/connection_pool.cpp10
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp3
-rw-r--r--src/mongo/db/repl/bgsync.cpp6
-rw-r--r--src/mongo/db/repl/data_replicator.cpp2
-rw-r--r--src/mongo/db/repl/oplogreader.cpp4
-rw-r--r--src/mongo/db/repl/replica_set_config.cpp6
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect.cpp2
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp2
-rw-r--r--src/mongo/db/repl/sync_source_feedback.cpp3
-rw-r--r--src/mongo/db/repl/sync_tail.cpp6
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl.cpp23
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl_test.cpp46
-rw-r--r--src/mongo/db/storage/mmap_v1/data_file_sync.cpp2
-rw-r--r--src/mongo/db/write_concern.cpp4
-rw-r--r--src/mongo/dbtests/mock/mock_replica_set.cpp3
-rw-r--r--src/mongo/s/catalog/dist_lock_catalog_impl.cpp2
-rw-r--r--src/mongo/s/catalog/legacy/cluster_client_internal.cpp2
-rw-r--r--src/mongo/s/catalog/legacy/distlock.cpp7
-rw-r--r--src/mongo/s/catalog/legacy/legacy_dist_lock_manager.cpp6
-rw-r--r--src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp5
-rw-r--r--src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp14
-rw-r--r--src/mongo/s/client/shard_registry.cpp4
22 files changed, 86 insertions, 76 deletions
diff --git a/src/mongo/client/connection_pool.cpp b/src/mongo/client/connection_pool.cpp
index d9c888ef37e..df321a76b30 100644
--- a/src/mongo/client/connection_pool.cpp
+++ b/src/mongo/client/connection_pool.cpp
@@ -149,9 +149,9 @@ ConnectionPool::ConnectionList::iterator ConnectionPool::acquireConnection(
try {
if (candidate->conn->isStillConnected()) {
// setSoTimeout takes a double representing the number of seconds for send and
- // receive timeouts. Thus, we must take count() and divide by
+ // receive timeouts. Thus, we must express 'timeout' in milliseconds and divide by
// 1000.0 to get the number of seconds with a fractional part.
- candidate->conn->setSoTimeout(timeout.count() / 1000.0);
+ candidate->conn->setSoTimeout(durationCount<Milliseconds>(timeout) / 1000.0);
return candidate;
}
} catch (...) {
@@ -170,9 +170,9 @@ ConnectionPool::ConnectionList::iterator ConnectionPool::acquireConnection(
std::unique_ptr<DBClientConnection> conn(new DBClientConnection());
// setSoTimeout takes a double representing the number of seconds for send and receive
- // timeouts. Thus, we must take count() and divide by 1000.0 to get the number
- // of seconds with a fractional part.
- conn->setSoTimeout(timeout.count() / 1000.0);
+ // timeouts. Thus, we must express 'timeout' in milliseconds and divide by 1000.0 to get the
+ // number of seconds with a fractional part.
+ conn->setSoTimeout(durationCount<Milliseconds>(timeout) / 1000.0);
if (_hook) {
uassertStatusOK(
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;
}
diff --git a/src/mongo/dbtests/mock/mock_replica_set.cpp b/src/mongo/dbtests/mock/mock_replica_set.cpp
index 3c969be31f0..1df5d5b7dee 100644
--- a/src/mongo/dbtests/mock/mock_replica_set.cpp
+++ b/src/mongo/dbtests/mock/mock_replica_set.cpp
@@ -216,7 +216,8 @@ void MockReplicaSet::mockIsMasterCmd() {
}
if (member->getSlaveDelay().count()) {
- builder.appendIntOrLL("slaveDelay", member->getSlaveDelay().count());
+ builder.appendIntOrLL("slaveDelay",
+ durationCount<Seconds>(member->getSlaveDelay()));
}
if (member->isHidden()) {
diff --git a/src/mongo/s/catalog/dist_lock_catalog_impl.cpp b/src/mongo/s/catalog/dist_lock_catalog_impl.cpp
index 1b0682560d1..6f02a4aba32 100644
--- a/src/mongo/s/catalog/dist_lock_catalog_impl.cpp
+++ b/src/mongo/s/catalog/dist_lock_catalog_impl.cpp
@@ -146,7 +146,7 @@ DistLockCatalogImpl::DistLockCatalogImpl(ShardRegistry* shardRegistry,
// kMajority implies JOURNAL, if journaling is supported
// by this mongod.
WriteConcernOptions::NONE,
- writeConcernTimeout.count())),
+ durationCount<Milliseconds>(writeConcernTimeout))),
_lockPingNS(LockpingsType::ConfigNS),
_locksNS(LocksType::ConfigNS) {}
diff --git a/src/mongo/s/catalog/legacy/cluster_client_internal.cpp b/src/mongo/s/catalog/legacy/cluster_client_internal.cpp
index 5e1cdecc964..868d85a2064 100644
--- a/src/mongo/s/catalog/legacy/cluster_client_internal.cpp
+++ b/src/mongo/s/catalog/legacy/cluster_client_internal.cpp
@@ -91,7 +91,7 @@ Status checkClusterMongoVersions(CatalogManager* catalogManager, const string& m
// We assume that anything that hasn't pinged in 5 minutes is probably down
if (quietIntervalMins >= Minutes{5}) {
- log() << "stale mongos detected " << quietIntervalMins.count()
+ log() << "stale mongos detected " << durationCount<Minutes>(quietIntervalMins)
<< " minutes ago, network location is " << pingDoc["_id"].String()
<< ", not checking version";
} else {
diff --git a/src/mongo/s/catalog/legacy/distlock.cpp b/src/mongo/s/catalog/legacy/distlock.cpp
index 0db1250f004..ba8e04905cc 100644
--- a/src/mongo/s/catalog/legacy/distlock.cpp
+++ b/src/mongo/s/catalog/legacy/distlock.cpp
@@ -242,10 +242,10 @@ bool DistributedLock::checkSkew(const ConnectionString& cluster,
// Remote time can be delayed by at most MAX_NET_SKEW
// Skew is how much time we'd have to add to local to get to remote
- avgSkews[s] += (remote - local).count();
+ avgSkews[s] += durationCount<Milliseconds>(remote - local);
LOG(logLvl + 1) << "skew from remote server " << server
- << " found: " << (remote - local).count();
+ << " found: " << (remote - local);
}
}
@@ -418,7 +418,8 @@ bool DistributedLock::lock_try(const string& why, BSONObj* other, double timeout
if (lastPingEntry.configLocalTime >= remote)
elapsed = 0;
else
- elapsed = (remote - lastPingEntry.configLocalTime).count();
+ elapsed =
+ durationCount<Milliseconds>(remote - lastPingEntry.configLocalTime);
}
} catch (LockException& e) {
// Remote server cannot be found / is not responsive
diff --git a/src/mongo/s/catalog/legacy/legacy_dist_lock_manager.cpp b/src/mongo/s/catalog/legacy/legacy_dist_lock_manager.cpp
index e325d64c76c..aec1f596311 100644
--- a/src/mongo/s/catalog/legacy/legacy_dist_lock_manager.cpp
+++ b/src/mongo/s/catalog/legacy/legacy_dist_lock_manager.cpp
@@ -99,8 +99,8 @@ StatusWith<DistLockManager::ScopedDistLock> LegacyDistLockManager::lock(
bool acquired = false;
BSONObj lockDoc;
try {
- acquired =
- distLock->lock_try(whyMessage.toString(), &lockDoc, kDefaultSocketTimeout.count());
+ acquired = distLock->lock_try(
+ whyMessage.toString(), &lockDoc, durationCount<Seconds>(kDefaultSocketTimeout));
if (!acquired) {
lastStatus = Status(ErrorCodes::LockBusy,
@@ -204,7 +204,7 @@ Status LegacyDistLockManager::checkStatus(const DistLockHandle& lockHandle) {
distLock = iter->second.get();
}
- return distLock->checkStatus(kDefaultSocketTimeout.count());
+ return distLock->checkStatus(durationCount<Seconds>(kDefaultSocketTimeout));
}
void LegacyDistLockManager::enablePinger(bool enable) {
diff --git a/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp b/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp
index 134848af105..04457499b61 100644
--- a/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp
+++ b/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp
@@ -58,7 +58,7 @@ void LegacyDistLockPinger::_distLockPingThread(ConnectionString addr,
string pingId = pingThreadId(addr, process);
LOG(0) << "creating distributed lock ping thread for " << addr << " and process " << process
- << " (sleeping for " << sleepTime.count() << "ms)";
+ << " (sleeping for " << sleepTime << ")";
static int loops = 0;
Date_t lastPingTime = jsTime();
@@ -146,8 +146,7 @@ void LegacyDistLockPinger::_distLockPingThread(ConnectionString addr,
LOG(1 - (loops % 10 == 0 ? 1 : 0)) << "cluster " << addr << " pinged successfully at "
<< pingTime << " by distributed lock pinger '"
- << pingId << "', sleeping for " << sleepTime.count()
- << "ms";
+ << pingId << "', sleeping for " << sleepTime;
// Remove old locks, if possible
// Make sure no one else is adding to this list at the same time
diff --git a/src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp b/src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp
index 28ac5afa23d..9453db131fd 100644
--- a/src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp
+++ b/src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp
@@ -101,7 +101,7 @@ bool ReplSetDistLockManager::isShutDown() {
void ReplSetDistLockManager::doTask() {
LOG(0) << "creating distributed lock ping thread for process " << _processID
- << " (sleeping for " << duration_cast<milliseconds>(_pingInterval).count() << " ms)";
+ << " (sleeping for " << _pingInterval << ")";
Timer elapsedSincelastPing(_serviceContext->getTickSource());
while (!isShutDown()) {
@@ -224,15 +224,13 @@ StatusWith<bool> ReplSetDistLockManager::canOvertakeLock(LocksType lockDoc) {
milliseconds elapsedSinceLastPing(configServerLocalTime - pingInfo->configLocalTime);
if (elapsedSinceLastPing >= _lockExpiration) {
LOG(0) << "forcing lock '" << lockDoc.getName() << "' because elapsed time "
- << duration_cast<milliseconds>(elapsedSinceLastPing).count()
- << " ms >= takeover time " << duration_cast<milliseconds>(_lockExpiration).count()
- << " ms";
+ << elapsedSinceLastPing << " >= takeover time " << _lockExpiration;
return true;
}
LOG(1) << "could not force lock '" << lockDoc.getName() << "' because elapsed time "
- << duration_cast<milliseconds>(elapsedSinceLastPing).count() << " ms < takeover time "
- << duration_cast<milliseconds>(_lockExpiration).count() << " ms";
+ << durationCount<Milliseconds>(elapsedSinceLastPing) << " < takeover time "
+ << durationCount<Milliseconds>(_lockExpiration) << " ms";
return false;
}
@@ -246,8 +244,8 @@ StatusWith<DistLockManager::ScopedDistLock> ReplSetDistLockManager::lock(
string who = str::stream() << _processID << ":" << getThreadName();
LOG(1) << "trying to acquire new distributed lock for " << name
- << " ( lock timeout : " << duration_cast<milliseconds>(_lockExpiration).count()
- << " ms, ping interval : " << duration_cast<milliseconds>(_pingInterval).count()
+ << " ( lock timeout : " << durationCount<Milliseconds>(_lockExpiration)
+ << " ms, ping interval : " << durationCount<Milliseconds>(_pingInterval)
<< " ms, process : " << _processID << " )"
<< " with lockSessionID: " << lockSessionID << ", why: " << whyMessage;
diff --git a/src/mongo/s/client/shard_registry.cpp b/src/mongo/s/client/shard_registry.cpp
index 90866b677b9..6eaa45c8c50 100644
--- a/src/mongo/s/client/shard_registry.cpp
+++ b/src/mongo/s/client/shard_registry.cpp
@@ -404,7 +404,7 @@ StatusWith<ShardRegistry::CommandResponse> ShardRegistry::runCommandWithNotMaste
// If we're out of retries don't bother sleeping, just return.
return target.getStatus();
}
- sleepmillis(kNotMasterRetryInterval.count());
+ sleepmillis(durationCount<Milliseconds>(kNotMasterRetryInterval));
continue;
}
return target.getStatus();
@@ -423,7 +423,7 @@ StatusWith<ShardRegistry::CommandResponse> ShardRegistry::runCommandWithNotMaste
// If we're out of retries don't bother sleeping, just return.
return commandStatus;
}
- sleepmillis(kNotMasterRetryInterval.count());
+ sleepmillis(durationCount<Milliseconds>(kNotMasterRetryInterval));
continue;
}