gizzmo 0.11.2 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/gizzmo.gemspec +8 -4
- data/lib/gizzard.rb +1 -0
- data/lib/gizzard/commands.rb +84 -103
- data/lib/gizzard/nameserver.rb +24 -3
- data/lib/gizzard/rebalancer.rb +125 -0
- data/lib/gizzard/thrift.rb +4 -2
- data/lib/gizzard/transformation.rb +36 -5
- data/lib/gizzard/transformation_scheduler.rb +19 -16
- data/lib/gizzmo.rb +20 -20
- data/test/gizzmo_spec.rb +251 -130
- data/test/nameserver_spec.rb +1 -1
- data/test/scheduler_spec.rb +10 -10
- data/test/spec_helper.rb +26 -5
- data/test/test_server/project/build/Project.scala +1 -1
- data/test/test_server/project/plugins/Plugins.scala +1 -1
- data/test/transformation_spec.rb +8 -0
- metadata +16 -4
data/test/nameserver_spec.rb
CHANGED
@@ -96,7 +96,7 @@ describe Gizzard::Nameserver::Manifest do
|
|
96
96
|
@nameserver = Gizzard::Nameserver.new("localhost:1234")
|
97
97
|
@state = Object.new
|
98
98
|
|
99
|
-
mock(@nameserver).dump_nameserver(0) { @state }
|
99
|
+
mock(@nameserver).dump_nameserver([0]) { [@state] }
|
100
100
|
mock(@state).forwardings { @forwardings }
|
101
101
|
mock(@state).links { @links }
|
102
102
|
mock(@state).shards { @shardinfos }
|
data/test/scheduler_spec.rb
CHANGED
@@ -15,17 +15,17 @@ describe Gizzard::Transformation::Scheduler do
|
|
15
15
|
shards = [info('127.0.0.1', 't_0_0001', 'TestShard')]
|
16
16
|
mock(@nameserver).get_busy_shards { shards }
|
17
17
|
|
18
|
-
@scheduler.busy_shards.should == shards.map {|s| s.id }
|
19
|
-
@scheduler.busy_shards.should == shards.map {|s| s.id }
|
18
|
+
@scheduler.busy_shards.should == shards.map {|s| s.id }.to_set
|
19
|
+
@scheduler.busy_shards.should == shards.map {|s| s.id }.to_set
|
20
20
|
end
|
21
21
|
|
22
22
|
it "resets after calling reload_busy_shards" do
|
23
23
|
shards = [info('127.0.0.1', 't_0_0001', 'TestShard')]
|
24
24
|
mock(@nameserver).get_busy_shards { shards }.twice
|
25
25
|
|
26
|
-
@scheduler.busy_shards.should == shards.map {|s| s.id }
|
26
|
+
@scheduler.busy_shards.should == shards.map {|s| s.id }.to_set
|
27
27
|
@scheduler.reload_busy_shards
|
28
|
-
@scheduler.busy_shards.should == shards.map {|s| s.id }
|
28
|
+
@scheduler.busy_shards.should == shards.map {|s| s.id }.to_set
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -35,15 +35,15 @@ describe Gizzard::Transformation::Scheduler do
|
|
35
35
|
stub(@nameserver).get_busy_shards { shards }
|
36
36
|
@scheduler = Gizzard::Transformation::Scheduler.new(@nameserver, 't', @transformations, :copies_per_host => 2)
|
37
37
|
|
38
|
-
@scheduler.busy_hosts.should ==
|
38
|
+
@scheduler.busy_hosts.should == Set.new
|
39
39
|
|
40
40
|
shards = [info('127.0.0.1', 't_0_0001', 'TestShard')]
|
41
41
|
@scheduler.reload_busy_shards
|
42
|
-
@scheduler.busy_hosts.should ==
|
42
|
+
@scheduler.busy_hosts.should == Set.new
|
43
43
|
|
44
44
|
shards = [info('127.0.0.1', 't_0_0001', 'TestShard'), info('127.0.0.1', 't_0_0002', 'TestShard')]
|
45
45
|
@scheduler.reload_busy_shards
|
46
|
-
@scheduler.busy_hosts.should == ['127.0.0.1']
|
46
|
+
@scheduler.busy_hosts.should == ['127.0.0.1'].to_set
|
47
47
|
end
|
48
48
|
|
49
49
|
it "respects passed in extra hosts" do
|
@@ -51,9 +51,9 @@ describe Gizzard::Transformation::Scheduler do
|
|
51
51
|
stub(@nameserver).get_busy_shards { shards }
|
52
52
|
@scheduler = Gizzard::Transformation::Scheduler.new(@nameserver, 't', @transformations, :copies_per_host => 2)
|
53
53
|
|
54
|
-
@scheduler.busy_hosts.should ==
|
55
|
-
@scheduler.busy_hosts(["127.0.0.1"]).should ==
|
56
|
-
@scheduler.busy_hosts(["127.0.0.1", "127.0.0.1"]).should == ["127.0.0.1"]
|
54
|
+
@scheduler.busy_hosts.should == Set.new
|
55
|
+
@scheduler.busy_hosts(["127.0.0.1"]).should == Set.new
|
56
|
+
@scheduler.busy_hosts(["127.0.0.1", "127.0.0.1"]).should == ["127.0.0.1"].to_set
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
data/test/spec_helper.rb
CHANGED
@@ -11,6 +11,13 @@ JOB_PORT = 7921
|
|
11
11
|
SERVICE_DATABASE = 'gizzard_test_integration'
|
12
12
|
NAMESERVER_DATABASE = 'gizzard_test_integration_ns'
|
13
13
|
|
14
|
+
class Object
|
15
|
+
def T; p self; self end
|
16
|
+
end
|
17
|
+
|
18
|
+
class NilClass
|
19
|
+
def T; p self; self end
|
20
|
+
end
|
14
21
|
|
15
22
|
require 'rubygems'
|
16
23
|
require 'spec'
|
@@ -78,6 +85,8 @@ def reset_nameserver(db = NAMESERVER_DATABASE)
|
|
78
85
|
$mysql.query("delete from `#{db}`.shard_children")
|
79
86
|
$mysql.query("delete from `#{db}`.forwardings")
|
80
87
|
$mysql.query("delete from `#{db}`.hosts")
|
88
|
+
|
89
|
+
nameserver.reload_config rescue nil
|
81
90
|
end
|
82
91
|
|
83
92
|
def reset_databases!
|
@@ -89,8 +98,7 @@ def reset_databases!
|
|
89
98
|
rescue MysqlError
|
90
99
|
|
91
100
|
begin
|
92
|
-
|
93
|
-
m.rebuild_schema
|
101
|
+
nameserver.rebuild_schema
|
94
102
|
rescue Errno::ECONNREFUSED
|
95
103
|
end
|
96
104
|
end
|
@@ -99,7 +107,7 @@ end
|
|
99
107
|
def read_nameserver_db(db = NAMESERVER_DATABASE)
|
100
108
|
{ :shards => map_rs($mysql.query("select * from `#{db}`.shards"), &method(:as_shard)),
|
101
109
|
:links => map_rs($mysql.query("select * from `#{db}`.shard_children"), &method(:as_link)),
|
102
|
-
:forwardings => map_rs($mysql.query("select * from `#{db}`.forwardings"), &method(:as_forwarding)),
|
110
|
+
:forwardings => map_rs($mysql.query("select * from `#{db}`.forwardings where deleted = 0"), &method(:as_forwarding)),
|
103
111
|
:hosts => map_rs($mysql.query("select * from `#{db}`.hosts"), &method(:as_host)) }
|
104
112
|
end
|
105
113
|
|
@@ -129,11 +137,24 @@ def as_host(h)
|
|
129
137
|
Gizzard::Host.new(h['hostname'], h['port'].to_i, h['cluster'], h['status'].to_i)
|
130
138
|
end
|
131
139
|
|
140
|
+
def gizzmo(cmd)
|
141
|
+
result = `cd #{ROOT_DIR} && ruby -rubygems -Ilib bin/gizzmo -H localhost -P #{MANAGER_PORT} #{cmd} 2>&1`
|
142
|
+
puts result if ENV['GIZZMO_OUTPUT']
|
143
|
+
result
|
144
|
+
end
|
145
|
+
|
146
|
+
def nameserver
|
147
|
+
@nameserver ||= Gizzard::Nameserver.new('localhost:' + MANAGER_PORT.to_s)
|
148
|
+
end
|
149
|
+
|
150
|
+
alias ns nameserver
|
132
151
|
|
133
152
|
# setup
|
134
153
|
|
135
154
|
mysql_connect!("localhost", '', '')
|
136
155
|
reset_databases!
|
137
|
-
start_test_server!
|
138
156
|
|
139
|
-
|
157
|
+
unless ENV['EXTERNAL_TEST_SERVER']
|
158
|
+
start_test_server!
|
159
|
+
at_exit { stop_test_server! }
|
160
|
+
end
|
@@ -7,7 +7,7 @@ class GizzmoServerProject(info: ProjectInfo) extends StandardProject(info) {
|
|
7
7
|
override def filterScalaJars = false
|
8
8
|
|
9
9
|
val scalaTools = "org.scala-lang" % "scala-compiler" % "2.7.7"
|
10
|
-
val gizzard = "com.twitter" % "gizzard" % "1.6-
|
10
|
+
val gizzard = "com.twitter" % "gizzard" % "1.6-fr-SNAPSHOT"
|
11
11
|
|
12
12
|
val specs = "org.scala-tools.testing" % "specs" % "1.6.2.1" % "test"
|
13
13
|
}
|
@@ -2,5 +2,5 @@ import sbt._
|
|
2
2
|
|
3
3
|
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
|
4
4
|
val twitterMaven = "twitter.com" at "http://maven.twttr.com/"
|
5
|
-
val defaultProject = "com.twitter" % "standard-project" % "0.7.
|
5
|
+
val defaultProject = "com.twitter" % "standard-project" % "0.7.17"
|
6
6
|
}
|
data/test/transformation_spec.rb
CHANGED
@@ -39,6 +39,14 @@ describe Gizzard::Transformation do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
describe "eql?" do
|
43
|
+
it "is true for two transformation involving equivalent templates" do
|
44
|
+
templates = lambda { ["SqlShard(host1)", "SqlShard(host2)"].map {|s| mk_template s } }
|
45
|
+
Gizzard::Transformation.new(*templates.call).should.eql? Gizzard::Transformation.new(*templates.call)
|
46
|
+
Gizzard::Transformation.new(*templates.call).hash.should.eql? Gizzard::Transformation.new(*templates.call).hash
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
# internal method tests
|
43
51
|
|
44
52
|
describe "operations" do
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gizzmo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 53
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 11
|
8
|
-
-
|
9
|
-
version: 0.11.
|
9
|
+
- 3
|
10
|
+
version: 0.11.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Kyle Maxwell
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-26 00:00:00 -08:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
@@ -42,6 +43,7 @@ files:
|
|
42
43
|
- lib/gizzard/digest.rb
|
43
44
|
- lib/gizzard/migrator.rb
|
44
45
|
- lib/gizzard/nameserver.rb
|
46
|
+
- lib/gizzard/rebalancer.rb
|
45
47
|
- lib/gizzard/shard_template.rb
|
46
48
|
- lib/gizzard/thrift.rb
|
47
49
|
- lib/gizzard/transformation.rb
|
@@ -83,6 +85,9 @@ files:
|
|
83
85
|
- test/test_server/src/main/scala/TestServer.scala
|
84
86
|
- test/test_server/src/main/thrift/TestServer.thrift
|
85
87
|
- test/transformation_spec.rb
|
88
|
+
- test/test_server/target/gen-rb/test_server.rb
|
89
|
+
- test/test_server/target/gen-rb/test_server_constants.rb
|
90
|
+
- test/test_server/target/gen-rb/test_server_types.rb
|
86
91
|
has_rdoc: true
|
87
92
|
homepage: http://github.com/twitter/gizzmo
|
88
93
|
licenses: []
|
@@ -93,23 +98,27 @@ rdoc_options:
|
|
93
98
|
require_paths:
|
94
99
|
- lib
|
95
100
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
96
102
|
requirements:
|
97
103
|
- - ">="
|
98
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 3
|
99
106
|
segments:
|
100
107
|
- 0
|
101
108
|
version: "0"
|
102
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
103
111
|
requirements:
|
104
112
|
- - ">="
|
105
113
|
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
106
115
|
segments:
|
107
116
|
- 0
|
108
117
|
version: "0"
|
109
118
|
requirements: []
|
110
119
|
|
111
120
|
rubyforge_project:
|
112
|
-
rubygems_version: 1.3.
|
121
|
+
rubygems_version: 1.3.7
|
113
122
|
signing_key:
|
114
123
|
specification_version: 3
|
115
124
|
summary: Gizzmo is a command-line client for managing gizzard clusters.
|
@@ -120,4 +129,7 @@ test_files:
|
|
120
129
|
- test/scheduler_spec.rb
|
121
130
|
- test/shard_template_spec.rb
|
122
131
|
- test/spec_helper.rb
|
132
|
+
- test/test_server/target/gen-rb/test_server.rb
|
133
|
+
- test/test_server/target/gen-rb/test_server_constants.rb
|
134
|
+
- test/test_server/target/gen-rb/test_server_types.rb
|
123
135
|
- test/transformation_spec.rb
|