summaryrefslogtreecommitdiff
path: root/src/mongo/s/catalog
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/catalog')
-rw-r--r--src/mongo/s/catalog/legacy/catalog_manager_legacy.cpp2
-rw-r--r--src/mongo/s/catalog/legacy/cluster_client_internal.cpp15
-rw-r--r--src/mongo/s/catalog/legacy/distlock.cpp13
-rw-r--r--src/mongo/s/catalog/legacy/distlock.h4
-rw-r--r--src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp10
-rw-r--r--src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.h10
-rw-r--r--src/mongo/s/catalog/type_actionlog.cpp2
-rw-r--r--src/mongo/s/catalog/type_changelog.cpp2
-rw-r--r--src/mongo/s/catalog/type_changelog_test.cpp16
-rw-r--r--src/mongo/s/catalog/type_chunk_test.cpp12
-rw-r--r--src/mongo/s/catalog/type_collection.cpp4
-rw-r--r--src/mongo/s/catalog/type_collection_test.cpp32
12 files changed, 60 insertions, 62 deletions
diff --git a/src/mongo/s/catalog/legacy/catalog_manager_legacy.cpp b/src/mongo/s/catalog/legacy/catalog_manager_legacy.cpp
index 88c1c57c21f..4037f70d43b 100644
--- a/src/mongo/s/catalog/legacy/catalog_manager_legacy.cpp
+++ b/src/mongo/s/catalog/legacy/catalog_manager_legacy.cpp
@@ -1582,7 +1582,7 @@ namespace {
lk.lock();
_consistentFromLastCheck = isConsistent;
if (_inShutdown) break;
- _consistencyCheckerCV.timed_wait(lk, Seconds(60));
+ _consistencyCheckerCV.wait_for(lk, Seconds(60));
}
LOG(1) << "Consistency checker thread shutting down";
}
diff --git a/src/mongo/s/catalog/legacy/cluster_client_internal.cpp b/src/mongo/s/catalog/legacy/cluster_client_internal.cpp
index 020ab7ec5a2..96c1e4ab998 100644
--- a/src/mongo/s/catalog/legacy/cluster_client_internal.cpp
+++ b/src/mongo/s/catalog/legacy/cluster_client_internal.cpp
@@ -91,19 +91,18 @@ namespace mongo {
Date_t lastPing = ping.getPing();
- long long quietIntervalMillis = 0;
+ Minutes quietIntervalMins{0};
Date_t currentJsTime = jsTime();
if (currentJsTime >= lastPing) {
- quietIntervalMillis = static_cast<long long>(currentJsTime - lastPing);
+ quietIntervalMins = duration_cast<Minutes>(currentJsTime - lastPing);
}
- long long quietIntervalMins = quietIntervalMillis / (60 * 1000);
// We assume that anything that hasn't pinged in 5 minutes is probably down
- if (quietIntervalMins >= 5) {
- log() << "stale mongos detected " << quietIntervalMins << " minutes ago,"
- << " network location is " << pingDoc["_id"].String()
- << ", not checking version" << endl;
- }
+ if (quietIntervalMins >= Minutes{5}) {
+ log() << "stale mongos detected " << quietIntervalMins.count()
+ << " minutes ago, network location is " << pingDoc["_id"].String()
+ << ", not checking version";
+ }
else {
if (versionCmp(mongoVersion, minMongoVersion) < 0) {
return Status(ErrorCodes::RemoteValidationError,
diff --git a/src/mongo/s/catalog/legacy/distlock.cpp b/src/mongo/s/catalog/legacy/distlock.cpp
index 01d3b9b005a..d55e7cb87b7 100644
--- a/src/mongo/s/catalog/legacy/distlock.cpp
+++ b/src/mongo/s/catalog/legacy/distlock.cpp
@@ -169,7 +169,7 @@ namespace mongo {
bool success = false;
BSONObj result;
string errMsg;
- long long delay = 0;
+ Milliseconds delay{0};
scoped_ptr<ScopedDbConnection> connPtr;
try {
@@ -204,7 +204,7 @@ namespace mongo {
// Make sure that our delay is not more than 2x our maximum network skew, since this is the max our remote
// time value can be off by if we assume a response in the middle of the delay.
- if ( delay > (long long) ( maxNetSkew * 2 ) ) {
+ if (delay > Milliseconds(maxNetSkew * 2)) {
throw TimeNotFoundException( str::stream()
<< "server " << server.toString() << " in cluster "
<< cluster.toString()
@@ -245,9 +245,10 @@ namespace mongo {
// 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] += (long long) (remote - local);
+ avgSkews[s] += (remote - local).count();
- LOG( logLvl + 1 ) << "skew from remote server " << server << " found: " << (long long) (remote - local) << endl;
+ LOG( logLvl + 1 ) << "skew from remote server " << server << " found: "
+ << (remote - local).count();
}
}
@@ -387,7 +388,7 @@ namespace mongo {
LOG( logLvl ) << "empty ping found for process in lock '" << lockName << "'" << endl;
// TODO: Using 0 as a "no time found" value Will fail if dates roll over, but then, so will a lot.
lastPing = BSON( LockpingsType::process(o[LocksType::process()].String()) <<
- LockpingsType::ping((Date_t) 0) );
+ LockpingsType::ping(Date_t()) );
}
unsigned long long elapsed = 0;
@@ -422,7 +423,7 @@ namespace mongo {
if(_lastPingCheck.remote >= remote)
elapsed = 0;
else
- elapsed = remote - _lastPingCheck.remote;
+ elapsed = (remote - _lastPingCheck.remote).count();
}
}
catch( LockException& e ) {
diff --git a/src/mongo/s/catalog/legacy/distlock.h b/src/mongo/s/catalog/legacy/distlock.h
index 98602448642..a9667307414 100644
--- a/src/mongo/s/catalog/legacy/distlock.h
+++ b/src/mongo/s/catalog/legacy/distlock.h
@@ -129,9 +129,7 @@ namespace mongo {
: id(_id), lastPing(_lastPing), remote(_remote), ts(_ts){
}
- PingData()
- : id(""), lastPing(0), remote(0), ts(){
- }
+ PingData() : id(""), ts() {}
std::string id;
Date_t lastPing;
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 d8c5f3c1fe6..a6ac69f3162 100644
--- a/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp
+++ b/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.cpp
@@ -53,7 +53,7 @@ namespace {
void LegacyDistLockPinger::_distLockPingThread(ConnectionString addr,
const string& process,
- stdx::chrono::milliseconds sleepTime) {
+ Milliseconds sleepTime) {
setThreadName("LockPinger");
string pingId = pingThreadId(addr, process);
@@ -73,11 +73,11 @@ namespace {
ScopedDbConnection conn(addr.toString(), 30.0);
pingTime = jsTime();
- Date_t elapsed(pingTime.millis - lastPingTime.millis);
- if (elapsed.millis > static_cast<unsigned long long>(10 * sleepTime.count())) {
+ const auto elapsed = pingTime - lastPingTime;
+ if (elapsed > 10 * sleepTime) {
warning() << "Lock pinger for addr: " << addr
<< ", proc: " << process
- << " was inactive for " << elapsed.millis << " ms";
+ << " was inactive for " << elapsed;
}
lastPingTime = pingTime;
@@ -133,7 +133,7 @@ namespace {
// of another pinger is too skewed). This is still fine as the lock logic only
// checks if there is a change in the ping document and the document going away
// is a valid change.
- Date_t fourDays = pingTime - (4 * 86400 * 1000); // 4 days
+ Date_t fourDays = pingTime - stdx::chrono::hours{4 * 24};
conn->remove(LockpingsType::ConfigNS,
BSON(LockpingsType::process() << NIN << pids
<< LockpingsType::ping() << LT << fourDays));
diff --git a/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.h b/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.h
index 6d0ac4ebf6f..e7dec414bb9 100644
--- a/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.h
+++ b/src/mongo/s/catalog/legacy/legacy_dist_lock_pinger.h
@@ -36,9 +36,9 @@
#include "mongo/base/status.h"
#include "mongo/client/dbclientinterface.h"
#include "mongo/s/catalog/dist_lock_manager.h"
-#include "mongo/stdx/chrono.h"
#include "mongo/stdx/memory.h"
#include "mongo/util/concurrency/mutex.h"
+#include "mongo/util/time_support.h"
namespace mongo {
@@ -51,7 +51,7 @@ namespace mongo {
/**
* Starts pinging the process id for the given lock.
*/
- Status startPing(const DistributedLock& lock, stdx::chrono::milliseconds sleepTime);
+ Status startPing(const DistributedLock& lock, Milliseconds sleepTime);
/**
* Adds a distributed lock that has the given id to the unlock list. The unlock list
@@ -82,7 +82,7 @@ namespace mongo {
void distLockPingThread(ConnectionString addr,
long long clockSkew,
const std::string& processId,
- stdx::chrono::milliseconds sleepTime);
+ Milliseconds sleepTime);
/**
* Function for repeatedly pinging the process id. Also attempts to unlock all the
@@ -90,7 +90,7 @@ namespace mongo {
*/
void _distLockPingThread(ConnectionString addr,
const std::string& process,
- stdx::chrono::milliseconds sleepTime);
+ Milliseconds sleepTime);
/**
* Returns true if a request has been made to stop pinging the give process id.
@@ -105,7 +105,7 @@ namespace mongo {
/**
* Blocks until duration has elapsed or if the ping thread is interrupted.
*/
- void waitTillNextPingTime(stdx::chrono::milliseconds duration);
+ void waitTillNextPingTime(Milliseconds duration);
//
// All member variables are labeled with one of the following codes indicating the
diff --git a/src/mongo/s/catalog/type_actionlog.cpp b/src/mongo/s/catalog/type_actionlog.cpp
index 8d208778e0f..49dd09b6958 100644
--- a/src/mongo/s/catalog/type_actionlog.cpp
+++ b/src/mongo/s/catalog/type_actionlog.cpp
@@ -123,7 +123,7 @@ namespace mongo {
_what.clear();
_isWhatSet = false;
- _time = 0ULL;
+ _time = Date_t();
_isTimeSet = false;
_details = BSONObj();
diff --git a/src/mongo/s/catalog/type_changelog.cpp b/src/mongo/s/catalog/type_changelog.cpp
index f73b90f72c0..40db60dbf94 100644
--- a/src/mongo/s/catalog/type_changelog.cpp
+++ b/src/mongo/s/catalog/type_changelog.cpp
@@ -158,7 +158,7 @@ namespace mongo {
_clientAddr.clear();
_isClientAddrSet = false;
- _time = 0ULL;
+ _time = Date_t();
_isTimeSet = false;
_what.clear();
diff --git a/src/mongo/s/catalog/type_changelog_test.cpp b/src/mongo/s/catalog/type_changelog_test.cpp
index 5777a3b7e37..0844b231497 100644
--- a/src/mongo/s/catalog/type_changelog_test.cpp
+++ b/src/mongo/s/catalog/type_changelog_test.cpp
@@ -53,7 +53,7 @@ namespace {
BSONObj obj = BSON(ChangelogType::changeID("host.local-2012-11-21T19:14:10-8") <<
ChangelogType::server("host.local") <<
ChangelogType::clientAddr("192.168.0.189:51128") <<
- ChangelogType::time(1ULL) <<
+ ChangelogType::time(Date_t::fromMillisSinceEpoch(1)) <<
ChangelogType::what("split") <<
ChangelogType::ns("test.test") <<
ChangelogType::details(BSON("dummy" << "info")));
@@ -64,7 +64,7 @@ namespace {
ASSERT_EQUALS(logEntry.getChangeID(), "host.local-2012-11-21T19:14:10-8");
ASSERT_EQUALS(logEntry.getServer(), "host.local");
ASSERT_EQUALS(logEntry.getClientAddr(), "192.168.0.189:51128");
- ASSERT_EQUALS(logEntry.getTime(), 1ULL);
+ ASSERT_EQUALS(logEntry.getTime(), Date_t::fromMillisSinceEpoch(1));
ASSERT_EQUALS(logEntry.getWhat(), "split");
ASSERT_EQUALS(logEntry.getNS(), "test.test");
ASSERT_EQUALS(logEntry.getDetails(), BSON("dummy" << "info"));
@@ -74,7 +74,7 @@ namespace {
ChangelogType logEntry;
BSONObj obj = BSON(ChangelogType::server("host.local") <<
ChangelogType::clientAddr("192.168.0.189:51128") <<
- ChangelogType::time(1ULL) <<
+ ChangelogType::time(Date_t::fromMillisSinceEpoch(1)) <<
ChangelogType::what("split") <<
ChangelogType::ns("test.test") <<
ChangelogType::details(BSON("dummy" << "info")));
@@ -88,7 +88,7 @@ namespace {
ChangelogType logEntry;
BSONObj obj = BSON(ChangelogType::changeID("host.local-2012-11-21T19:14:10-8") <<
ChangelogType::clientAddr("192.168.0.189:51128") <<
- ChangelogType::time(1ULL) <<
+ ChangelogType::time(Date_t::fromMillisSinceEpoch(1)) <<
ChangelogType::what("split") <<
ChangelogType::ns("test.test") <<
ChangelogType::details(BSON("dummy" << "info")));
@@ -102,7 +102,7 @@ namespace {
ChangelogType logEntry;
BSONObj obj = BSON(ChangelogType::changeID("host.local-2012-11-21T19:14:10-8") <<
ChangelogType::server("host.local") <<
- ChangelogType::time(1ULL) <<
+ ChangelogType::time(Date_t::fromMillisSinceEpoch(1)) <<
ChangelogType::what("split") <<
ChangelogType::ns("test.test") <<
ChangelogType::details(BSON("dummy" << "info")));
@@ -131,7 +131,7 @@ namespace {
BSONObj obj = BSON(ChangelogType::changeID("host.local-2012-11-21T19:14:10-8") <<
ChangelogType::server("host.local") <<
ChangelogType::clientAddr("192.168.0.189:51128") <<
- ChangelogType::time(1ULL) <<
+ ChangelogType::time(Date_t::fromMillisSinceEpoch(1)) <<
ChangelogType::ns("test.test") <<
ChangelogType::details(BSON("dummy" << "info")));
string errMsg;
@@ -145,7 +145,7 @@ namespace {
BSONObj obj = BSON(ChangelogType::changeID("host.local-2012-11-21T19:14:10-8") <<
ChangelogType::server("host.local") <<
ChangelogType::clientAddr("192.168.0.189:51128") <<
- ChangelogType::time(1ULL) <<
+ ChangelogType::time(Date_t::fromMillisSinceEpoch(1)) <<
ChangelogType::what("split") <<
ChangelogType::details(BSON("dummy" << "info")));
string errMsg;
@@ -159,7 +159,7 @@ namespace {
BSONObj obj = BSON(ChangelogType::changeID("host.local-2012-11-21T19:14:10-8") <<
ChangelogType::server("host.local") <<
ChangelogType::clientAddr("192.168.0.189:51128") <<
- ChangelogType::time(1ULL) <<
+ ChangelogType::time(Date_t::fromMillisSinceEpoch(1)) <<
ChangelogType::what("split") <<
ChangelogType::ns("test.test"));
string errMsg;
diff --git a/src/mongo/s/catalog/type_chunk_test.cpp b/src/mongo/s/catalog/type_chunk_test.cpp
index db86f9fe809..35d9f578d5f 100644
--- a/src/mongo/s/catalog/type_chunk_test.cpp
+++ b/src/mongo/s/catalog/type_chunk_test.cpp
@@ -43,7 +43,7 @@ namespace {
TEST(ChunkType, MissingRequiredFields) {
ChunkType chunk;
- BSONArray version = BSON_ARRAY(Date_t(1) << OID::gen());
+ BSONArray version = BSON_ARRAY(Date_t::fromMillisSinceEpoch(1) << OID::gen());
BSONObj objModNS = BSON(ChunkType::name("test.mycol-a_MinKey") <<
ChunkType::min(BSON("a" << 10 << "b" << 10)) <<
@@ -78,7 +78,7 @@ namespace {
}
TEST(ChunkType, DifferentNumberOfColumns) {
- BSONArray version = BSON_ARRAY(Date_t(1) << OID::gen());
+ BSONArray version = BSON_ARRAY(Date_t::fromMillisSinceEpoch(1) << OID::gen());
BSONObj obj = BSON(ChunkType::name("test.mycol-a_MinKey") <<
ChunkType::ns("test.mycol") <<
ChunkType::min(BSON("a" << 10 << "b" << 10)) <<
@@ -91,7 +91,7 @@ namespace {
}
TEST(ChunkType, DifferentColumns) {
- BSONArray version = BSON_ARRAY(Date_t(1) << OID::gen());
+ BSONArray version = BSON_ARRAY(Date_t::fromMillisSinceEpoch(1) << OID::gen());
BSONObj obj = BSON(ChunkType::name("test.mycol-a_MinKey") <<
ChunkType::ns("test.mycol") <<
ChunkType::min(BSON("a" << 10)) <<
@@ -104,7 +104,7 @@ namespace {
}
TEST(ChunkType, NotAscending) {
- BSONArray version = BSON_ARRAY(Date_t(1) << OID::gen());
+ BSONArray version = BSON_ARRAY(Date_t::fromMillisSinceEpoch(1) << OID::gen());
BSONObj obj = BSON(ChunkType::name("test.mycol-a_MinKey") <<
ChunkType::ns("test.mycol") <<
ChunkType::min(BSON("a" << 20)) <<
@@ -119,7 +119,7 @@ namespace {
TEST(ChunkType, NewFormatVersion) {
ChunkType chunk;
OID epoch = OID::gen();
- BSONArray version = BSON_ARRAY(Date_t(1) << epoch);
+ BSONArray version = BSON_ARRAY(Date_t::fromMillisSinceEpoch(1) << epoch);
BSONObj obj = BSON(ChunkType::name("test.mycol-a_MinKey") <<
ChunkType::ns("test.mycol") <<
ChunkType::min(BSON("a" << 10)) <<
@@ -148,7 +148,7 @@ namespace {
ChunkType::ns("test.mycol") <<
ChunkType::min(BSON("a" << 10)) <<
ChunkType::max(BSON("a" << 20)) <<
- ChunkType::DEPRECATED_lastmod(Date_t(1)) <<
+ ChunkType::DEPRECATED_lastmod(Date_t::fromMillisSinceEpoch(1)) <<
ChunkType::DEPRECATED_epoch(epoch) <<
ChunkType::shard("shard0001"));
StatusWith<ChunkType> chunkRes = ChunkType::fromBSON(obj);
diff --git a/src/mongo/s/catalog/type_collection.cpp b/src/mongo/s/catalog/type_collection.cpp
index 05f7aa1d808..fb121942615 100644
--- a/src/mongo/s/catalog/type_collection.cpp
+++ b/src/mongo/s/catalog/type_collection.cpp
@@ -161,7 +161,7 @@ namespace mongo {
return Status(ErrorCodes::BadValue, "invalid epoch");
}
- if (!_updatedAt.get()) {
+ if (Date_t() == _updatedAt.get()) {
return Status(ErrorCodes::BadValue, "invalid updated at timestamp");
}
@@ -183,7 +183,7 @@ namespace mongo {
builder.append(fullNs.name(), _fullNs->toString());
}
builder.append(epoch.name(), _epoch.get_value_or(OID()));
- builder.append(updatedAt.name(), _updatedAt.get_value_or(0));
+ builder.append(updatedAt.name(), _updatedAt.get_value_or(Date_t()));
// These fields are optional, so do not include them in the metadata for the purposes of
// consuming less space on the config servers.
diff --git a/src/mongo/s/catalog/type_collection_test.cpp b/src/mongo/s/catalog/type_collection_test.cpp
index 1b6f113570a..3d538b51a2f 100644
--- a/src/mongo/s/catalog/type_collection_test.cpp
+++ b/src/mongo/s/catalog/type_collection_test.cpp
@@ -47,18 +47,18 @@ namespace {
TEST(CollectionType, Basic) {
const OID oid = OID::gen();
StatusWith<CollectionType> status = CollectionType::fromBSON(
- BSON(CollectionType::fullNs("db.coll") <<
- CollectionType::epoch(oid) <<
- CollectionType::updatedAt(1ULL) <<
- CollectionType::keyPattern(BSON("a" << 1)) <<
- CollectionType::unique(true)));
+ BSON(CollectionType::fullNs("db.coll") <<
+ CollectionType::epoch(oid) <<
+ CollectionType::updatedAt(Date_t::fromMillisSinceEpoch(1)) <<
+ CollectionType::keyPattern(BSON("a" << 1)) <<
+ CollectionType::unique(true)));
ASSERT_TRUE(status.isOK());
CollectionType coll = status.getValue();
ASSERT_TRUE(coll.validate().isOK());
ASSERT(coll.getNs() == NamespaceString{"db.coll"});
ASSERT_EQUALS(coll.getEpoch(), oid);
- ASSERT_EQUALS(coll.getUpdatedAt(), 1ULL);
+ ASSERT_EQUALS(coll.getUpdatedAt(), Date_t::fromMillisSinceEpoch(1));
ASSERT_EQUALS(coll.getKeyPattern(), BSON("a" << 1));
ASSERT_EQUALS(coll.getUnique(), true);
ASSERT_EQUALS(coll.getAllowBalance(), true);
@@ -68,11 +68,11 @@ namespace {
TEST(CollectionType, InvalidCollectionNamespace) {
const OID oid = OID::gen();
StatusWith<CollectionType> result = CollectionType::fromBSON(
- BSON(CollectionType::fullNs("foo\\bar.coll") <<
- CollectionType::epoch(oid) <<
- CollectionType::updatedAt(1ULL) <<
- CollectionType::keyPattern(BSON("a" << 1)) <<
- CollectionType::unique(true)));
+ BSON(CollectionType::fullNs("foo\\bar.coll") <<
+ CollectionType::epoch(oid) <<
+ CollectionType::updatedAt(Date_t::fromMillisSinceEpoch(1)) <<
+ CollectionType::keyPattern(BSON("a" << 1)) <<
+ CollectionType::unique(true)));
ASSERT_TRUE(result.isOK());
CollectionType collType = result.getValue();
ASSERT_FALSE(collType.validate().isOK());
@@ -81,11 +81,11 @@ namespace {
TEST(CollectionType, BadType) {
const OID oid = OID::gen();
StatusWith<CollectionType> status = CollectionType::fromBSON(
- BSON(CollectionType::fullNs() << 1 <<
- CollectionType::epoch(oid) <<
- CollectionType::updatedAt(1ULL) <<
- CollectionType::keyPattern(BSON("a" << 1)) <<
- CollectionType::unique(true)));
+ BSON(CollectionType::fullNs() << 1 <<
+ CollectionType::epoch(oid) <<
+ CollectionType::updatedAt(Date_t::fromMillisSinceEpoch(1)) <<
+ CollectionType::keyPattern(BSON("a" << 1)) <<
+ CollectionType::unique(true)));
ASSERT_FALSE(status.isOK());
}