summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/parameters.cpp
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/commands/parameters.cpp
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/commands/parameters.cpp')
-rw-r--r--src/mongo/db/commands/parameters.cpp47
1 files changed, 47 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;
}
}