diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2017-10-14 21:54:01 -0400 |
---|---|---|
committer | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2017-10-14 21:54:01 -0400 |
commit | 2c5511c8c411c70ac1063d1209764e71f83d0b1a (patch) | |
tree | 17eefbaa6e2a7a0416ae036f26e7822d9cf8d982 /src/mongo/scripting | |
parent | 7efbb340cd781d097c153c48c64fb442bbe2a22b (diff) | |
download | mongo-2c5511c8c411c70ac1063d1209764e71f83d0b1a.tar.gz |
SERVER-31456 Expose server type on Mongo connection object.
This makes it possible to prevent the mongo shell from gossiping a
clusterTime to stand-alone mongod processes when the mongo shell is also
connected to a replica set or a sharded cluster.
Diffstat (limited to 'src/mongo/scripting')
-rw-r--r-- | src/mongo/scripting/mozjs/mongo.cpp | 15 | ||||
-rw-r--r-- | src/mongo/scripting/mozjs/mongo.h | 4 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/mongo/scripting/mozjs/mongo.cpp b/src/mongo/scripting/mozjs/mongo.cpp index 84c93aa786f..922a6931891 100644 --- a/src/mongo/scripting/mozjs/mongo.cpp +++ b/src/mongo/scripting/mozjs/mongo.cpp @@ -84,6 +84,9 @@ const JSFunctionSpec MongoBase::methods[] = { getMinWireVersion, MongoLocalInfo, MongoExternalInfo), MONGO_ATTACH_JS_CONSTRAINED_METHOD_NO_PROTO( getMaxWireVersion, MongoLocalInfo, MongoExternalInfo), + MONGO_ATTACH_JS_CONSTRAINED_METHOD_NO_PROTO( + isReplicaSetMember, MongoLocalInfo, MongoExternalInfo), + MONGO_ATTACH_JS_CONSTRAINED_METHOD_NO_PROTO(isMongos, MongoLocalInfo, MongoExternalInfo), MONGO_ATTACH_JS_CONSTRAINED_METHOD_NO_PROTO(getClusterTime, MongoLocalInfo, MongoExternalInfo), MONGO_ATTACH_JS_CONSTRAINED_METHOD_NO_PROTO(setClusterTime, MongoLocalInfo, MongoExternalInfo), MONGO_ATTACH_JS_CONSTRAINED_METHOD_NO_PROTO(_startSession, MongoLocalInfo, MongoExternalInfo), @@ -766,6 +769,18 @@ void MongoBase::Functions::getMaxWireVersion::call(JSContext* cx, JS::CallArgs a args.rval().setInt32(conn->getMaxWireVersion()); } +void MongoBase::Functions::isReplicaSetMember::call(JSContext* cx, JS::CallArgs args) { + auto conn = getConnection(args); + + args.rval().setBoolean(conn->isReplicaSetMember()); +} + +void MongoBase::Functions::isMongos::call(JSContext* cx, JS::CallArgs args) { + auto conn = getConnection(args); + + args.rval().setBoolean(conn->isMongos()); +} + void MongoBase::Functions::getClusterTime::call(JSContext* cx, JS::CallArgs args) { auto ct = MongoBase::getClusterTime(); diff --git a/src/mongo/scripting/mozjs/mongo.h b/src/mongo/scripting/mozjs/mongo.h index 6d8426520b3..f6c6a535c1c 100644 --- a/src/mongo/scripting/mozjs/mongo.h +++ b/src/mongo/scripting/mozjs/mongo.h @@ -62,12 +62,14 @@ struct MongoBase : public BaseInfo { MONGO_DECLARE_JS_FUNCTION(update); MONGO_DECLARE_JS_FUNCTION(getMinWireVersion); MONGO_DECLARE_JS_FUNCTION(getMaxWireVersion); + MONGO_DECLARE_JS_FUNCTION(isReplicaSetMember); + MONGO_DECLARE_JS_FUNCTION(isMongos); MONGO_DECLARE_JS_FUNCTION(getClusterTime); MONGO_DECLARE_JS_FUNCTION(setClusterTime); MONGO_DECLARE_JS_FUNCTION(_startSession); }; - static const JSFunctionSpec methods[22]; + static const JSFunctionSpec methods[24]; static const char* const className; static const unsigned classFlags = JSCLASS_HAS_PRIVATE; |