summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2017-07-20 16:40:47 -0400
committerJudah Schvimer <judah@mongodb.com>2017-07-20 16:45:00 -0400
commitd8bcead30c25f076728f7115cdf98d7a93ab7a4f (patch)
treeaf85b9db5913e3f5cc792e4e7966bbe0127a181e /src/mongo/db
parent808368314d1036b022334b67a9b2bd306daab840 (diff)
downloadmongo-d8bcead30c25f076728f7115cdf98d7a93ab7a4f.tar.gz
SERVER-30184 Add mock getters to storage interface for stable timestamp and initial data timestamp
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/repl/storage_interface_mock.cpp28
-rw-r--r--src/mongo/db/repl/storage_interface_mock.h16
2 files changed, 34 insertions, 10 deletions
diff --git a/src/mongo/db/repl/storage_interface_mock.cpp b/src/mongo/db/repl/storage_interface_mock.cpp
index 89fb5831083..2bb4e8c4597 100644
--- a/src/mongo/db/repl/storage_interface_mock.cpp
+++ b/src/mongo/db/repl/storage_interface_mock.cpp
@@ -40,7 +40,7 @@ namespace mongo {
namespace repl {
StatusWith<int> StorageInterfaceMock::getRollbackID(OperationContext* opCtx) {
- stdx::lock_guard<stdx::mutex> lock(_rbidMutex);
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
if (!_rbidInitialized) {
return Status(ErrorCodes::NamespaceNotFound, "Rollback ID not initialized");
}
@@ -48,7 +48,7 @@ StatusWith<int> StorageInterfaceMock::getRollbackID(OperationContext* opCtx) {
}
Status StorageInterfaceMock::initializeRollbackID(OperationContext* opCtx) {
- stdx::lock_guard<stdx::mutex> lock(_rbidMutex);
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
if (_rbidInitialized) {
return Status(ErrorCodes::NamespaceExists, "Rollback ID already initialized");
}
@@ -60,13 +60,35 @@ Status StorageInterfaceMock::initializeRollbackID(OperationContext* opCtx) {
}
Status StorageInterfaceMock::incrementRollbackID(OperationContext* opCtx) {
- stdx::lock_guard<stdx::mutex> lock(_rbidMutex);
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
if (!_rbidInitialized) {
return Status(ErrorCodes::NamespaceNotFound, "Rollback ID not initialized");
}
_rbid++;
return Status::OK();
}
+
+void StorageInterfaceMock::setStableTimestamp(OperationContext* opCtx, SnapshotName snapshotName) {
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
+ _stableTimestamp = snapshotName;
+}
+
+void StorageInterfaceMock::setInitialDataTimestamp(OperationContext* opCtx,
+ SnapshotName snapshotName) {
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
+ _initialDataTimestamp = snapshotName;
+}
+
+SnapshotName StorageInterfaceMock::getStableTimestamp() const {
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
+ return _stableTimestamp;
+}
+
+SnapshotName StorageInterfaceMock::getInitialDataTimestamp() const {
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
+ return _initialDataTimestamp;
+}
+
Status CollectionBulkLoaderMock::init(const std::vector<BSONObj>& secondaryIndexSpecs) {
LOG(1) << "CollectionBulkLoaderMock::init called";
stats->initCalled = true;
diff --git a/src/mongo/db/repl/storage_interface_mock.h b/src/mongo/db/repl/storage_interface_mock.h
index f443dc95e7e..20249b455c6 100644
--- a/src/mongo/db/repl/storage_interface_mock.h
+++ b/src/mongo/db/repl/storage_interface_mock.h
@@ -244,13 +244,13 @@ public:
return 0;
}
- void setStableTimestamp(OperationContext* opCtx, SnapshotName snapshotName) override {
- return;
- }
+ void setStableTimestamp(OperationContext* opCtx, SnapshotName snapshotName) override;
- void setInitialDataTimestamp(OperationContext* opCtx, SnapshotName snapshotName) override {
- return;
- }
+ void setInitialDataTimestamp(OperationContext* opCtx, SnapshotName snapshotName) override;
+
+ SnapshotName getStableTimestamp() const;
+
+ SnapshotName getInitialDataTimestamp() const;
Status isAdminDbValid(OperationContext* opCtx) override {
return isAdminDbValidFn(opCtx);
@@ -310,9 +310,11 @@ public:
};
private:
- mutable stdx::mutex _rbidMutex;
+ mutable stdx::mutex _mutex;
int _rbid;
bool _rbidInitialized = false;
+ SnapshotName _stableTimestamp = SnapshotName::min();
+ SnapshotName _initialDataTimestamp = SnapshotName::min();
};
} // namespace repl