diff options
author | Shaun Verch <shaun.verch@mongodb.com> | 2014-03-28 11:00:46 -0400 |
---|---|---|
committer | Shaun Verch <shaun.verch@mongodb.com> | 2014-03-28 13:49:45 -0400 |
commit | 8af90cc7e196a63791e0b1b30c49e3f7b96bf4dc (patch) | |
tree | b8d59cc3852aed38831b5b3f1d5905bcebc94a57 | |
parent | f9841e0136d9f7a667662581cda9ce9ddfbf20d8 (diff) | |
download | mongo-8af90cc7e196a63791e0b1b30c49e3f7b96bf4dc.tar.gz |
SERVER-13379 Canonicalize noAutoSplit as sharding.autoSplit
(cherry picked from commit a574286b4f6d487bc18b214fba8aec5a0f64de66)
-rw-r--r-- | jstests/libs/config_files/enable_autosplit.json | 5 | ||||
-rw-r--r-- | jstests/sharding/sharding_options.js | 69 | ||||
-rw-r--r-- | src/mongo/s/mongos_options.cpp | 24 |
3 files changed, 82 insertions, 16 deletions
diff --git a/jstests/libs/config_files/enable_autosplit.json b/jstests/libs/config_files/enable_autosplit.json new file mode 100644 index 00000000000..a0d4f8af1be --- /dev/null +++ b/jstests/libs/config_files/enable_autosplit.json @@ -0,0 +1,5 @@ +{ + "sharding" : { + "autoSplit" : true + } +} diff --git a/jstests/sharding/sharding_options.js b/jstests/sharding/sharding_options.js index bce2ed70bf4..fc410e33d0f 100644 --- a/jstests/sharding/sharding_options.js +++ b/jstests/sharding/sharding_options.js @@ -10,7 +10,7 @@ function removeOptionsAddedByFramework(getCmdLineOptsResult) { return getCmdLineOptsResult; } -function testGetCmdLineOpts(mongoRunnerConfig, expectedResult) { +function testGetCmdLineOptsMongod(mongoRunnerConfig, expectedResult) { // Start mongod with options var mongod = MongoRunner.runMongod(mongoRunnerConfig); @@ -29,6 +29,36 @@ function testGetCmdLineOpts(mongoRunnerConfig, expectedResult) { MongoRunner.stopMongod(mongod.port); } +function testGetCmdLineOptsMongos(mongoRunnerConfig, expectedResult) { + + // Start mongod with options + var mongod = MongoRunner.runMongod(); + + // Add configdb option + mongoRunnerConfig['configdb'] = mongod.host; + + // Start mongos connected to mongod + var mongos = MongoRunner.runMongos(mongoRunnerConfig); + + // Get the parsed options + var getCmdLineOptsResult = mongos.adminCommand("getCmdLineOpts"); + printjson(getCmdLineOptsResult); + + // Remove options added by the test framework + getCmdLineOptsResult = removeOptionsAddedByFramework(getCmdLineOptsResult); + + // Remove the configdb option + delete getCmdLineOptsResult.parsed.sharding.configDB; + + // Make sure the options are equal to what we expect + assert.docEq(getCmdLineOptsResult.parsed, expectedResult.parsed); + + // Cleanup + MongoRunner.stopMongod(mongod.port); + MongoRunner.stopMongos(mongos.port); +} + + // Move Paranoia jsTest.log("Testing \"moveParanoia\" command line option"); var expectedResult = { @@ -38,7 +68,7 @@ var expectedResult = { } } }; -testGetCmdLineOpts({ moveParanoia : "" }, expectedResult); +testGetCmdLineOptsMongod({ moveParanoia : "" }, expectedResult); jsTest.log("Testing \"noMoveParanoia\" command line option"); expectedResult = { @@ -48,7 +78,7 @@ expectedResult = { } } }; -testGetCmdLineOpts({ noMoveParanoia : "" }, expectedResult); +testGetCmdLineOptsMongod({ noMoveParanoia : "" }, expectedResult); jsTest.log("Testing \"sharding.archiveMovedChunks\" config file option"); expectedResult = { @@ -59,7 +89,7 @@ expectedResult = { } } }; -testGetCmdLineOpts({ config : "jstests/libs/config_files/enable_paranoia.json" }, expectedResult); +testGetCmdLineOptsMongod({ config : "jstests/libs/config_files/enable_paranoia.json" }, expectedResult); @@ -72,7 +102,7 @@ var expectedResult = { } } }; -testGetCmdLineOpts({ configsvr : "" }, expectedResult); +testGetCmdLineOptsMongod({ configsvr : "" }, expectedResult); jsTest.log("Testing \"shardsvr\" command line option"); expectedResult = { @@ -82,7 +112,7 @@ expectedResult = { } } }; -testGetCmdLineOpts({ shardsvr : "" }, expectedResult); +testGetCmdLineOptsMongod({ shardsvr : "" }, expectedResult); jsTest.log("Testing \"sharding.clusterRole\" config file option"); expectedResult = { @@ -93,13 +123,32 @@ expectedResult = { } } }; -testGetCmdLineOpts({ config : "jstests/libs/config_files/set_shardingrole.json" }, expectedResult); +testGetCmdLineOptsMongod({ config : "jstests/libs/config_files/set_shardingrole.json" }, expectedResult); + + + +// Auto Splitting +jsTest.log("Testing \"noAutoSplit\" command line option"); +var expectedResult = { + "parsed" : { + "sharding" : { + "autoSplit" : false + } + } +}; +testGetCmdLineOptsMongos({ noAutoSplit : "" }, expectedResult); -jsTest.log("Testing with no explicit sharding option setting"); +jsTest.log("Testing \"sharding.autoSplit\" config file option"); expectedResult = { - "parsed" : { } + "parsed" : { + "config" : "jstests/libs/config_files/enable_autosplit.json", + "sharding" : { + "autoSplit" : true + } + } }; -testGetCmdLineOpts({}, expectedResult); +testGetCmdLineOptsMongos({ config : "jstests/libs/config_files/enable_autosplit.json" }, + expectedResult); diff --git a/src/mongo/s/mongos_options.cpp b/src/mongo/s/mongos_options.cpp index 8dce0117f94..024701912d6 100644 --- a/src/mongo/s/mongos_options.cpp +++ b/src/mongo/s/mongos_options.cpp @@ -176,6 +176,19 @@ namespace mongo { } #endif + // "sharding.autoSplit" comes from the config file, so override it if "noAutoSplit" is set + // since that comes from the command line. + if (params->count("noAutoSplit")) { + Status ret = params->set("sharding.autoSplit", moe::Value(false)); + if (!ret.isOK()) { + return ret; + } + ret = params->remove("noAutoSplit"); + if (!ret.isOK()) { + return ret; + } + } + return Status::OK(); } @@ -225,12 +238,11 @@ namespace mongo { // This option currently has no effect for mongos } - // --noAutoSplit is on the command line, while sharding.autoSplit is in the JSON config. - // Disable auto splitting if either one specifies that we should. - if (params.count("noAutoSplit") || - (params.count("sharding.autoSplit") && !params["sharding.autoSplit"].as<bool>())) { - warning() << "running with auto-splitting disabled" << endl; - Chunk::ShouldAutoSplit = false; + if (params.count("sharding.autoSplit")) { + Chunk::ShouldAutoSplit = params["sharding.autoSplit"].as<bool>(); + if (Chunk::ShouldAutoSplit == false) { + warning() << "running with auto-splitting disabled" << endl; + } } if ( ! params.count( "sharding.configDB" ) ) { |