summaryrefslogtreecommitdiff
path: root/src/mongo/db/keys_collection_cache_reader_and_updater.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/keys_collection_cache_reader_and_updater.cpp')
-rw-r--r--src/mongo/db/keys_collection_cache_reader_and_updater.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/mongo/db/keys_collection_cache_reader_and_updater.cpp b/src/mongo/db/keys_collection_cache_reader_and_updater.cpp
index b9ae9ca78ac..ce20c5d5993 100644
--- a/src/mongo/db/keys_collection_cache_reader_and_updater.cpp
+++ b/src/mongo/db/keys_collection_cache_reader_and_updater.cpp
@@ -31,10 +31,10 @@
#include "mongo/db/keys_collection_cache_reader_and_updater.h"
#include "mongo/client/read_preference.h"
+#include "mongo/db/keys_collection_client.h"
#include "mongo/db/logical_clock.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/server_options.h"
-#include "mongo/s/catalog/sharding_catalog_client.h"
#include "mongo/s/client/shard_registry.h"
#include "mongo/util/fail_point_service.h"
@@ -52,15 +52,12 @@ MONGO_FP_DECLARE(disableKeyGeneration);
* locally and never remotely even if this node is no longer primary.
*/
Status insertNewKey(OperationContext* opCtx,
- ShardingCatalogClient* client,
+ KeysCollectionClient* client,
long long keyId,
const std::string& purpose,
const LogicalTime& expiresAt) {
KeysCollectionDocument newKey(keyId, purpose, TimeProofService::generateRandomKey(), expiresAt);
- return client->insertConfigDocument(opCtx,
- KeysCollectionDocument::ConfigNS,
- newKey.toBSON(),
- ShardingCatalogClient::kMajorityWriteConcern);
+ return client->insertNewKey(opCtx, newKey.toBSON());
}
/**
@@ -73,11 +70,11 @@ LogicalTime addSeconds(const LogicalTime& logicalTime, const Seconds& seconds) {
} // unnamed namespace
KeysCollectionCacheReaderAndUpdater::KeysCollectionCacheReaderAndUpdater(
- std::string purpose, ShardingCatalogClient* client, Seconds keyValidForInterval)
+ std::string purpose, KeysCollectionClient* client, Seconds keyValidForInterval)
: KeysCollectionCacheReader(purpose, client),
+ _client(client),
_purpose(std::move(purpose)),
- _keyValidForInterval(keyValidForInterval),
- _catalogClient(client) {}
+ _keyValidForInterval(keyValidForInterval) {}
StatusWith<KeysCollectionDocument> KeysCollectionCacheReaderAndUpdater::refresh(
OperationContext* opCtx) {
@@ -92,8 +89,7 @@ StatusWith<KeysCollectionDocument> KeysCollectionCacheReaderAndUpdater::refresh(
}
auto currentTime = LogicalClock::get(opCtx)->getClusterTime();
- auto keyStatus = _catalogClient->getNewKeys(
- opCtx, _purpose, currentTime, repl::ReadConcernLevel::kLocalReadConcern);
+ auto keyStatus = _client->getNewKeys(opCtx, _purpose, currentTime);
if (!keyStatus.isOK()) {
return keyStatus.getStatus();
@@ -108,7 +104,7 @@ StatusWith<KeysCollectionDocument> KeysCollectionCacheReaderAndUpdater::refresh(
if (keyIter == newKeys.cend()) {
currentKeyExpiresAt = addSeconds(currentTime, _keyValidForInterval);
- auto status = insertNewKey(opCtx, _catalogClient, keyId, _purpose, currentKeyExpiresAt);
+ auto status = insertNewKey(opCtx, _client, keyId, _purpose, currentKeyExpiresAt);
if (!status.isOK()) {
return status;
@@ -117,7 +113,7 @@ StatusWith<KeysCollectionDocument> KeysCollectionCacheReaderAndUpdater::refresh(
keyId++;
} else if (keyIter->getExpiresAt() < currentTime) {
currentKeyExpiresAt = addSeconds(currentTime, _keyValidForInterval);
- auto status = insertNewKey(opCtx, _catalogClient, keyId, _purpose, currentKeyExpiresAt);
+ auto status = insertNewKey(opCtx, _client, keyId, _purpose, currentKeyExpiresAt);
if (!status.isOK()) {
return status;
@@ -135,14 +131,14 @@ StatusWith<KeysCollectionDocument> KeysCollectionCacheReaderAndUpdater::refresh(
// Note: Convert this block into a loop if more reserved keys are desired.
if (keyIter == newKeys.cend()) {
auto reserveKeyExpiresAt = addSeconds(currentKeyExpiresAt, _keyValidForInterval);
- auto status = insertNewKey(opCtx, _catalogClient, keyId, _purpose, reserveKeyExpiresAt);
+ auto status = insertNewKey(opCtx, _client, keyId, _purpose, reserveKeyExpiresAt);
if (!status.isOK()) {
return status;
}
} else if (keyIter->getExpiresAt() < currentTime) {
currentKeyExpiresAt = addSeconds(currentKeyExpiresAt, _keyValidForInterval);
- auto status = insertNewKey(opCtx, _catalogClient, keyId, _purpose, currentKeyExpiresAt);
+ auto status = insertNewKey(opCtx, _client, keyId, _purpose, currentKeyExpiresAt);
if (!status.isOK()) {
return status;