gizzmo 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/test/config.yaml ADDED
@@ -0,0 +1,2 @@
1
+ host: localhost
2
+ port: 7917
@@ -0,0 +1,5 @@
1
+ Skipped writing: create_shard(localhost/replicating_table_b_0)
2
+ Skipped writing: add_link(localhost/replicating_table_b_0, localhost/table_b_0, 1)
3
+ Skipped writing: add_link(localhost/table_repl_0, localhost/replicating_table_b_0, 1)
4
+ Skipped writing: remove_link(localhost/table_repl_0, localhost/table_b_0)
5
+ localhost/replicating_table_b_0
File without changes
@@ -0,0 +1,20 @@
1
+ localhost/table_a_0
2
+ localhost/table_a_1
3
+ localhost/table_a_2
4
+ localhost/table_a_3
5
+ localhost/table_a_4
6
+ localhost/table_a_5
7
+ localhost/table_a_6
8
+ localhost/table_a_7
9
+ localhost/table_a_8
10
+ localhost/table_a_9
11
+ localhost/table_b_0
12
+ localhost/table_b_1
13
+ localhost/table_b_2
14
+ localhost/table_b_3
15
+ localhost/table_b_4
16
+ localhost/table_b_5
17
+ localhost/table_b_6
18
+ localhost/table_b_7
19
+ localhost/table_b_8
20
+ localhost/table_b_9
@@ -0,0 +1 @@
1
+ Usage: ../../../script/gizzmo info SHARD_ID [MORE SHARD_IDS...]
@@ -0,0 +1,30 @@
1
+ localhost/table_a_0 com.twitter.service.flock.edges.SqlShard unbusy
2
+ localhost/table_a_1 com.twitter.service.flock.edges.SqlShard unbusy
3
+ localhost/table_a_2 com.twitter.service.flock.edges.SqlShard unbusy
4
+ localhost/table_a_3 com.twitter.service.flock.edges.SqlShard unbusy
5
+ localhost/table_a_4 com.twitter.service.flock.edges.SqlShard unbusy
6
+ localhost/table_a_5 com.twitter.service.flock.edges.SqlShard unbusy
7
+ localhost/table_a_6 com.twitter.service.flock.edges.SqlShard unbusy
8
+ localhost/table_a_7 com.twitter.service.flock.edges.SqlShard unbusy
9
+ localhost/table_a_8 com.twitter.service.flock.edges.SqlShard unbusy
10
+ localhost/table_a_9 com.twitter.service.flock.edges.SqlShard unbusy
11
+ localhost/table_b_0 com.twitter.service.flock.edges.SqlShard unbusy
12
+ localhost/table_b_1 com.twitter.service.flock.edges.SqlShard unbusy
13
+ localhost/table_b_2 com.twitter.service.flock.edges.SqlShard unbusy
14
+ localhost/table_b_3 com.twitter.service.flock.edges.SqlShard unbusy
15
+ localhost/table_b_4 com.twitter.service.flock.edges.SqlShard unbusy
16
+ localhost/table_b_5 com.twitter.service.flock.edges.SqlShard unbusy
17
+ localhost/table_b_6 com.twitter.service.flock.edges.SqlShard unbusy
18
+ localhost/table_b_7 com.twitter.service.flock.edges.SqlShard unbusy
19
+ localhost/table_b_8 com.twitter.service.flock.edges.SqlShard unbusy
20
+ localhost/table_b_9 com.twitter.service.flock.edges.SqlShard unbusy
21
+ localhost/table_repl_0 com.twitter.service.flock.edges.ReplicatingShard unbusy
22
+ localhost/table_repl_1 com.twitter.service.flock.edges.ReplicatingShard unbusy
23
+ localhost/table_repl_2 com.twitter.service.flock.edges.ReplicatingShard unbusy
24
+ localhost/table_repl_3 com.twitter.service.flock.edges.ReplicatingShard unbusy
25
+ localhost/table_repl_4 com.twitter.service.flock.edges.ReplicatingShard unbusy
26
+ localhost/table_repl_5 com.twitter.service.flock.edges.ReplicatingShard unbusy
27
+ localhost/table_repl_6 com.twitter.service.flock.edges.ReplicatingShard unbusy
28
+ localhost/table_repl_7 com.twitter.service.flock.edges.ReplicatingShard unbusy
29
+ localhost/table_repl_8 com.twitter.service.flock.edges.ReplicatingShard unbusy
30
+ localhost/table_repl_9 com.twitter.service.flock.edges.ReplicatingShard unbusy
@@ -0,0 +1,2 @@
1
+ localhost/table_repl_0 localhost/replicating_table_b_0 1
2
+ localhost/replicating_table_b_0 localhost/table_b_0 1
@@ -0,0 +1 @@
1
+ localhost/replicating_table_b_0 localhost/table_b_0 1
@@ -0,0 +1,2 @@
1
+ localhost/table_repl_0 localhost/table_a_0 2
2
+ localhost/table_repl_0 localhost/replicating_table_b_0 1
@@ -0,0 +1,30 @@
1
+ localhost/table_a_0
2
+ localhost/table_a_1
3
+ localhost/table_a_2
4
+ localhost/table_a_3
5
+ localhost/table_a_4
6
+ localhost/table_a_5
7
+ localhost/table_a_6
8
+ localhost/table_a_7
9
+ localhost/table_a_8
10
+ localhost/table_a_9
11
+ localhost/table_b_0
12
+ localhost/table_b_1
13
+ localhost/table_b_2
14
+ localhost/table_b_3
15
+ localhost/table_b_4
16
+ localhost/table_b_5
17
+ localhost/table_b_6
18
+ localhost/table_b_7
19
+ localhost/table_b_8
20
+ localhost/table_b_9
21
+ localhost/table_repl_0
22
+ localhost/table_repl_1
23
+ localhost/table_repl_2
24
+ localhost/table_repl_3
25
+ localhost/table_repl_4
26
+ localhost/table_repl_5
27
+ localhost/table_repl_6
28
+ localhost/table_repl_7
29
+ localhost/table_repl_8
30
+ localhost/table_repl_9
@@ -0,0 +1,33 @@
1
+ localhost/table_repl_3
2
+ localhost/blocked_table_a_3
3
+ localhost/table_a_3
4
+ localhost/table_b_3
5
+ localhost/table_repl_0
6
+ localhost/table_a_0
7
+ localhost/table_repl_1
8
+ localhost/table_a_1
9
+ localhost/table_b_1
10
+ localhost/table_repl_2
11
+ localhost/table_a_2
12
+ localhost/table_b_2
13
+ localhost/blocked_table_a_3
14
+ localhost/table_a_3
15
+ localhost/table_repl_4
16
+ localhost/table_a_4
17
+ localhost/table_b_4
18
+ localhost/table_repl_5
19
+ localhost/table_a_5
20
+ localhost/table_b_5
21
+ localhost/table_repl_6
22
+ localhost/table_a_6
23
+ localhost/table_b_6
24
+ localhost/table_repl_7
25
+ localhost/table_a_7
26
+ localhost/table_b_7
27
+ localhost/table_repl_8
28
+ localhost/table_a_8
29
+ localhost/table_b_8
30
+ localhost/table_repl_9
31
+ localhost/table_a_9
32
+ localhost/table_b_9
33
+ localhost/table_b_0
@@ -0,0 +1 @@
1
+ localhost/table_repl_0 localhost/table_b_0 1
@@ -0,0 +1 @@
1
+ localhost/table_repl_0 localhost/table_b_0 1
@@ -0,0 +1 @@
1
+ localhost/replicating_table_b_0
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'gizzmo'
8
+
9
+ class Test::Unit::TestCase
10
+ end
data/test/recreate.sql ADDED
@@ -0,0 +1,32 @@
1
+ CREATE TABLE IF NOT EXISTS shards (
2
+ class_name VARCHAR(125) NOT NULL,
3
+ table_prefix VARCHAR(125) NOT NULL,
4
+ hostname VARCHAR(25) NOT NULL,
5
+ source_type VARCHAR(125),
6
+ destination_type VARCHAR(125),
7
+ busy TINYINT NOT NULL DEFAULT 0,
8
+
9
+ PRIMARY KEY primary_key_table_prefix_hostname (hostname, table_prefix)
10
+ ) ENGINE=INNODB;
11
+
12
+ CREATE TABLE IF NOT EXISTS shard_children (
13
+ parent_hostname VARCHAR(125) NOT NULL,
14
+ parent_table_prefix VARCHAR(125) NOT NULL,
15
+ child_hostname VARCHAR(125) NOT NULL,
16
+ child_table_prefix VARCHAR(125) NOT NULL,
17
+ weight INT NOT NULL DEFAULT 1,
18
+
19
+ PRIMARY KEY primary_key_family (parent_hostname, parent_table_prefix, child_hostname, child_table_prefix),
20
+ INDEX child (child_hostname, child_table_prefix)
21
+ ) ENGINE=INNODB;
22
+
23
+ CREATE TABLE IF NOT EXISTS forwardings (
24
+ base_source_id BIGINT NOT NULL,
25
+ table_id INT NOT NULL,
26
+ shard_hostname VARCHAR(125) NOT NULL,
27
+ shard_table_prefix VARCHAR(125) NOT NULL,
28
+
29
+ PRIMARY KEY (base_source_id, table_id),
30
+
31
+ UNIQUE unique_shard (shard_hostname, shard_table_prefix)
32
+ ) ENGINE=INNODB;
data/test/test.sh ADDED
@@ -0,0 +1,60 @@
1
+ #!/bin/bash
2
+ cd `dirname $0`
3
+ function g {
4
+ # echo "> g $@" >&2
5
+ ../bin/gizzmo -Cconfig.yaml "$@" 2>&1
6
+ }
7
+ function expect {
8
+ diff -u - "expected/$1" && echo " success." || echo " failed." && exit 1
9
+ }
10
+
11
+ # set -ex
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
26
+
27
+ for i in {0..9}
28
+ do
29
+ g create localhost "table_repl_$i" com.twitter.service.flock.edges.ReplicatingShard
30
+ g create localhost "table_a_$i" com.twitter.service.flock.edges.SqlShard --source-type="INT UNSIGNED" --destination-type="INT UNSIGNED"
31
+ g create localhost "table_b_$i" com.twitter.service.flock.edges.SqlShard --source-type="INT UNSIGNED" --destination-type="INT UNSIGNED"
32
+ g addlink "localhost/table_repl_$i" "localhost/table_a_$i" 2
33
+ g addlink "localhost/table_repl_$i" "localhost/table_b_$i" 1
34
+ done
35
+
36
+ for i in `g find -h localhost`; do g info $i; done | expect info.txt
37
+ g find -hlocalhost | expect original-find.txt
38
+ g find -hlocalhost -tSqlShard | expect find-only-sql-shard-type.txt
39
+
40
+ # Dry run this
41
+
42
+ g -D wrap com.twitter.service.flock.edges.ReplicatingShard localhost/table_b_0 | expect dry-wrap-table_b_0.txt
43
+ g wrap com.twitter.service.flock.edges.ReplicatingShard localhost/table_b_0 | expect wrap-table_b_0.txt
44
+ g wrap com.twitter.service.flock.edges.ReplicatingShard localhost/table_b_0 | expect wrap-table_b_0.txt
45
+ g links localhost/table_b_0 | expect links-for-table_b_0.txt
46
+ g links localhost/table_repl_0 | expect links-for-table_repl_0.txt
47
+ g links localhost/replicating_table_b_0 | expect links-for-replicating_table_b_0.txt
48
+
49
+ g unwrap localhost/replicating_table_b_0 | expect unwrapped-replicating_table_b_0.txt
50
+ g links localhost/table_b_0 | expect unwrapped-table_b_0.txt
51
+
52
+ g unlink localhost/table_repl_0 localhost/table_b_0 | expect empty-file.txt
53
+ g links localhost/table_b_0 | expect empty-file.txt
54
+
55
+ g wrap com.twitter.gizzard.shards.BlockedShard localhost/table_a_3
56
+ 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 ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gizzmo
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 4
9
+ version: 0.1.4
10
+ platform: ruby
11
+ authors:
12
+ - Kyle Maxwell
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-30 00:00:00 -07:00
18
+ default_executable: gizzmo
19
+ dependencies: []
20
+
21
+ description: Gizzmo is a command-line client for managing gizzard clusters.
22
+ email: kmaxwell@twitter.com
23
+ executables:
24
+ - gizzmo
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - LICENSE
29
+ - README.rdoc
30
+ files:
31
+ - .document
32
+ - .gitignore
33
+ - LICENSE
34
+ - README.rdoc
35
+ - Rakefile
36
+ - VERSION
37
+ - bin/gizzmo
38
+ - gizzmo.gemspec
39
+ - lib/gizzard.rb
40
+ - lib/gizzard/commands.rb
41
+ - lib/gizzard/thrift.rb
42
+ - lib/gizzmo.rb
43
+ - lib/vendor/thrift_client/simple.rb
44
+ - test/config.yaml
45
+ - test/expected/dry-wrap-table_b_0.txt
46
+ - test/expected/empty-file.txt
47
+ - test/expected/find-only-sql-shard-type.txt
48
+ - test/expected/help-info.txt
49
+ - test/expected/info.txt
50
+ - test/expected/links-for-replicating_table_b_0.txt
51
+ - test/expected/links-for-table_b_0.txt
52
+ - test/expected/links-for-table_repl_0.txt
53
+ - test/expected/original-find.txt
54
+ - test/expected/subtree.txt
55
+ - test/expected/unwrapped-replicating_table_b_0.txt
56
+ - test/expected/unwrapped-table_b_0.txt
57
+ - test/expected/wrap-table_b_0.txt
58
+ - test/helper.rb
59
+ - test/recreate.sql
60
+ - test/test.sh
61
+ has_rdoc: true
62
+ homepage: http://github.com/twitter/gizzmo
63
+ licenses: []
64
+
65
+ post_install_message:
66
+ rdoc_options:
67
+ - --charset=UTF-8
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project:
87
+ rubygems_version: 1.3.6
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Gizzmo is a command-line client for managing gizzard clusters.
91
+ test_files:
92
+ - test/helper.rb