mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 17:10:48 +01:00
SERVER-15031 Add compile-time flag to control which ReplicationCoordinator is used
This commit is contained in:
parent
30b1d49b30
commit
c9ae135400
@ -230,6 +230,9 @@ add_option( "mm", "use main memory instead of memory mapped files" , 0 , True )
|
||||
add_option( "ssl" , "Enable SSL" , 0 , True )
|
||||
add_option( "ssl-fips-capability", "Enable the ability to activate FIPS 140-2 mode", 0, True );
|
||||
add_option( "rocksdb" , "Enable RocksDB" , 0 , False )
|
||||
add_option( "replication-implementation",
|
||||
"Controls what implementation is used for the replication system", "?", False,
|
||||
type="choice", choices=["impl", "legacy"], const="legacy", default="legacy" )
|
||||
|
||||
# library choices
|
||||
js_engine_choices = ['v8-3.12', 'v8-3.25', 'none']
|
||||
@ -978,6 +981,8 @@ if has_option( "ssl" ):
|
||||
if has_option("ssl-fips-capability"):
|
||||
env.Append( CPPDEFINES=["MONGO_SSL_FIPS"] )
|
||||
|
||||
env['MONGO_REPL_IMPL'] = get_option('replication-implementation')
|
||||
|
||||
try:
|
||||
umask = os.umask(022)
|
||||
except OSError:
|
||||
|
@ -965,7 +965,8 @@ env.Library("mongodwebserver",
|
||||
],
|
||||
LIBDEPS=["coredb", "mongodandmongos"])
|
||||
|
||||
mongodOnlyFiles = [ "db/db.cpp", "db/commands/touch.cpp", "db/mongod_options_init.cpp" ]
|
||||
mongodOnlyFiles = [ "db/db.cpp", "db/commands/touch.cpp", "db/mongod_options_init.cpp",
|
||||
"db/repl/replication_initializer_${MONGO_REPL_IMPL}.cpp", ]
|
||||
|
||||
# ----- TARGETS ------
|
||||
|
||||
|
@ -69,9 +69,7 @@
|
||||
#include "mongo/db/query/internal_plans.h"
|
||||
#include "mongo/db/range_deleter_service.h"
|
||||
#include "mongo/db/repair_database.h"
|
||||
#include "mongo/db/repl/network_interface_impl.h"
|
||||
#include "mongo/db/repl/repl_coordinator_global.h"
|
||||
#include "mongo/db/repl/repl_coordinator_legacy.h"
|
||||
#include "mongo/db/repl/repl_settings.h"
|
||||
#include "mongo/db/restapi.h"
|
||||
#include "mongo/db/server_parameters.h"
|
||||
@ -738,22 +736,6 @@ MONGO_INITIALIZER_GENERAL(CreateAuthorizationManager,
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
namespace {
|
||||
repl::ReplSettings globalReplSettings;
|
||||
} // namespace
|
||||
|
||||
namespace mongo {
|
||||
void setGlobalReplSettings(const repl::ReplSettings& settings) {
|
||||
globalReplSettings = settings;
|
||||
}
|
||||
} // namespace mongo
|
||||
|
||||
MONGO_INITIALIZER_WITH_PREREQUISITES(CreateReplicationManager, ("SetGlobalEnvironment"))
|
||||
(InitializerContext* context) {
|
||||
repl::setGlobalReplicationCoordinator(new repl::LegacyReplicationCoordinator(globalReplSettings));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
#ifdef MONGO_SSL
|
||||
MONGO_INITIALIZER_GENERAL(setSSLManagerType,
|
||||
MONGO_NO_PREREQUISITES,
|
||||
|
@ -43,6 +43,4 @@ namespace repl {
|
||||
|
||||
extern void (*snmpInit)();
|
||||
|
||||
void setGlobalReplSettings(const repl::ReplSettings& settings);
|
||||
|
||||
} // namespace mongo
|
||||
|
@ -1181,4 +1181,16 @@ namespace mongo {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
namespace {
|
||||
repl::ReplSettings globalReplSettings;
|
||||
} // namespace
|
||||
|
||||
void setGlobalReplSettings(const repl::ReplSettings& settings) {
|
||||
globalReplSettings = settings;
|
||||
}
|
||||
|
||||
const repl::ReplSettings& getGlobalReplSettings() {
|
||||
return globalReplSettings;
|
||||
}
|
||||
|
||||
} // namespace mongo
|
||||
|
@ -85,4 +85,7 @@ namespace mongo {
|
||||
StatusWith<repl::ReplSettings> parseMongodReplicationOptions(const moe::Environment& params);
|
||||
|
||||
Status storeMongodOptions(const moe::Environment& params, const std::vector<std::string>& args);
|
||||
|
||||
void setGlobalReplSettings(const repl::ReplSettings& settings);
|
||||
const repl::ReplSettings& getGlobalReplSettings();
|
||||
}
|
||||
|
59
src/mongo/db/repl/replication_initializer_impl.cpp
Normal file
59
src/mongo/db/repl/replication_initializer_impl.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright (C) 2014 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.
|
||||
*/
|
||||
|
||||
#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kReplication
|
||||
|
||||
#include "mongo/platform/basic.h"
|
||||
|
||||
#include "mongo/base/init.h"
|
||||
#include "mongo/base/status.h"
|
||||
#include "mongo/db/mongod_options.h"
|
||||
#include "mongo/db/repl/repl_coordinator_external_state_impl.h"
|
||||
#include "mongo/db/repl/repl_coordinator_impl.h"
|
||||
#include "mongo/db/repl/repl_coordinator_global.h"
|
||||
#include "mongo/db/repl/repl_settings.h"
|
||||
#include "mongo/db/repl/network_interface_impl.h"
|
||||
#include "mongo/db/repl/topology_coordinator_impl.h"
|
||||
#include "mongo/util/time_support.h"
|
||||
|
||||
namespace mongo {
|
||||
namespace {
|
||||
|
||||
MONGO_INITIALIZER_WITH_PREREQUISITES(CreateReplicationManager, ("SetGlobalEnvironment"))
|
||||
(InitializerContext* context) {
|
||||
repl::setGlobalReplicationCoordinator(new repl::ReplicationCoordinatorImpl(
|
||||
getGlobalReplSettings(),
|
||||
new repl::ReplicationCoordinatorExternalStateImpl,
|
||||
new repl::NetworkInterfaceImpl,
|
||||
new repl::TopologyCoordinatorImpl(Seconds(repl::maxSyncSourceLagSecs)),
|
||||
static_cast<int64_t>(curTimeMillis64())));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace mongo
|
50
src/mongo/db/repl/replication_initializer_legacy.cpp
Normal file
50
src/mongo/db/repl/replication_initializer_legacy.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (C) 2014 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.
|
||||
*/
|
||||
|
||||
#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kReplication
|
||||
|
||||
#include "mongo/platform/basic.h"
|
||||
|
||||
#include "mongo/base/init.h"
|
||||
#include "mongo/db/mongod_options.h"
|
||||
#include "mongo/db/repl/repl_coordinator_global.h"
|
||||
#include "mongo/db/repl/repl_coordinator_legacy.h"
|
||||
#include "mongo/db/repl/repl_settings.h"
|
||||
|
||||
namespace mongo {
|
||||
namespace {
|
||||
|
||||
MONGO_INITIALIZER_WITH_PREREQUISITES(CreateReplicationManager, ("SetGlobalEnvironment"))
|
||||
(InitializerContext* context) {
|
||||
repl::setGlobalReplicationCoordinator(
|
||||
new repl::LegacyReplicationCoordinator(getGlobalReplSettings()));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace mongo
|
Loading…
Reference in New Issue
Block a user