summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2016-07-12 11:23:38 -0400
committerAndrew Morrow <acm@mongodb.com>2016-07-15 18:10:22 -0400
commit08ef5eefb59b96c6696416144d43cfe2c45d3619 (patch)
tree0d3e711550e90f863e185312bb960bc2eb73340a /src/mongo/db
parent292d84272ba6a548e9c81064bcdab00dd1acf2a3 (diff)
downloadmongo-08ef5eefb59b96c6696416144d43cfe2c45d3619.tar.gz
SERVER-18399 Issue a notification in the shell when automation is active
Also provides a new setParameter to configure the automation name to be returned in an isMaster reply.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/commands/parameters.cpp47
-rw-r--r--src/mongo/db/repl/replication_info.cpp9
2 files changed, 56 insertions, 0 deletions
diff --git a/src/mongo/db/commands/parameters.cpp b/src/mongo/db/commands/parameters.cpp
index 7531a834818..32c4b7d535b 100644
--- a/src/mongo/db/commands/parameters.cpp
+++ b/src/mongo/db/commands/parameters.cpp
@@ -603,5 +603,52 @@ ExportedServerParameter<int, ServerParameterType::kRuntimeOnly> MaxConsecutiveFa
ExportedServerParameter<bool, ServerParameterType::kRuntimeOnly> TraceExceptionsSetting(
ServerParameterSet::getGlobal(), "traceExceptions", &DBException::traceExceptions);
+
+class AutomationServiceDescriptor final : public ServerParameter {
+public:
+ static constexpr auto kName = "automationServiceDescriptor"_sd;
+ static constexpr auto kMaxSize = 64U;
+
+ AutomationServiceDescriptor()
+ : ServerParameter(ServerParameterSet::getGlobal(), kName.toString(), true, true) {}
+
+ virtual void append(OperationContext* txn,
+ BSONObjBuilder& builder,
+ const std::string& name) override {
+ const stdx::lock_guard<stdx::mutex> lock(_mutex);
+ if (!_value.empty())
+ builder << name << _value;
+ }
+
+ virtual Status set(const BSONElement& newValueElement) override {
+ if (newValueElement.type() != mongo::String)
+ return {ErrorCodes::TypeMismatch,
+ mongoutils::str::stream() << "Value for parameter " << kName
+ << " must be of type 'string'"};
+ return setFromString(newValueElement.String());
+ }
+
+ virtual Status setFromString(const std::string& str) override {
+ if (str.size() > kMaxSize)
+ return {ErrorCodes::Overflow,
+ mongoutils::str::stream() << "Value for parameter " << kName
+ << " must be no more than "
+ << kMaxSize
+ << " bytes"};
+
+ {
+ const stdx::lock_guard<stdx::mutex> lock(_mutex);
+ _value = str;
+ }
+
+ return Status::OK();
+ }
+
+private:
+ stdx::mutex _mutex;
+ std::string _value;
+} automationServiceDescriptor;
+
+constexpr decltype(AutomationServiceDescriptor::kName) AutomationServiceDescriptor::kName;
}
}
diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp
index fd36395c017..d79f48de6d4 100644
--- a/src/mongo/db/repl/replication_info.cpp
+++ b/src/mongo/db/repl/replication_info.cpp
@@ -45,10 +45,13 @@
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/oplogreader.h"
#include "mongo/db/repl/replication_coordinator_global.h"
+#include "mongo/db/server_options.h"
+#include "mongo/db/server_parameters.h"
#include "mongo/db/storage/storage_options.h"
#include "mongo/db/wire_version.h"
#include "mongo/executor/network_interface.h"
#include "mongo/s/write_ops/batched_command_request.h"
+#include "mongo/util/map_util.h"
namespace mongo {
@@ -253,6 +256,12 @@ public:
result.append("maxWireVersion", WireSpec::instance().maxWireVersionIncoming);
result.append("minWireVersion", WireSpec::instance().minWireVersionIncoming);
result.append("readOnly", storageGlobalParams.readOnly);
+
+ const auto parameter = mapFindWithDefault(ServerParameterSet::getGlobal()->getMap(),
+ "automationServiceDescriptor");
+ if (parameter)
+ parameter->append(txn, result, "automationServiceDescriptor");
+
return true;
}
} cmdismaster;