Permalink
Browse files

Add support for slave shards

  • Loading branch information...
1 parent 54ce7ce commit e2d9ea372ce06b8a5b8285c5f888642cdf8206e2 @stuhood stuhood committed Apr 26, 2012
Showing with 30 additions and 11 deletions.
  1. +6 −3 lib/gizzard/nameserver.rb
  2. +24 −8 test/gizzmo_spec.rb
@@ -22,28 +22,31 @@ def parse_enumeration(table_prefix)
"ReadOnlyShard",
"WriteOnlyShard",
"BlockedShard",
+ "SlaveShard",
]
REPLICATING_SHARD_TYPES = ["ReplicatingShard", "FailingOverShard"]
TRANSITIONAL_SHARD_TYPES = ["BlockedShard"]
- INVALID_COPY_TYPES = ["ReadOnlyShard", "BlackHoleShard", "BlockedShard", "WriteOnlyShard"]
+ INVALID_COPY_TYPES = ["ReadOnlyShard", "BlackHoleShard", "BlockedShard", "WriteOnlyShard", "SlaveShard"]
SHARD_SUFFIXES = {
"FailingOverShard" => 'replicating',
"ReplicatingShard" => 'replicating',
"ReadOnlyShard" => 'read_only',
"WriteOnlyShard" => 'write_only',
- "BlockedShard" => 'blocked'
+ "BlockedShard" => 'blocked',
+ "SlaveShard" => 'slave',
}
SHARD_TAGS = {
"ReplicatingShard" => 'replicating',
"ReadOnlyShard" => 'read_only',
"WriteOnlyShard" => 'write_only',
"BlockedShard" => 'blocked',
- "BlackHoleShard" => 'blackhole'
+ "BlackHoleShard" => 'blackhole',
+ "SlaveShard" => 'slave',
}
def id; info.id end
View
@@ -78,20 +78,35 @@ def sio(string="")
ns.create_shard info("localhost", "t_0_000", "TestShard")
ns.create_shard info("localhost", "t_0_000_replicating", "ReplicatingShard")
ns.add_link id("localhost", "t_0_000_replicating"), id("localhost", "t_0_000"), 1
-
- gizzmo "wrap BlockedShard localhost/t_0_000"
end
- it "wrap wraps a shard" do
- nameserver_db[:shards].should == [info("localhost", "t_0_000", "TestShard"),
- info("localhost", "t_0_000_blocked", "BlockedShard"),
- info("localhost", "t_0_000_replicating", "ReplicatingShard")]
+ describe "wrap wraps a shard" do
+ it "with BlockedShard" do
+ gizzmo "wrap BlockedShard localhost/t_0_000"
+ nameserver_db[:shards].to_set.should == shards_with_wrapper("BlockedShard", "blocked")
+ nameserver_db[:links].to_set.should == links_with_wrapper("blocked")
+ end
- nameserver_db[:links].should == [link(id("localhost", "t_0_000_blocked"), id("localhost", "t_0_000"), 1),
- link(id("localhost", "t_0_000_replicating"), id("localhost", "t_0_000_blocked"), 1)]
+ it "with SlaveShard" do
+ gizzmo "wrap SlaveShard localhost/t_0_000"
+ nameserver_db[:shards].to_set.should == shards_with_wrapper("SlaveShard", "slave")
+ nameserver_db[:links].to_set.should == links_with_wrapper("slave")
+ end
+
+ def shards_with_wrapper(clazz, suffix)
+ [info("localhost", "t_0_000", "TestShard"),
+ info("localhost", "t_0_000_#{suffix}", clazz),
+ info("localhost", "t_0_000_replicating", "ReplicatingShard")].to_set
+ end
+
+ def links_with_wrapper(suffix)
+ [link(id("localhost", "t_0_000_#{suffix}"), id("localhost", "t_0_000"), 1),
+ link(id("localhost", "t_0_000_replicating"), id("localhost", "t_0_000_#{suffix}"), 1)].to_set
+ end
end
it "unwrap unwraps a shard" do
+ gizzmo "wrap BlockedShard localhost/t_0_000"
gizzmo "unwrap localhost/t_0_000_blocked"
nameserver_db[:shards].should == [info("localhost", "t_0_000", "TestShard"),
@@ -101,6 +116,7 @@ def sio(string="")
end
it "unwrap doesn't unwrap a top level shard or a leaf" do
+ gizzmo "wrap BlockedShard localhost/t_0_000"
gizzmo "unwrap localhost/t_0_000"
gizzmo "unwrap localhost/t_0_000_replicating"

0 comments on commit e2d9ea3

Please sign in to comment.