gizzmo 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/gizzmo.gemspec +2 -1
- data/lib/gizzard/commands.rb +21 -0
- data/lib/gizzmo.rb +15 -0
- data/test/expected/forwardings.txt +1 -0
- data/test/test.sh +6 -20
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/gizzmo.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{gizzmo}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kyle Maxwell"]
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
"test/expected/dry-wrap-table_b_0.txt",
|
37
37
|
"test/expected/empty-file.txt",
|
38
38
|
"test/expected/find-only-sql-shard-type.txt",
|
39
|
+
"test/expected/forwardings.txt",
|
39
40
|
"test/expected/help-info.txt",
|
40
41
|
"test/expected/info.txt",
|
41
42
|
"test/expected/links-for-replicating_table_b_0.txt",
|
data/lib/gizzard/commands.rb
CHANGED
@@ -24,6 +24,27 @@ module Gizzard
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
class AddforwardingCommand < Command
|
28
|
+
def run
|
29
|
+
help! if argv.length != 3
|
30
|
+
table_id, base_id, shard_id_text = argv
|
31
|
+
shard_id = ShardId.parse(shard_id_text)
|
32
|
+
service.set_forwarding(Forwarding.new(table_id.to_i, base_id.to_i, shard_id))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class ForwardingsCommand < Command
|
37
|
+
def run
|
38
|
+
service.get_forwardings().sort_by do |f|
|
39
|
+
[ ((f.table_id.abs << 1) + (f.table_id < 0 ? 1 : 0)), f.base_id ]
|
40
|
+
end.reject do |forwarding|
|
41
|
+
@command_options.table_ids && !@command_options.table_ids.include?(forwarding.table_id)
|
42
|
+
end.each do |forwarding|
|
43
|
+
puts [ forwarding.table_id, forwarding.base_id, forwarding.shard_id.to_unix ].join("\t")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
27
48
|
class SubtreeCommand < Command
|
28
49
|
def run
|
29
50
|
@roots = []
|
data/lib/gizzmo.rb
CHANGED
@@ -46,6 +46,17 @@ subcommands = {
|
|
46
46
|
'delete' => OptionParser.new do |opts|
|
47
47
|
opts.banner = "Usage: #{$0} delete SHARD_ID_TO_DELETE [MORE SHARD_IDS]"
|
48
48
|
end,
|
49
|
+
'addforwarding' => OptionParser.new do |opts|
|
50
|
+
opts.banner = "Usage: #{$0} addforwarding TABLE_ID BASE_ID SHARD_ID"
|
51
|
+
end,
|
52
|
+
'forwardings' => OptionParser.new do |opts|
|
53
|
+
opts.banner = "Usage: #{$0} show [options]"
|
54
|
+
|
55
|
+
opts.on("-t", "--tables=IDS", "Show only the specified table ids (comma separated)") do |table_ids|
|
56
|
+
subcommand_options.table_ids ||= []
|
57
|
+
subcommand_options.table_ids += table_ids.split(",").map { |s| s.to_i }
|
58
|
+
end
|
59
|
+
end,
|
49
60
|
'unwrap' => OptionParser.new do |opts|
|
50
61
|
opts.banner = "Usage: #{$0} unwrap SHARD_ID_TO_REMOVE [MORE SHARD_IDS]"
|
51
62
|
end,
|
@@ -110,6 +121,10 @@ global = OptionParser.new do |opts|
|
|
110
121
|
opts.on("-L", "--log=LOG_FILE", "Path to LOG_FILE") do |file|
|
111
122
|
global_options.log = file
|
112
123
|
end
|
124
|
+
|
125
|
+
opts.on("-f", "--force", "Don't display confirmation dialogs") do |force|
|
126
|
+
global_options.force = force
|
127
|
+
end
|
113
128
|
end
|
114
129
|
|
115
130
|
# Print banner if no args
|
@@ -0,0 +1 @@
|
|
1
|
+
1 0 localhost/table_a_3
|
data/test/test.sh
CHANGED
@@ -4,25 +4,13 @@ function g {
|
|
4
4
|
# echo "> g $@" >&2
|
5
5
|
../bin/gizzmo -Cconfig.yaml "$@" 2>&1
|
6
6
|
}
|
7
|
+
|
7
8
|
function expect {
|
8
9
|
diff -u - "expected/$1" && echo " success." || echo " failed." && exit 1
|
9
10
|
}
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
if ["$FLOCK_ENV" -eq ""]; then
|
14
|
-
FLOCK_ENV=development
|
15
|
-
fi
|
16
|
-
|
17
|
-
for i in 1 2
|
18
|
-
do
|
19
|
-
for type in edges groups
|
20
|
-
do
|
21
|
-
db="flock_${type}_${FLOCK_ENV}_${i}"
|
22
|
-
echo "drop database if exists $db; create database $db; " | mysql -u"$DB_USERNAME" --password="$DB_PASSWORD"
|
23
|
-
cat recreate.sql | mysql -u"$DB_USERNAME" --password="$DB_PASSWORD" "$db"
|
24
|
-
done
|
25
|
-
done
|
12
|
+
g find -hlocalhost | xargs ../bin/gizzmo -Cconfig.yaml delete
|
13
|
+
g find -hlocalhost | expect empty-file.txt
|
26
14
|
|
27
15
|
for i in {0..9}
|
28
16
|
do
|
@@ -37,7 +25,9 @@ for i in `g find -h localhost`; do g info $i; done | expect info.txt
|
|
37
25
|
g find -hlocalhost | expect original-find.txt
|
38
26
|
g find -hlocalhost -tSqlShard | expect find-only-sql-shard-type.txt
|
39
27
|
|
40
|
-
|
28
|
+
g addforwarding 1 0 localhost/table_a_3
|
29
|
+
g forwardings | expect forwardings.txt
|
30
|
+
g unforward 1 0 localhost/table_a_3
|
41
31
|
|
42
32
|
g -D wrap com.twitter.service.flock.edges.ReplicatingShard localhost/table_b_0 | expect dry-wrap-table_b_0.txt
|
43
33
|
g wrap com.twitter.service.flock.edges.ReplicatingShard localhost/table_b_0 | expect wrap-table_b_0.txt
|
@@ -54,7 +44,3 @@ g links localhost/table_b_0 | expect empty-file.txt
|
|
54
44
|
|
55
45
|
g wrap com.twitter.gizzard.shards.BlockedShard localhost/table_a_3
|
56
46
|
g find -hlocalhost | xargs ../bin/gizzmo -Cconfig.yaml subtree 2>&1 | expect subtree.txt
|
57
|
-
|
58
|
-
g find -hlocalhost | xargs ../bin/gizzmo -Cconfig.yaml delete
|
59
|
-
g find -hlocalhost | expect empty-file.txt
|
60
|
-
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kyle Maxwell
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- test/expected/dry-wrap-table_b_0.txt
|
46
46
|
- test/expected/empty-file.txt
|
47
47
|
- test/expected/find-only-sql-shard-type.txt
|
48
|
+
- test/expected/forwardings.txt
|
48
49
|
- test/expected/help-info.txt
|
49
50
|
- test/expected/info.txt
|
50
51
|
- test/expected/links-for-replicating_table_b_0.txt
|