Skip to content

Commit

Permalink
Revert "Revert "SERVER-18124 Move tags loading to the catalog manager""
Browse files Browse the repository at this point in the history
This reverts commit b59643c.
  • Loading branch information
kaloianm committed May 20, 2015
1 parent 15a5fcc commit 256f4ef
Show file tree
Hide file tree
Showing 23 changed files with 836 additions and 824 deletions.
57 changes: 0 additions & 57 deletions jstests/noPassthroughWithMongod/balance_tags1.js

This file was deleted.

52 changes: 0 additions & 52 deletions jstests/noPassthroughWithMongod/balance_tags2.js

This file was deleted.

66 changes: 66 additions & 0 deletions jstests/sharding/balance_tags1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Test balancing all chunks off of one shard
var s = new ShardingTest("balance_tags1", 3, 1, 1, { sync:true, chunksize : 1, nopreallocj : true });
s.config.settings.update({ _id: "balancer" }, { $set: { stopped: false }}, true);

s.adminCommand({ enablesharding: "test" });
s.ensurePrimaryShard('test', 'shard0001');

var db = s.getDB("test");

var bulk = db.foo.initializeUnorderedBulkOp();
for (i = 0; i < 21; i++) {
bulk.insert({ _id: i, x: i });
}
assert.writeOK(bulk.execute());

sh.shardCollection("test.foo", { _id : 1 });

sh.stopBalancer();

for (i = 0; i < 20; i++) {
s.adminCommand({ split : "test.foo", middle : { _id : i } });
}

sh.startBalancer();

sh.status(true);

// Wait for the initial balance to happen
assert.soon(function() {
var counts = s.chunkCounts("foo");
printjson(counts);
return counts["shard0000"] == 7 &&
counts["shard0001"] == 7 &&
counts["shard0002"] == 7;
},
"balance 1 didn't happen",
1000 * 60 * 10,
1000);

// Quick test of some shell helpers and setting up state
sh.addShardTag("shard0000", "a");
assert.eq([ "a" ] , s.config.shards.findOne({ _id : "shard0000" }).tags);

sh.addShardTag("shard0000", "b");
assert.eq([ "a" , "b" ], s.config.shards.findOne({ _id : "shard0000" }).tags);

sh.removeShardTag("shard0000", "b");
assert.eq([ "a" ], s.config.shards.findOne( { _id : "shard0000" } ).tags);

sh.addShardTag("shard0001" , "a");
sh.addTagRange("test.foo" , { _id : -1 } , { _id : 1000 } , "a");

sh.status( true );

// At this point, everything should drain off shard 2, which does not have the tag
assert.soon(function() {
var counts = s.chunkCounts("foo");
printjson(counts);
return counts["shard0002"] == 0;
},
"balance 2 didn't happen",
1000 * 60 * 10 , 1000);

printjson(sh.status());

s.stop();
62 changes: 62 additions & 0 deletions jstests/sharding/balance_tags2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Test balancing all chunks to one shard by tagging the full shard-key range on that collection
var s = new ShardingTest("balance_tags2", 3, 1, 1, { sync:true, chunksize : 1, nopreallocj : true });
s.config.settings.update({ _id: "balancer" }, { $set: { stopped: false }}, true);

s.adminCommand({ enablesharding: "test" });
s.ensurePrimaryShard('test', 'shard0001');

var db = s.getDB("test");

var bulk = db.foo.initializeUnorderedBulkOp();
for (i = 0; i < 21; i++) {
bulk.insert({ _id: i, x: i });
}
assert.writeOK(bulk.execute());

sh.shardCollection("test.foo", { _id : 1 });

sh.stopBalancer();

for (i = 0; i < 20; i++) {
sh.splitAt("test.foo", {_id : i});
}

sh.startBalancer();

sh.status(true);

// Wait for the initial balance to happen
assert.soon(function() {
var counts = s.chunkCounts("foo");
printjson(counts);
return counts["shard0000"] == 7 &&
counts["shard0001"] == 7 &&
counts["shard0002"] == 7;
},
"balance 1 didn't happen",
1000 * 60 * 10,
1000);

// Tag one shard
sh.addShardTag("shard0000" , "a");
assert.eq([ "a" ] , s.config.shards.findOne({ _id : "shard0000" }).tags);

// Tag the whole collection (ns) to one shard
sh.addTagRange("test.foo", { _id : MinKey }, { _id : MaxKey }, "a");

// Wait for things to move to that one shard
sh.status(true);

assert.soon(function() {
var counts = s.chunkCounts("foo");
printjson(counts);
return counts["shard0001"] == 0 &&
counts["shard0002"] == 0;
},
"balance 2 didn't happen",
1000 * 60 * 10,
1000);

printjson(sh.status());

s.stop();
7 changes: 1 addition & 6 deletions src/mongo/s/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ env.Library('base', ['mongo_version_range.cpp',
'type_locks.cpp',
'type_lockpings.cpp',
'type_config_version.cpp',
'type_mongos.cpp',
'type_tags.cpp'],
'type_mongos.cpp'],
LIBDEPS=['$BUILD_DIR/mongo/base/base',
'$BUILD_DIR/mongo/bson/bson'])

Expand Down Expand Up @@ -48,10 +47,6 @@ env.CppUnitTest('type_mongos_test', 'type_mongos_test.cpp',
LIBDEPS=['base',
'$BUILD_DIR/mongo/db/common'])

env.CppUnitTest('type_tags_test', 'type_tags_test.cpp',
LIBDEPS=['base',
'$BUILD_DIR/mongo/db/common'])

#
# Support for maintaining persistent sharding state and data.
#
Expand Down
Loading

0 comments on commit 256f4ef

Please sign in to comment.