From 08ef5eefb59b96c6696416144d43cfe2c45d3619 Mon Sep 17 00:00:00 2001 From: Andrew Morrow Date: Tue, 12 Jul 2016 11:23:38 -0400 Subject: 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. --- src/mongo/db/commands/parameters.cpp | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/mongo/db/commands/parameters.cpp') 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 MaxConsecutiveFa ExportedServerParameter 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 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 lock(_mutex); + _value = str; + } + + return Status::OK(); + } + +private: + stdx::mutex _mutex; + std::string _value; +} automationServiceDescriptor; + +constexpr decltype(AutomationServiceDescriptor::kName) AutomationServiceDescriptor::kName; } } -- cgit v1.2.1