summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2018-12-18 12:52:14 -0500
committerMark Benvenuto <mark.benvenuto@mongodb.com>2018-12-18 12:52:14 -0500
commita68772146462ed5ef7e86c09b05e4c31a1930be5 (patch)
tree77f7ef804d62b7579d54fa6b9c4fc1b01ef20ab4
parentc48fa7e3fe5ad27d7b0e4360da03943b362adf24 (diff)
downloadmongo-a68772146462ed5ef7e86c09b05e4c31a1930be5.tar.gz
SERVER-38484 Convert free_mon_mongod.cpp set parameters to IDL
-rw-r--r--src/mongo/db/free_mon/SConscript1
-rw-r--r--src/mongo/db/free_mon/free_mon_mongod.cpp36
-rw-r--r--src/mongo/db/free_mon/free_mon_mongod.h5
-rw-r--r--src/mongo/db/free_mon/free_mon_mongod.idl47
4 files changed, 65 insertions, 24 deletions
diff --git a/src/mongo/db/free_mon/SConscript b/src/mongo/db/free_mon/SConscript
index e973c88f648..90ebd17ee78 100644
--- a/src/mongo/db/free_mon/SConscript
+++ b/src/mongo/db/free_mon/SConscript
@@ -35,6 +35,7 @@ if free_monitoring == "on":
source=[
'free_mon_commands.cpp',
'free_mon_mongod.cpp',
+ env.Idlc('free_mon_mongod.idl')[0],
'free_mon_options.cpp',
'free_mon_status.cpp',
],
diff --git a/src/mongo/db/free_mon/free_mon_mongod.cpp b/src/mongo/db/free_mon/free_mon_mongod.cpp
index 38c71e6f543..3ff516fea7a 100644
--- a/src/mongo/db/free_mon/free_mon_mongod.cpp
+++ b/src/mongo/db/free_mon/free_mon_mongod.cpp
@@ -50,6 +50,7 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/free_mon/free_mon_controller.h"
#include "mongo/db/free_mon/free_mon_message.h"
+#include "mongo/db/free_mon/free_mon_mongod_gen.h"
#include "mongo/db/free_mon/free_mon_network.h"
#include "mongo/db/free_mon/free_mon_op_observer.h"
#include "mongo/db/free_mon/free_mon_options.h"
@@ -75,28 +76,6 @@ namespace {
constexpr Seconds kDefaultMetricsGatherInterval(60);
-/**
- * Expose cloudFreeMonitoringEndpointURL set parameter to URL for free monitoring.
- */
-class ExportedFreeMonEndpointURL : public LockedServerParameter<std::string> {
-public:
- ExportedFreeMonEndpointURL()
- : LockedServerParameter<std::string>("cloudFreeMonitoringEndpointURL",
- "https://cloud.mongodb.com/freemonitoring/mongo",
- ServerParameterType::kStartupOnly) {}
-
-
- Status setFromString(const std::string& str) final {
- // Check for http, not https here because testEnabled may not be set yet
- if (str.compare(0, 4, "http") != 0) {
- return Status(ErrorCodes::BadValue,
- "ExportedFreeMonEndpointURL only supports https:// URLs");
- }
-
- return setLocked(str);
- }
-} exportedExportedFreeMonEndpointURL;
-
auto makeTaskExecutor(ServiceContext* /*serviceContext*/) {
ThreadPool::Options tpOptions;
tpOptions.poolName = "freemon";
@@ -178,7 +157,7 @@ private:
Future<DataBuilder> post(StringData path,
std::shared_ptr<std::vector<std::uint8_t>> data) const {
auto pf = makePromiseFuture<DataBuilder>();
- std::string url(exportedExportedFreeMonEndpointURL.getLocked() + path.toString());
+ std::string url(FreeMonEndpointURL + path.toString());
auto status = _executor->scheduleWork(
[ promise = std::move(pf.promise), url = std::move(url), data = std::move(data), this ](
@@ -300,6 +279,15 @@ private:
} // namespace
+Status onValidateFreeMonEndpointURL(StringData str) {
+ // Check for http, not https here because testEnabled may not be set yet
+ if (!str.startsWith("https"_sd) != 0) {
+ return Status(ErrorCodes::BadValue,
+ "cloudFreeMonitoringEndpointURL only supports https:// URLs");
+ }
+
+ return Status::OK();
+}
void registerCollectors(FreeMonController* controller) {
// These are collected only at registration
@@ -359,7 +347,7 @@ void startFreeMonitoring(ServiceContext* serviceContext) {
if (!getTestCommandsEnabled()) {
uassert(50774,
"ExportedFreeMonEndpointURL only supports https:// URLs",
- exportedExportedFreeMonEndpointURL.getLocked().compare(0, 5, "https") == 0);
+ FreeMonEndpointURL.compare(0, 5, "https") == 0);
}
auto network = std::unique_ptr<FreeMonNetworkInterface>(new FreeMonNetworkHttp(serviceContext));
diff --git a/src/mongo/db/free_mon/free_mon_mongod.h b/src/mongo/db/free_mon/free_mon_mongod.h
index d266543b1d9..d591fa8d14a 100644
--- a/src/mongo/db/free_mon/free_mon_mongod.h
+++ b/src/mongo/db/free_mon/free_mon_mongod.h
@@ -30,6 +30,8 @@
#pragma once
+#include <string>
+
#include "mongo/db/op_observer_registry.h"
#include "mongo/db/service_context.h"
@@ -58,4 +60,7 @@ void notifyFreeMonitoringOnTransitionToPrimary();
*/
void setupFreeMonitoringOpObserver(OpObserverRegistry* registry);
+Status onValidateFreeMonEndpointURL(StringData str);
+
+
} // namespace mongo
diff --git a/src/mongo/db/free_mon/free_mon_mongod.idl b/src/mongo/db/free_mon/free_mon_mongod.idl
new file mode 100644
index 00000000000..b3b34dafb29
--- /dev/null
+++ b/src/mongo/db/free_mon/free_mon_mongod.idl
@@ -0,0 +1,47 @@
+# Copyright (C) 2018-present MongoDB, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Server Side Public License, version 1,
+# as published by MongoDB, Inc.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# Server Side Public License for more details.
+#
+# You should have received a copy of the Server Side Public License
+# along with this program. If not, see
+# <http://www.mongodb.com/licensing/server-side-public-license>.
+#
+# As a special exception, the copyright holders give permission to link the
+# code of portions of this program with the OpenSSL library under certain
+# conditions as described in each individual source file and distribute
+# linked combinations including the program with the OpenSSL library. You
+# must comply with the Server Side Public License in all respects for
+# all of the code used other than as permitted herein. If you modify file(s)
+# with this exception, you may extend this exception to your version of the
+# file(s), but you are not obligated to do so. If you do not wish to do so,
+# delete this exception statement from your version. If you delete this
+# exception statement from all source files in the program, then also delete
+# it in the license file.
+#
+
+global:
+ cpp_namespace: "mongo"
+ cpp_includes:
+ - "mongo/db/free_mon/free_mon_mongod.h"
+
+imports:
+ - "mongo/idl/basic_types.idl"
+
+server_parameters:
+
+ cloudFreeMonitoringEndpointURL:
+ description: "Suppress logging of warnings when non-SSL connections are accepted in preferSSL mode"
+ set_at: startup
+ default: "https://cloud.mongodb.com/freemonitoring/mongo"
+ cpp_vartype: std::string
+ cpp_varname: FreeMonEndpointURL
+ validator:
+ callback: "onValidateFreeMonEndpointURL"
+