summaryrefslogtreecommitdiff
path: root/src/mongo/rpc
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2015-08-21 14:04:07 -0400
committerBenety Goh <benety@mongodb.com>2015-09-02 11:13:53 -0400
commite2d0abbeddaff528a86391832593789e26a05f10 (patch)
treebc6182abf20d1c47da61e154fe61d9da98dcf499 /src/mongo/rpc
parent6cb1c6dc32da19dff41f40eec6beea9abc6bbdd4 (diff)
downloadmongo-e2d0abbeddaff528a86391832593789e26a05f10.tar.gz
SERVER-18384 commented on use of -1 for primary index in replication metadata
Diffstat (limited to 'src/mongo/rpc')
-rw-r--r--src/mongo/rpc/metadata/repl_set_metadata.cpp4
-rw-r--r--src/mongo/rpc/metadata/repl_set_metadata.h9
2 files changed, 12 insertions, 1 deletions
diff --git a/src/mongo/rpc/metadata/repl_set_metadata.cpp b/src/mongo/rpc/metadata/repl_set_metadata.cpp
index 66780b50633..8ea6f2fa867 100644
--- a/src/mongo/rpc/metadata/repl_set_metadata.cpp
+++ b/src/mongo/rpc/metadata/repl_set_metadata.cpp
@@ -51,6 +51,10 @@ const char kTermFieldName[] = "term";
} // unnamed namespace
+#ifndef _MSC_EXTENSIONS
+const int ReplSetMetadata::kNoPrimary;
+#endif // _MSC_EXTENSIONS
+
ReplSetMetadata::ReplSetMetadata(long long term,
OpTime committedOpTime,
OpTime visibleOpTime,
diff --git a/src/mongo/rpc/metadata/repl_set_metadata.h b/src/mongo/rpc/metadata/repl_set_metadata.h
index 97d7b4b8da3..722f3befe3e 100644
--- a/src/mongo/rpc/metadata/repl_set_metadata.h
+++ b/src/mongo/rpc/metadata/repl_set_metadata.h
@@ -44,6 +44,12 @@ extern const char kReplSetMetadataFieldName[];
*/
class ReplSetMetadata {
public:
+ /**
+ * Default primary index. Also used to indicate in metadata that there is no
+ * primary.
+ */
+ static const int kNoPrimary = -1;
+
ReplSetMetadata() = default;
ReplSetMetadata(long long term,
repl::OpTime committedOpTime,
@@ -87,6 +93,7 @@ public:
/**
* Returns the index of the current primary from the perspective of the sender.
+ * Returns kNoPrimary if there is no primary.
*/
long long getPrimaryIndex() const {
return _currentPrimaryIndex;
@@ -104,7 +111,7 @@ private:
repl::OpTime _lastOpVisible = repl::OpTime(Timestamp(0, 0), repl::OpTime::kUninitializedTerm);
long long _currentTerm = -1;
long long _configVersion = -1;
- int _currentPrimaryIndex = -1;
+ int _currentPrimaryIndex = kNoPrimary;
};
} // namespace rpc