summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2016-01-26 12:40:58 -0500
committermatt dannenberg <matt.dannenberg@10gen.com>2016-02-04 11:22:18 -0500
commitc3d0eecc3cad249849734eae96096b8ad313ab04 (patch)
tree4faa4a6bc06cd5a99586f3ee9f603a37acac0b15 /src/mongo/db/repl
parent2c2e6a38f559f25559c2b24eff51511c6fbc4a5b (diff)
downloadmongo-c3d0eecc3cad249849734eae96096b8ad313ab04.tar.gz
SERVER-22269 make ReadConcern: majority reflect journaled state on PRIMARY
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/optime.cpp20
-rw-r--r--src/mongo/db/repl/optime.h20
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.cpp10
-rw-r--r--src/mongo/db/repl/replication_coordinator_external_state_impl.h8
4 files changed, 31 insertions, 27 deletions
diff --git a/src/mongo/db/repl/optime.cpp b/src/mongo/db/repl/optime.cpp
index 8cf08a0afd7..288826821c2 100644
--- a/src/mongo/db/repl/optime.cpp
+++ b/src/mongo/db/repl/optime.cpp
@@ -41,26 +41,6 @@ namespace repl {
const char OpTime::kTimestampFieldName[] = "ts";
const char OpTime::kTermFieldName[] = "t";
-OpTime::OpTime() : _timestamp(Timestamp(0, 0)), _term(OpTime::kUninitializedTerm) {}
-
-OpTime::OpTime(Timestamp ts, long long term) : _timestamp(std::move(ts)), _term(term) {}
-
-Timestamp OpTime::getTimestamp() const {
- return _timestamp;
-}
-
-long long OpTime::getSecs() const {
- return _timestamp.getSecs();
-}
-
-long long OpTime::getTerm() const {
- return _term;
-}
-
-bool OpTime::isNull() const {
- return _timestamp.isNull();
-}
-
void OpTime::append(BSONObjBuilder* builder, const std::string& subObjName) const {
BSONObjBuilder opTimeBuilder(builder->subobjStart(subObjName));
opTimeBuilder.append(kTimestampFieldName, _timestamp);
diff --git a/src/mongo/db/repl/optime.h b/src/mongo/db/repl/optime.h
index b4c647047b9..d606935f340 100644
--- a/src/mongo/db/repl/optime.h
+++ b/src/mongo/db/repl/optime.h
@@ -62,14 +62,20 @@ public:
static const long long kInitialTerm = 0;
// Default OpTime, also the smallest one.
- OpTime();
- OpTime(Timestamp ts, long long term);
+ OpTime() : _timestamp(Timestamp(0, 0)), _term(kUninitializedTerm) {}
+ OpTime(Timestamp ts, long long term) : _timestamp(std::move(ts)), _term(term) {}
- Timestamp getTimestamp() const;
+ Timestamp getTimestamp() const {
+ return _timestamp;
+ }
- long long getSecs() const;
+ long long getSecs() const {
+ return _timestamp.getSecs();
+ }
- long long getTerm() const;
+ long long getTerm() const {
+ return _term;
+ }
/**
* Serializes the contents of this optime to the specified builder in the form:
@@ -83,7 +89,9 @@ public:
std::string toString() const;
// Returns true when this OpTime is not yet initialized.
- bool isNull() const;
+ bool isNull() const {
+ return _timestamp.isNull();
+ }
inline bool operator==(const OpTime& rhs) const {
// Only compare timestamp if either of the two OpTimes is generated by old protocol,
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
index ee12989dbbb..c14dae19b8c 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp
@@ -53,6 +53,7 @@
#include "mongo/db/repl/minvalid.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/repl_settings.h"
+#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/repl/rs_sync.h"
#include "mongo/db/repl/snapshot_thread.h"
#include "mongo/db/server_parameters.h"
@@ -108,6 +109,7 @@ void ReplicationCoordinatorExternalStateImpl::startThreads(const ReplSettings& s
_snapshotThread = SnapshotThread::start(getGlobalServiceContext());
}
_startedThreads = true;
+ getGlobalServiceContext()->getGlobalStorageEngine()->setJournalListener(this);
}
void ReplicationCoordinatorExternalStateImpl::startMasterSlave(OperationContext* txn) {
@@ -430,5 +432,13 @@ bool ReplicationCoordinatorExternalStateImpl::isReadCommittedSupportedByStorageE
return storageEngine->getSnapshotManager();
}
+JournalListener::Token ReplicationCoordinatorExternalStateImpl::getToken() {
+ return repl::getGlobalReplicationCoordinator()->getMyLastAppliedOpTime();
+}
+
+void ReplicationCoordinatorExternalStateImpl::onDurable(const JournalListener::Token& token) {
+ repl::getGlobalReplicationCoordinator()->setMyLastDurableOpTimeForward(token);
+}
+
} // namespace repl
} // namespace mongo
diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.h b/src/mongo/db/repl/replication_coordinator_external_state_impl.h
index 051c225c5bc..577c0b2aa4f 100644
--- a/src/mongo/db/repl/replication_coordinator_external_state_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.h
@@ -34,6 +34,7 @@
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/repl/replication_coordinator_external_state.h"
#include "mongo/db/repl/sync_source_feedback.h"
+#include "mongo/db/storage/journal_listener.h"
#include "mongo/db/storage/snapshot_manager.h"
#include "mongo/stdx/mutex.h"
#include "mongo/stdx/thread.h"
@@ -43,7 +44,8 @@ namespace repl {
class SnapshotThread;
-class ReplicationCoordinatorExternalStateImpl : public ReplicationCoordinatorExternalState {
+class ReplicationCoordinatorExternalStateImpl : public ReplicationCoordinatorExternalState,
+ public JournalListener {
MONGO_DISALLOW_COPYING(ReplicationCoordinatorExternalStateImpl);
public:
@@ -84,6 +86,10 @@ public:
std::string getNextOpContextThreadName();
+ // Methods from JournalListener.
+ virtual JournalListener::Token getToken();
+ virtual void onDurable(const JournalListener::Token& token);
+
private:
// Guards starting threads and setting _startedThreads
stdx::mutex _threadMutex;