summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2016-04-22 19:10:03 -0400
committerAndy Schwerin <schwerin@mongodb.com>2016-05-24 11:02:20 -0400
commit16e30e94be91617f710967dc404c4cf6f76388f3 (patch)
treeaf94b0fd4c57c3c6e4e951ef110e6b1838427473 /src/mongo
parent47a685fdab7a6506d15e3d37665624594f5e8ea7 (diff)
downloadmongo-16e30e94be91617f710967dc404c4cf6f76388f3.tar.gz
SERVER-23905 Remove isPrimaryFor from OperationContext.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/index/index_access_method.cpp5
-rw-r--r--src/mongo/db/operation_context.h5
-rw-r--r--src/mongo/db/operation_context_impl.cpp4
-rw-r--r--src/mongo/db/operation_context_impl.h2
-rw-r--r--src/mongo/db/operation_context_noop.h4
5 files changed, 4 insertions, 16 deletions
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp
index 4670a74f59d..2abb95870d3 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/keypattern.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/server_parameters.h"
#include "mongo/db/storage/storage_options.h"
#include "mongo/util/log.h"
@@ -109,7 +110,9 @@ IndexAccessMethod::IndexAccessMethod(IndexCatalogEntry* btreeState, SortedDataIn
bool IndexAccessMethod::ignoreKeyTooLong(OperationContext* txn) {
// Ignore this error if we're on a secondary or if the user requested it
- return !txn->isPrimaryFor(_btreeState->ns()) || !failIndexKeyTooLong;
+ const auto canAcceptWritesForNs = repl::ReplicationCoordinator::get(txn)
+ ->canAcceptWritesFor(NamespaceString(_btreeState->ns()));
+ return !canAcceptWritesForNs || !failIndexKeyTooLong;
}
// Find the keys for obj, put them in the tree pointing to loc
diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h
index 409d329733f..6b81375c00f 100644
--- a/src/mongo/db/operation_context.h
+++ b/src/mongo/db/operation_context.h
@@ -164,11 +164,6 @@ public:
}
/**
- * @return true if this instance is primary for this namespace
- */
- virtual bool isPrimaryFor(StringData ns) = 0;
-
- /**
* Returns WriteConcernOptions of the current operation
*/
const WriteConcernOptions& getWriteConcern() const {
diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp
index fec4cff0957..93ce0686440 100644
--- a/src/mongo/db/operation_context_impl.cpp
+++ b/src/mongo/db/operation_context_impl.cpp
@@ -99,8 +99,4 @@ string OperationContextImpl::getNS() const {
return CurOp::get(this)->getNS();
}
-bool OperationContextImpl::isPrimaryFor(StringData ns) {
- return repl::getGlobalReplicationCoordinator()->canAcceptWritesFor(NamespaceString(ns));
-}
-
} // namespace mongo
diff --git a/src/mongo/db/operation_context_impl.h b/src/mongo/db/operation_context_impl.h
index de60127c6dd..a4861c171a0 100644
--- a/src/mongo/db/operation_context_impl.h
+++ b/src/mongo/db/operation_context_impl.h
@@ -44,8 +44,6 @@ public:
virtual std::string getNS() const override;
- virtual bool isPrimaryFor(StringData ns) override;
-
private:
friend class ServiceContextMongoD;
diff --git a/src/mongo/db/operation_context_noop.h b/src/mongo/db/operation_context_noop.h
index 84d2eb2f4ec..b7978fa3b42 100644
--- a/src/mongo/db/operation_context_noop.h
+++ b/src/mongo/db/operation_context_noop.h
@@ -77,10 +77,6 @@ public:
return &_pm;
}
- virtual bool isPrimaryFor(StringData ns) override {
- return true;
- }
-
virtual std::string getNS() const override {
return std::string();
};