diff options
Diffstat (limited to 'src/mongo/s/catalog')
19 files changed, 121 insertions, 153 deletions
diff --git a/src/mongo/s/catalog/catalog_manager.h b/src/mongo/s/catalog/catalog_manager.h index f3fe5ca2f21..72cfdc51b8a 100644 --- a/src/mongo/s/catalog/catalog_manager.h +++ b/src/mongo/s/catalog/catalog_manager.h @@ -446,7 +446,7 @@ public: OperationContext* txn, StringData name, StringData whyMessage, - stdx::chrono::milliseconds waitFor = DistLockManager::kSingleLockAttemptTimeout) = 0; + Milliseconds waitFor = DistLockManager::kSingleLockAttemptTimeout) = 0; protected: CatalogManager() = default; diff --git a/src/mongo/s/catalog/catalog_manager_mock.cpp b/src/mongo/s/catalog/catalog_manager_mock.cpp index 49f5e3213cb..5e09bc1a7b7 100644 --- a/src/mongo/s/catalog/catalog_manager_mock.cpp +++ b/src/mongo/s/catalog/catalog_manager_mock.cpp @@ -144,11 +144,10 @@ StatusWith<repl::OpTimeWith<std::vector<ShardType>>> CatalogManagerMock::getAllS return {ErrorCodes::InternalError, "Method not implemented"}; } -StatusWith<DistLockManager::ScopedDistLock> CatalogManagerMock::distLock( - OperationContext* txn, - StringData name, - StringData whyMessage, - stdx::chrono::milliseconds waitFor) { +StatusWith<DistLockManager::ScopedDistLock> CatalogManagerMock::distLock(OperationContext* txn, + StringData name, + StringData whyMessage, + Milliseconds waitFor) { return {ErrorCodes::InternalError, "Method not implemented"}; } diff --git a/src/mongo/s/catalog/catalog_manager_mock.h b/src/mongo/s/catalog/catalog_manager_mock.h index 48a5ba066d8..51a43f7a1b5 100644 --- a/src/mongo/s/catalog/catalog_manager_mock.h +++ b/src/mongo/s/catalog/catalog_manager_mock.h @@ -156,11 +156,10 @@ public: DistLockManager* getDistLockManager() override; - StatusWith<DistLockManager::ScopedDistLock> distLock( - OperationContext* txn, - StringData name, - StringData whyMessage, - stdx::chrono::milliseconds waitFor) override; + StatusWith<DistLockManager::ScopedDistLock> distLock(OperationContext* txn, + StringData name, + StringData whyMessage, + Milliseconds waitFor) override; Status initConfigVersion(OperationContext* txn) override; diff --git a/src/mongo/s/catalog/dist_lock_manager.cpp b/src/mongo/s/catalog/dist_lock_manager.cpp index 7c59ea07f0c..732e2fc664a 100644 --- a/src/mongo/s/catalog/dist_lock_manager.cpp +++ b/src/mongo/s/catalog/dist_lock_manager.cpp @@ -36,9 +36,9 @@ namespace mongo { -const stdx::chrono::seconds DistLockManager::kDefaultLockTimeout(20); -const stdx::chrono::milliseconds DistLockManager::kSingleLockAttemptTimeout(0); -const stdx::chrono::milliseconds DistLockManager::kDefaultLockRetryInterval(500); +const Seconds DistLockManager::kDefaultLockTimeout(20); +const Milliseconds DistLockManager::kSingleLockAttemptTimeout(0); +const Milliseconds DistLockManager::kDefaultLockRetryInterval(500); DistLockManager::ScopedDistLock::ScopedDistLock(OperationContext* txn, DistLockHandle lockHandle, diff --git a/src/mongo/s/catalog/dist_lock_manager.h b/src/mongo/s/catalog/dist_lock_manager.h index 3b60c4a09bd..f97b186e2de 100644 --- a/src/mongo/s/catalog/dist_lock_manager.h +++ b/src/mongo/s/catalog/dist_lock_manager.h @@ -62,15 +62,15 @@ class StatusWith; class DistLockManager { public: // Default timeout which will be used if one is not passed to the lock method. - static const stdx::chrono::seconds kDefaultLockTimeout; + static const Seconds kDefaultLockTimeout; // Timeout value, which specifies that if the lock is not available immediately, no attempt // should be made to wait for it to become free. - static const stdx::chrono::milliseconds kSingleLockAttemptTimeout; + static const Milliseconds kSingleLockAttemptTimeout; // If timeout is passed to the lock call, what is the default frequency with which the lock will // be checked for availability. - static const stdx::chrono::milliseconds kDefaultLockRetryInterval; + static const Milliseconds kDefaultLockRetryInterval; /** * RAII type for distributed lock. Not meant to be shared across multiple threads. @@ -134,8 +134,8 @@ public: OperationContext* txn, StringData name, StringData whyMessage, - stdx::chrono::milliseconds waitFor = kDefaultLockTimeout, - stdx::chrono::milliseconds lockTryInterval = kDefaultLockRetryInterval) = 0; + Milliseconds waitFor = kDefaultLockTimeout, + Milliseconds lockTryInterval = kDefaultLockRetryInterval) = 0; /** * Same behavior as lock(...) above, except takes a specific lock session ID "lockSessionID" @@ -150,8 +150,8 @@ public: StringData name, StringData whyMessage, const OID lockSessionID, - stdx::chrono::milliseconds waitFor = kDefaultLockTimeout, - stdx::chrono::milliseconds lockTryInterval = kDefaultLockRetryInterval) = 0; + Milliseconds waitFor = kDefaultLockTimeout, + Milliseconds lockTryInterval = kDefaultLockRetryInterval) = 0; /** * Makes a best-effort attempt to unlock all locks owned by the given processID. diff --git a/src/mongo/s/catalog/dist_lock_manager_mock.cpp b/src/mongo/s/catalog/dist_lock_manager_mock.cpp index 28ac22cb411..7c2c58e83ed 100644 --- a/src/mongo/s/catalog/dist_lock_manager_mock.cpp +++ b/src/mongo/s/catalog/dist_lock_manager_mock.cpp @@ -35,18 +35,17 @@ #include <algorithm> #include "mongo/util/mongoutils/str.h" +#include "mongo/util/time_support.h" #include "mongo/unittest/unittest.h" namespace mongo { -using stdx::chrono::milliseconds; - namespace { void NoLockFuncSet(StringData name, StringData whyMessage, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { FAIL(str::stream() << "Lock not expected to be called. " << "Name: " << name << ", whyMessage: " << whyMessage << ", waitFor: " << waitFor << ", lockTryInterval: " << lockTryInterval); @@ -71,8 +70,8 @@ StatusWith<DistLockManager::ScopedDistLock> DistLockManagerMock::lock( OperationContext* txn, StringData name, StringData whyMessage, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { return lockWithSessionID( txn, name, whyMessage, DistLockHandle::gen(), waitFor, lockTryInterval); } @@ -82,8 +81,8 @@ StatusWith<DistLockManager::ScopedDistLock> DistLockManagerMock::lockWithSession StringData name, StringData whyMessage, const OID lockSessionID, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { _lockChecker(name, whyMessage, waitFor, lockTryInterval); _lockChecker = NoLockFuncSet; diff --git a/src/mongo/s/catalog/dist_lock_manager_mock.h b/src/mongo/s/catalog/dist_lock_manager_mock.h index 21ddef99f93..5d32acda6b3 100644 --- a/src/mongo/s/catalog/dist_lock_manager_mock.h +++ b/src/mongo/s/catalog/dist_lock_manager_mock.h @@ -47,27 +47,26 @@ public: virtual std::string getProcessID() override; - virtual StatusWith<DistLockManager::ScopedDistLock> lock( - OperationContext* txn, - StringData name, - StringData whyMessage, - stdx::chrono::milliseconds waitFor, - stdx::chrono::milliseconds lockTryInterval) override; + virtual StatusWith<DistLockManager::ScopedDistLock> lock(OperationContext* txn, + StringData name, + StringData whyMessage, + Milliseconds waitFor, + Milliseconds lockTryInterval) override; virtual StatusWith<DistLockManager::ScopedDistLock> lockWithSessionID( OperationContext* txn, StringData name, StringData whyMessage, const OID lockSessionID, - stdx::chrono::milliseconds waitFor, - stdx::chrono::milliseconds lockTryInterval) override; + Milliseconds waitFor, + Milliseconds lockTryInterval) override; virtual void unlockAll(OperationContext* txn, const std::string& processID) override; using LockFunc = stdx::function<void(StringData name, StringData whyMessage, - stdx::chrono::milliseconds waitFor, - stdx::chrono::milliseconds lockTryInterval)>; + Milliseconds waitFor, + Milliseconds lockTryInterval)>; void expectLock(LockFunc checkerFunc, Status lockStatus); diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set.cpp index 73d85a7e5db..9025a22b001 100644 --- a/src/mongo/s/catalog/replset/catalog_manager_replica_set.cpp +++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set.cpp @@ -760,10 +760,7 @@ Status CatalogManagerReplicaSet::_log(OperationContext* txn, } StatusWith<DistLockManager::ScopedDistLock> CatalogManagerReplicaSet::distLock( - OperationContext* txn, - StringData name, - StringData whyMessage, - stdx::chrono::milliseconds waitFor) { + OperationContext* txn, StringData name, StringData whyMessage, Milliseconds waitFor) { return getDistLockManager()->lock(txn, name, whyMessage, waitFor); } @@ -1114,10 +1111,10 @@ Status CatalogManagerReplicaSet::dropCollection(OperationContext* txn, const Nam LOG(1) << "dropCollection " << ns << " started"; // Lock the collection globally so that split/migrate cannot run - stdx::chrono::seconds waitFor(DistLockManager::kDefaultLockTimeout); + Seconds waitFor(DistLockManager::kDefaultLockTimeout); MONGO_FAIL_POINT_BLOCK(setDropCollDistLockWait, customWait) { const BSONObj& data = customWait.getData(); - waitFor = stdx::chrono::seconds(data["waitForSecs"].numberInt()); + waitFor = Seconds(data["waitForSecs"].numberInt()); } auto scopedDistLock = getDistLockManager()->lock(txn, ns.ns(), "drop", waitFor); diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set.h b/src/mongo/s/catalog/replset/catalog_manager_replica_set.h index a3cbf6f9227..b7251dc2a37 100644 --- a/src/mongo/s/catalog/replset/catalog_manager_replica_set.h +++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set.h @@ -88,11 +88,10 @@ public: const std::string& ns, const BSONObj& detail) override; - StatusWith<DistLockManager::ScopedDistLock> distLock( - OperationContext* txn, - StringData name, - StringData whyMessage, - stdx::chrono::milliseconds waitFor) override; + StatusWith<DistLockManager::ScopedDistLock> distLock(OperationContext* txn, + StringData name, + StringData whyMessage, + Milliseconds waitFor) override; Status shardCollection(OperationContext* txn, const std::string& ns, diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_append_db_stats_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_append_db_stats_test.cpp index bf1b8e9d5a7..6542a14a5e6 100644 --- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_append_db_stats_test.cpp +++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_append_db_stats_test.cpp @@ -39,6 +39,7 @@ #include "mongo/s/catalog/replset/catalog_manager_replica_set_test_fixture.h" #include "mongo/stdx/future.h" #include "mongo/util/log.h" +#include "mongo/util/time_support.h" namespace mongo { namespace { @@ -46,7 +47,6 @@ namespace { using executor::NetworkInterfaceMock; using executor::RemoteCommandRequest; using executor::RemoteCommandResponse; -using stdx::chrono::milliseconds; using CatalogManagerReplSetAppendDbStatsTest = CatalogManagerReplSetTestFixture; diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_drop_coll_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_drop_coll_test.cpp index abdb370f180..51bf688cf74 100644 --- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_drop_coll_test.cpp +++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_drop_coll_test.cpp @@ -44,7 +44,7 @@ #include "mongo/s/chunk_version.h" #include "mongo/s/client/shard_registry.h" #include "mongo/s/write_ops/batched_update_request.h" -#include "mongo/stdx/chrono.h" +#include "mongo/util/time_support.h" namespace mongo { namespace { @@ -53,7 +53,6 @@ using executor::RemoteCommandRequest; using executor::RemoteCommandResponse; using std::string; using std::vector; -using stdx::chrono::milliseconds; using unittest::assertGet; class DropColl2ShardTest : public CatalogManagerReplSetTestFixture { @@ -65,7 +64,7 @@ public: configTargeter()->setFindHostReturnValue(_configHost); distLock()->expectLock( - [this](StringData name, StringData whyMessage, milliseconds, milliseconds) { + [this](StringData name, StringData whyMessage, Milliseconds, Milliseconds) { ASSERT_EQUALS(_dropNS.ns(), name); ASSERT_EQUALS("drop", whyMessage); }, @@ -263,7 +262,7 @@ TEST_F(DropColl2ShardTest, ConfigTargeterError) { } TEST_F(DropColl2ShardTest, DistLockBusy) { - distLock()->expectLock([](StringData, StringData, milliseconds, milliseconds) {}, + distLock()->expectLock([](StringData, StringData, Milliseconds, Milliseconds) {}, {ErrorCodes::LockBusy, "test lock taken"}); auto future = launchAsync([this] { diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_log_change_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_log_change_test.cpp index ee82dce9bd8..ed2a1b7e868 100644 --- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_log_change_test.cpp +++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_log_change_test.cpp @@ -55,7 +55,7 @@ using executor::TaskExecutor; using stdx::async; using unittest::assertGet; -const stdx::chrono::seconds kFutureTimeout{5}; +const Seconds kFutureTimeout{5}; const HostAndPort configHost{"TestHost1"}; class InfoLoggingTest : public CatalogManagerReplSetTestFixture { diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp index eed5dfb3c98..c359b3f2874 100644 --- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp +++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_remove_shard_test.cpp @@ -62,7 +62,7 @@ using std::string; using std::vector; using unittest::assertGet; -static const stdx::chrono::seconds kFutureTimeout{5}; +static const Seconds kFutureTimeout{5}; const BSONObj kReplSecondaryOkMetadata{[] { BSONObjBuilder o; diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_shard_collection_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_shard_collection_test.cpp index 8fc2cf1f984..46a8d19ece5 100644 --- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_shard_collection_test.cpp +++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_shard_collection_test.cpp @@ -56,9 +56,9 @@ #include "mongo/s/shard_key_pattern.h" #include "mongo/s/write_ops/batched_command_request.h" #include "mongo/s/write_ops/batched_command_response.h" -#include "mongo/stdx/chrono.h" #include "mongo/stdx/future.h" #include "mongo/util/log.h" +#include "mongo/util/time_support.h" namespace mongo { namespace { @@ -70,7 +70,6 @@ using executor::TaskExecutor; using std::set; using std::string; using std::vector; -using stdx::chrono::milliseconds; using unittest::assertGet; const BSONObj kReplMetadata(); @@ -225,8 +224,8 @@ TEST_F(ShardCollectionTest, distLockFails) { distLock()->expectLock( [](StringData name, StringData whyMessage, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { ASSERT_EQUALS("test.foo", name); ASSERT_EQUALS("shardCollection", whyMessage); }, @@ -258,8 +257,8 @@ TEST_F(ShardCollectionTest, anotherMongosSharding) { distLock()->expectLock( [&](StringData name, StringData whyMessage, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { ASSERT_EQUALS(ns, name); ASSERT_EQUALS("shardCollection", whyMessage); }, @@ -317,8 +316,8 @@ TEST_F(ShardCollectionTest, noInitialChunksOrData) { distLock()->expectLock( [&](StringData name, StringData whyMessage, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { ASSERT_EQUALS(ns, name); ASSERT_EQUALS("shardCollection", whyMessage); }, @@ -487,8 +486,8 @@ TEST_F(ShardCollectionTest, withInitialChunks) { distLock()->expectLock( [&](StringData name, StringData whyMessage, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { ASSERT_EQUALS(ns, name); ASSERT_EQUALS("shardCollection", whyMessage); }, @@ -642,8 +641,8 @@ TEST_F(ShardCollectionTest, withInitialData) { distLock()->expectLock( [&](StringData name, StringData whyMessage, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { ASSERT_EQUALS(ns, name); ASSERT_EQUALS("shardCollection", whyMessage); }, diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp index 8f36b7908e5..8ed21d44952 100644 --- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp +++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_test.cpp @@ -55,9 +55,9 @@ #include "mongo/s/write_ops/batched_command_response.h" #include "mongo/s/write_ops/batched_insert_request.h" #include "mongo/s/write_ops/batched_update_request.h" -#include "mongo/stdx/chrono.h" #include "mongo/stdx/future.h" #include "mongo/util/log.h" +#include "mongo/util/time_support.h" namespace mongo { namespace { @@ -70,7 +70,6 @@ using rpc::ReplSetMetadata; using repl::OpTime; using std::string; using std::vector; -using stdx::chrono::milliseconds; using unittest::assertGet; using CatalogManagerReplSetTest = CatalogManagerReplSetTestFixture; @@ -706,8 +705,8 @@ TEST_F(CatalogManagerReplSetTest, RunUserManagementWriteCommandRewriteWriteConce distLock()->expectLock( [](StringData name, StringData whyMessage, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { ASSERT_EQUALS("authorizationData", name); ASSERT_EQUALS("dropUser", whyMessage); }, @@ -1540,8 +1539,8 @@ TEST_F(CatalogManagerReplSetTest, createDatabaseSuccess) { distLock()->expectLock([dbname](StringData name, StringData whyMessage, - stdx::chrono::milliseconds waitFor, - stdx::chrono::milliseconds lockTryInterval) {}, + Milliseconds waitFor, + Milliseconds lockTryInterval) {}, Status::OK()); @@ -1639,8 +1638,8 @@ TEST_F(CatalogManagerReplSetTest, createDatabaseDistLockHeld) { distLock()->expectLock( [dbname](StringData name, StringData whyMessage, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { ASSERT_EQUALS(dbname, name); ASSERT_EQUALS("createDatabase", whyMessage); }, @@ -1658,8 +1657,8 @@ TEST_F(CatalogManagerReplSetTest, createDatabaseDBExists) { distLock()->expectLock([dbname](StringData name, StringData whyMessage, - stdx::chrono::milliseconds waitFor, - stdx::chrono::milliseconds lockTryInterval) {}, + Milliseconds waitFor, + Milliseconds lockTryInterval) {}, Status::OK()); @@ -1697,8 +1696,8 @@ TEST_F(CatalogManagerReplSetTest, createDatabaseDBExistsDifferentCase) { distLock()->expectLock([dbname](StringData name, StringData whyMessage, - stdx::chrono::milliseconds waitFor, - stdx::chrono::milliseconds lockTryInterval) {}, + Milliseconds waitFor, + Milliseconds lockTryInterval) {}, Status::OK()); @@ -1735,8 +1734,8 @@ TEST_F(CatalogManagerReplSetTest, createDatabaseNoShards) { distLock()->expectLock([dbname](StringData name, StringData whyMessage, - stdx::chrono::milliseconds waitFor, - stdx::chrono::milliseconds lockTryInterval) {}, + Milliseconds waitFor, + Milliseconds lockTryInterval) {}, Status::OK()); @@ -1827,8 +1826,8 @@ TEST_F(CatalogManagerReplSetTest, createDatabaseDuplicateKeyOnInsert) { distLock()->expectLock([dbname](StringData name, StringData whyMessage, - stdx::chrono::milliseconds waitFor, - stdx::chrono::milliseconds lockTryInterval) {}, + Milliseconds waitFor, + Milliseconds lockTryInterval) {}, Status::OK()); @@ -1934,15 +1933,10 @@ TEST_F(CatalogManagerReplSetTest, EnableShardingNoDBExists) { shardRegistry()->getShard(operationContext(), "shard0")->getTargeter()); shardTargeter->setFindHostReturnValue(HostAndPort("shard0:12")); - distLock()->expectLock( - [](StringData name, - StringData whyMessage, - stdx::chrono::milliseconds, - stdx::chrono::milliseconds) { - ASSERT_EQ("test", name); - ASSERT_FALSE(whyMessage.empty()); - }, - Status::OK()); + distLock()->expectLock([](StringData name, StringData whyMessage, Milliseconds, Milliseconds) { + ASSERT_EQ("test", name); + ASSERT_FALSE(whyMessage.empty()); + }, Status::OK()); auto future = launchAsync([this] { auto status = catalogManager()->enableSharding(operationContext(), "test"); @@ -2022,9 +2016,8 @@ TEST_F(CatalogManagerReplSetTest, EnableShardingNoDBExists) { TEST_F(CatalogManagerReplSetTest, EnableShardingLockBusy) { configTargeter()->setFindHostReturnValue(HostAndPort("config:123")); - distLock()->expectLock( - [](StringData, StringData, stdx::chrono::milliseconds, stdx::chrono::milliseconds) {}, - {ErrorCodes::LockBusy, "lock taken"}); + distLock()->expectLock([](StringData, StringData, Milliseconds, Milliseconds) {}, + {ErrorCodes::LockBusy, "lock taken"}); auto status = catalogManager()->enableSharding(operationContext(), "test"); ASSERT_EQ(ErrorCodes::LockBusy, status.code()); @@ -2040,9 +2033,7 @@ TEST_F(CatalogManagerReplSetTest, EnableShardingDBExistsWithDifferentCase) { setupShards(vector<ShardType>{shard}); - distLock()->expectLock( - [](StringData, StringData, stdx::chrono::milliseconds, stdx::chrono::milliseconds) {}, - Status::OK()); + distLock()->expectLock([](StringData, StringData, Milliseconds, Milliseconds) {}, Status::OK()); auto future = launchAsync([this] { auto status = catalogManager()->enableSharding(operationContext(), "test"); @@ -2069,9 +2060,7 @@ TEST_F(CatalogManagerReplSetTest, EnableShardingDBExists) { setupShards(vector<ShardType>{shard}); - distLock()->expectLock( - [](StringData, StringData, stdx::chrono::milliseconds, stdx::chrono::milliseconds) {}, - Status::OK()); + distLock()->expectLock([](StringData, StringData, Milliseconds, Milliseconds) {}, Status::OK()); auto future = launchAsync([this] { auto status = catalogManager()->enableSharding(operationContext(), "test"); @@ -2127,9 +2116,7 @@ TEST_F(CatalogManagerReplSetTest, EnableShardingFailsWhenTheDatabaseIsAlreadySha setupShards(vector<ShardType>{shard}); - distLock()->expectLock( - [](StringData, StringData, stdx::chrono::milliseconds, stdx::chrono::milliseconds) {}, - Status::OK()); + distLock()->expectLock([](StringData, StringData, Milliseconds, Milliseconds) {}, Status::OK()); auto future = launchAsync([this] { auto status = catalogManager()->enableSharding(operationContext(), "test"); @@ -2155,9 +2142,7 @@ TEST_F(CatalogManagerReplSetTest, EnableShardingDBExistsInvalidFormat) { setupShards(vector<ShardType>{shard}); - distLock()->expectLock( - [](StringData, StringData, stdx::chrono::milliseconds, stdx::chrono::milliseconds) {}, - Status::OK()); + distLock()->expectLock([](StringData, StringData, Milliseconds, Milliseconds) {}, Status::OK()); auto future = launchAsync([this] { auto status = catalogManager()->enableSharding(operationContext(), "test"); @@ -2177,9 +2162,7 @@ TEST_F(CatalogManagerReplSetTest, EnableShardingDBExistsInvalidFormat) { TEST_F(CatalogManagerReplSetTest, EnableShardingNoDBExistsNoShards) { configTargeter()->setFindHostReturnValue(HostAndPort("config:123")); - distLock()->expectLock( - [](StringData, StringData, stdx::chrono::milliseconds, stdx::chrono::milliseconds) {}, - Status::OK()); + distLock()->expectLock([](StringData, StringData, Milliseconds, Milliseconds) {}, Status::OK()); auto future = launchAsync([this] { auto status = catalogManager()->enableSharding(operationContext(), "test"); diff --git a/src/mongo/s/catalog/replset/catalog_manager_replica_set_write_retry_test.cpp b/src/mongo/s/catalog/replset/catalog_manager_replica_set_write_retry_test.cpp index bccc5e3cce5..27554868a9b 100644 --- a/src/mongo/s/catalog/replset/catalog_manager_replica_set_write_retry_test.cpp +++ b/src/mongo/s/catalog/replset/catalog_manager_replica_set_write_retry_test.cpp @@ -54,7 +54,6 @@ #include "mongo/s/grid.h" #include "mongo/s/write_ops/batched_command_request.h" #include "mongo/s/write_ops/batched_command_response.h" -#include "mongo/stdx/chrono.h" #include "mongo/stdx/future.h" #include "mongo/stdx/memory.h" #include "mongo/util/log.h" @@ -69,7 +68,6 @@ using executor::TaskExecutor; using std::set; using std::string; using std::vector; -using stdx::chrono::milliseconds; using unittest::assertGet; using InsertRetryTest = CatalogManagerReplSetTestFixture; diff --git a/src/mongo/s/catalog/replset/dist_lock_catalog_impl_test.cpp b/src/mongo/s/catalog/replset/dist_lock_catalog_impl_test.cpp index 3bae6ce8a09..35c9be42c9b 100644 --- a/src/mongo/s/catalog/replset/dist_lock_catalog_impl_test.cpp +++ b/src/mongo/s/catalog/replset/dist_lock_catalog_impl_test.cpp @@ -74,7 +74,7 @@ using repl::ReadConcernArgs; namespace { const HostAndPort dummyHost("dummy", 123); -static const stdx::chrono::seconds kFutureTimeout{5}; +static const Seconds kFutureTimeout{5}; /** * Sets up the mocked out objects for testing the replica-set backed catalog manager. 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 31fb999cdbf..a7b693fe5c4 100644 --- a/src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp +++ b/src/mongo/s/catalog/replset/replset_dist_lock_manager.cpp @@ -48,6 +48,7 @@ #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" #include "mongo/util/timer.h" +#include "mongo/util/time_support.h" namespace mongo { @@ -55,8 +56,6 @@ MONGO_FP_DECLARE(setDistLockTimeout); using std::string; using std::unique_ptr; -using stdx::chrono::milliseconds; -using stdx::chrono::duration_cast; namespace { @@ -71,8 +70,8 @@ const Minutes ReplSetDistLockManager::kDistLockExpirationTime{15}; ReplSetDistLockManager::ReplSetDistLockManager(ServiceContext* globalContext, StringData processID, unique_ptr<DistLockCatalog> catalog, - milliseconds pingInterval, - milliseconds lockExpiration) + Milliseconds pingInterval, + Milliseconds lockExpiration) : _serviceContext(globalContext), _processID(processID.toString()), _catalog(std::move(catalog)), @@ -133,7 +132,7 @@ void ReplSetDistLockManager::doTask() { warning() << "pinging failed for distributed lock pinger" << causedBy(pingStatus); } - const milliseconds elapsed(elapsedSincelastPing.millis()); + const Milliseconds elapsed(elapsedSincelastPing.millis()); if (elapsed > 10 * _pingInterval) { warning() << "Lock pinger for proc: " << _processID << " was inactive for " << elapsed << " ms"; @@ -171,7 +170,7 @@ void ReplSetDistLockManager::doTask() { StatusWith<bool> ReplSetDistLockManager::isLockExpired(OperationContext* txn, LocksType lockDoc, - const milliseconds& lockExpiration) { + const Milliseconds& lockExpiration) { const auto& processID = lockDoc.getProcess(); auto pingStatus = _catalog->getPing(txn, processID); @@ -199,7 +198,7 @@ StatusWith<bool> ReplSetDistLockManager::isLockExpired(OperationContext* txn, // Be conservative when determining that lock expiration has elapsed by // taking into account the roundtrip delay of trying to get the local // time from the config server. - milliseconds delay(timer.millis() / 2); // Assuming symmetrical delay. + Milliseconds delay(timer.millis() / 2); // Assuming symmetrical delay. const auto& serverInfo = serverInfoStatus.getValue(); @@ -249,7 +248,7 @@ StatusWith<bool> ReplSetDistLockManager::isLockExpired(OperationContext* txn, return false; } - milliseconds elapsedSinceLastPing(configServerLocalTime - pingInfo->configLocalTime); + Milliseconds elapsedSinceLastPing(configServerLocalTime - pingInfo->configLocalTime); if (elapsedSinceLastPing >= lockExpiration) { LOG(0) << "forcing lock '" << lockDoc.getName() << "' because elapsed time " << elapsedSinceLastPing << " >= takeover time " << lockExpiration; @@ -266,8 +265,8 @@ StatusWith<DistLockManager::ScopedDistLock> ReplSetDistLockManager::lock( OperationContext* txn, StringData name, StringData whyMessage, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { return lockWithSessionID(txn, name, whyMessage, OID::gen(), waitFor, lockTryInterval); } @@ -276,8 +275,8 @@ StatusWith<DistLockManager::ScopedDistLock> ReplSetDistLockManager::lockWithSess StringData name, StringData whyMessage, const OID lockSessionID, - milliseconds waitFor, - milliseconds lockTryInterval) { + Milliseconds waitFor, + Milliseconds lockTryInterval) { Timer timer(_serviceContext->getTickSource()); Timer msgTimer(_serviceContext->getTickSource()); @@ -291,13 +290,13 @@ StatusWith<DistLockManager::ScopedDistLock> ReplSetDistLockManager::lockWithSess // the lock is currently taken, we will back off and try the acquisition again, repeating this // until the lockTryInterval has been reached. If a network error occurs at each lock // acquisition attempt, the lock acquisition will be retried immediately. - while (waitFor <= milliseconds::zero() || milliseconds(timer.millis()) < waitFor) { + while (waitFor <= Milliseconds::zero() || Milliseconds(timer.millis()) < waitFor) { const string who = str::stream() << _processID << ":" << getThreadName(); auto lockExpiration = _lockExpiration; MONGO_FAIL_POINT_BLOCK(setDistLockTimeout, customTimeout) { const BSONObj& data = customTimeout.getData(); - lockExpiration = stdx::chrono::milliseconds(data["timeoutMs"].numberInt()); + lockExpiration = Milliseconds(data["timeoutMs"].numberInt()); } LOG(1) << "trying to acquire new distributed lock for " << name @@ -399,7 +398,7 @@ StatusWith<DistLockManager::ScopedDistLock> ReplSetDistLockManager::lockWithSess LOG(1) << "distributed lock '" << name << "' was not acquired."; - if (waitFor == milliseconds::zero()) { + if (waitFor == Milliseconds::zero()) { break; } @@ -415,8 +414,8 @@ StatusWith<DistLockManager::ScopedDistLock> ReplSetDistLockManager::lockWithSess // busy, so reset the retries counter) networkErrorRetries = 0; - const milliseconds timeRemaining = - std::max(milliseconds::zero(), waitFor - milliseconds(timer.millis())); + const Milliseconds timeRemaining = + std::max(Milliseconds::zero(), waitFor - Milliseconds(timer.millis())); sleepFor(std::min(lockTryInterval, timeRemaining)); } diff --git a/src/mongo/s/catalog/replset/replset_dist_lock_manager.h b/src/mongo/s/catalog/replset/replset_dist_lock_manager.h index 2f876f8e693..635b2ab343d 100644 --- a/src/mongo/s/catalog/replset/replset_dist_lock_manager.h +++ b/src/mongo/s/catalog/replset/replset_dist_lock_manager.h @@ -58,8 +58,8 @@ public: ReplSetDistLockManager(ServiceContext* globalContext, StringData processID, std::unique_ptr<DistLockCatalog> catalog, - stdx::chrono::milliseconds pingInterval, - stdx::chrono::milliseconds lockExpiration); + Milliseconds pingInterval, + Milliseconds lockExpiration); virtual ~ReplSetDistLockManager(); @@ -68,20 +68,18 @@ public: virtual std::string getProcessID() override; - virtual StatusWith<DistLockManager::ScopedDistLock> lock( - OperationContext* txn, - StringData name, - StringData whyMessage, - stdx::chrono::milliseconds waitFor, - stdx::chrono::milliseconds lockTryInterval) override; - - virtual StatusWith<ScopedDistLock> lockWithSessionID( - OperationContext* txn, - StringData name, - StringData whyMessage, - const OID lockSessionID, - stdx::chrono::milliseconds waitFor, - stdx::chrono::milliseconds lockTryInterval) override; + virtual StatusWith<DistLockManager::ScopedDistLock> lock(OperationContext* txn, + StringData name, + StringData whyMessage, + Milliseconds waitFor, + Milliseconds lockTryInterval) override; + + virtual StatusWith<ScopedDistLock> lockWithSessionID(OperationContext* txn, + StringData name, + StringData whyMessage, + const OID lockSessionID, + Milliseconds waitFor, + Milliseconds lockTryInterval) override; virtual void unlockAll(OperationContext* txn, const std::string& processID) override; @@ -112,7 +110,7 @@ private: */ StatusWith<bool> isLockExpired(OperationContext* txn, const LocksType lockDoc, - const stdx::chrono::milliseconds& lockExpiration); + const Milliseconds& lockExpiration); // // All member variables are labeled with one of the following codes indicating the @@ -126,10 +124,10 @@ private: ServiceContext* const _serviceContext; // (F) - const std::string _processID; // (I) - const std::unique_ptr<DistLockCatalog> _catalog; // (I) - const stdx::chrono::milliseconds _pingInterval; // (I) - const stdx::chrono::milliseconds _lockExpiration; // (I) + const std::string _processID; // (I) + const std::unique_ptr<DistLockCatalog> _catalog; // (I) + const Milliseconds _pingInterval; // (I) + const Milliseconds _lockExpiration; // (I) stdx::mutex _mutex; std::unique_ptr<stdx::thread> _execThread; // (S) |