summaryrefslogtreecommitdiff
path: root/src/mongo/executor
diff options
context:
space:
mode:
authorsamantharitter <samantha.ritter@10gen.com>2015-06-30 11:18:39 -0400
committersamantharitter <samantha.ritter@10gen.com>2015-06-30 14:33:43 -0400
commit167e9cb5467e5052c9eef678c9dd306612a19790 (patch)
tree089faca17d2b8e37b46eed18d529bded43b47821 /src/mongo/executor
parent83bdca38a6d4e1dfb1af4760c4af72a7b4ca65c2 (diff)
downloadmongo-167e9cb5467e5052c9eef678c9dd306612a19790.tar.gz
SERVER-19165 add setParameter to control choice of NetworkInterface
Diffstat (limited to 'src/mongo/executor')
-rw-r--r--src/mongo/executor/SConscript12
-rw-r--r--src/mongo/executor/network_interface_factory.cpp66
-rw-r--r--src/mongo/executor/network_interface_factory.h48
3 files changed, 125 insertions, 1 deletions
diff --git a/src/mongo/executor/SConscript b/src/mongo/executor/SConscript
index c9c4b5d8d95..a919d240799 100644
--- a/src/mongo/executor/SConscript
+++ b/src/mongo/executor/SConscript
@@ -47,6 +47,16 @@ env.Library(
'$BUILD_DIR/mongo/client/clientdriver',
'$BUILD_DIR/mongo/db/coredb',
'$BUILD_DIR/mongo/db/repl/replication_executor',
- '$BUILD_DIR/mongo/db/serveronly',
'$BUILD_DIR/third_party/shim_asio',
])
+
+env.Library(
+ target='network_interface_factory',
+ source=[
+ 'network_interface_factory.cpp',
+ ],
+ LIBDEPS=[
+ 'network_interface',
+ 'network_interface_asio',
+ 'network_interface_impl',
+ ])
diff --git a/src/mongo/executor/network_interface_factory.cpp b/src/mongo/executor/network_interface_factory.cpp
new file mode 100644
index 00000000000..d86f1899a36
--- /dev/null
+++ b/src/mongo/executor/network_interface_factory.cpp
@@ -0,0 +1,66 @@
+/**
+ * Copyright (C) 2015 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * 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 GNU Affero General 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.
+ */
+
+#include "mongo/executor/network_interface_factory.h"
+
+#include "mongo/base/init.h"
+#include "mongo/base/status.h"
+#include "mongo/db/server_parameters.h"
+#include "mongo/executor/network_interface_asio.h"
+#include "mongo/executor/network_interface_impl.h"
+#include "mongo/stdx/memory.h"
+
+namespace mongo {
+namespace executor {
+
+namespace {
+
+const char kNetworkImplASIO[] = "ASIO";
+const char kNetworkImplThreadPool[] = "threadPool";
+
+} // namespace
+
+MONGO_EXPORT_STARTUP_SERVER_PARAMETER(outboundNetworkImpl, std::string, kNetworkImplThreadPool);
+MONGO_INITIALIZER(outboundNetworkImpl)(InitializerContext*) {
+ if (outboundNetworkImpl != kNetworkImplThreadPool && outboundNetworkImpl != kNetworkImplASIO) {
+ return Status(ErrorCodes::BadValue,
+ "unsupported networking option: " + outboundNetworkImpl);
+ }
+ return Status::OK();
+}
+
+std::unique_ptr<NetworkInterface> makeNetworkInterface() {
+ if (outboundNetworkImpl == kNetworkImplASIO) {
+ return stdx::make_unique<NetworkInterfaceASIO>();
+ } else {
+ return stdx::make_unique<NetworkInterfaceImpl>();
+ }
+}
+
+} // namespace executor
+} // namespace mongo
diff --git a/src/mongo/executor/network_interface_factory.h b/src/mongo/executor/network_interface_factory.h
new file mode 100644
index 00000000000..5934368d942
--- /dev/null
+++ b/src/mongo/executor/network_interface_factory.h
@@ -0,0 +1,48 @@
+/**
+ * Copyright (C) 2015 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * 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 GNU Affero General 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.
+ */
+
+#pragma once
+
+#include <memory>
+#include <string>
+
+#include "mongo/executor/network_interface.h"
+
+namespace mongo {
+namespace executor {
+
+ /**
+ * Returns a new NetworkInterface.
+ *
+ * Different NetworkInterface implementations may be specified setting the
+ * 'outboundNetworkImpl' at startup.
+ */
+ std::unique_ptr<NetworkInterface> makeNetworkInterface();
+
+} // namespace executor
+} // namespace mongo