jetpants 0.7.10 → 0.8.0
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/README.rdoc +7 -3
- data/bin/jetpants +67 -33
- data/doc/commands.rdoc +2 -0
- data/doc/configuration.rdoc +3 -2
- data/doc/jetpants_collins.rdoc +1 -1
- data/doc/plugins.rdoc +4 -0
- data/doc/requirements.rdoc +1 -1
- data/lib/jetpants.rb +21 -4
- data/lib/jetpants/db.rb +4 -0
- data/lib/jetpants/db/client.rb +10 -4
- data/lib/jetpants/db/import_export.rb +28 -11
- data/lib/jetpants/db/privileges.rb +59 -10
- data/lib/jetpants/db/replication.rb +69 -20
- data/lib/jetpants/db/server.rb +41 -19
- data/lib/jetpants/db/state.rb +99 -8
- data/lib/jetpants/host.rb +33 -35
- data/lib/jetpants/monkeypatch.rb +9 -0
- data/lib/jetpants/pool.rb +14 -7
- data/lib/jetpants/shard.rb +10 -12
- data/lib/jetpants/table.rb +4 -0
- data/lib/jetpants/topology.rb +28 -9
- data/plugins/jetpants_collins/db.rb +12 -0
- data/plugins/jetpants_collins/jetpants_collins.rb +34 -7
- data/plugins/jetpants_collins/pool.rb +6 -2
- data/plugins/jetpants_collins/topology.rb +44 -6
- data/plugins/simple_tracker/topology.rb +1 -0
- metadata +33 -29
@@ -6,7 +6,7 @@ require 'json'
|
|
6
6
|
module Jetpants
|
7
7
|
class Topology
|
8
8
|
|
9
|
-
#####
|
9
|
+
##### METHODS THAT OTHER PLUGINS CAN OVERRIDE ##############################
|
10
10
|
|
11
11
|
# IMPORTANT NOTE
|
12
12
|
# This plugin does NOT implement write_config, since this format of
|
@@ -18,6 +18,26 @@ module Jetpants
|
|
18
18
|
# on whatever your application uses.
|
19
19
|
|
20
20
|
|
21
|
+
# Handles extra options for querying spare nodes. Takes a Collins selector
|
22
|
+
# hash and an options hash, and returns a potentially-modified Collins
|
23
|
+
# selector hash.
|
24
|
+
# The default implementation here implements no special logic. Custom plugins
|
25
|
+
# (loaded AFTER jetpants_collins is loaded) can override this method to
|
26
|
+
# manipulate the selector; see commented-out example below.
|
27
|
+
def process_spare_selector_options(selector, options)
|
28
|
+
# If you wanted to support an option of :role, and map this to the Collins
|
29
|
+
# SECONDARY_ROLE attribute, you could implement this via:
|
30
|
+
# selector[:secondary_role] = options[:role].to_s.downcase if options[:role]
|
31
|
+
# This could be useful if, for example, you use a different hardware spec
|
32
|
+
# for masters vs slaves. (doing so isn't really recommended, which is why
|
33
|
+
# we omit this logic by default.)
|
34
|
+
|
35
|
+
# return the selector
|
36
|
+
selector
|
37
|
+
end
|
38
|
+
|
39
|
+
##### METHOD OVERRIDES #####################################################
|
40
|
+
|
21
41
|
# Initializes list of pools + shards from Collins
|
22
42
|
def load_pools
|
23
43
|
# We keep a cache of Collins::Asset objects, organized as pool_name => role => [asset, asset, ...]
|
@@ -123,9 +143,9 @@ module Jetpants
|
|
123
143
|
results = Plugin::JetCollins.find selector.dup # find apparently alters the selector object now, so we dup it
|
124
144
|
done = results.count < per_page
|
125
145
|
page += 1
|
126
|
-
assets.concat
|
146
|
+
assets.concat(results.select {|a| a.pool}) # filter out any spare nodes, which will have no pool set
|
127
147
|
end
|
128
|
-
|
148
|
+
|
129
149
|
# Next we need to update our @pool_role_assets cache. But first let's set it to [] for each pool/role
|
130
150
|
# that we queried. This intentionally nukes any previous cached data, and also allows us to differentiate
|
131
151
|
# between an empty result and a cache miss.
|
@@ -229,10 +249,28 @@ module Jetpants
|
|
229
249
|
type: 'SERVER_NODE',
|
230
250
|
status: 'Provisioned',
|
231
251
|
primary_role: 'DATABASE',
|
232
|
-
size:
|
252
|
+
size: 100,
|
233
253
|
}
|
234
|
-
selector
|
235
|
-
|
254
|
+
selector = process_spare_selector_options(selector, options)
|
255
|
+
|
256
|
+
nodes = Plugin::JetCollins.find(selector)
|
257
|
+
keep_nodes = []
|
258
|
+
|
259
|
+
# Probe concurrently for speed reasons
|
260
|
+
nodes.map(&:to_db).concurrent_each(&:probe)
|
261
|
+
|
262
|
+
# Now iterate in a single-threaded way for simplicity
|
263
|
+
nodes.each do |node|
|
264
|
+
db = node.to_db
|
265
|
+
db.probe
|
266
|
+
if node.pool || !db.available? || !db.running? || !db.usable_spare?
|
267
|
+
db.output "Removed from potential spare pool for failing checks"
|
268
|
+
else
|
269
|
+
keep_nodes << node
|
270
|
+
break if keep_nodes.size >= count
|
271
|
+
end
|
272
|
+
end
|
273
|
+
keep_nodes.slice(0,count)
|
236
274
|
end
|
237
275
|
|
238
276
|
end
|
@@ -37,6 +37,7 @@ module Jetpants
|
|
37
37
|
puts "Regenerated #{config_file_path}"
|
38
38
|
end
|
39
39
|
|
40
|
+
# simple_tracker completely ignores any options like :role or :like
|
40
41
|
def claim_spares(count, options={})
|
41
42
|
raise "Not enough spare machines -- requested #{count}, only have #{@tracker.spares.count}" if @tracker.spares.count < count
|
42
43
|
hashes = @tracker.spares.shift(count)
|
metadata
CHANGED
@@ -2,16 +2,18 @@
|
|
2
2
|
name: jetpants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.8.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Evan Elias
|
9
9
|
- Dallas Marlow
|
10
|
+
- Bob Patterson Jr.
|
11
|
+
- Tom Christ
|
10
12
|
autorequire:
|
11
13
|
bindir: bin
|
12
14
|
cert_chain: []
|
13
15
|
|
14
|
-
date:
|
16
|
+
date: 2013-03-12 00:00:00 Z
|
15
17
|
dependencies:
|
16
18
|
- !ruby/object:Gem::Dependency
|
17
19
|
name: mysql2
|
@@ -105,56 +107,58 @@ description: Jetpants is an automation toolkit for handling monstrously large My
|
|
105
107
|
email:
|
106
108
|
- me@evanelias.com
|
107
109
|
- dallasmarlow@gmail.com
|
110
|
+
- bob@bobpattersonjr.com
|
111
|
+
- tbchrist@gmail.com
|
108
112
|
executables:
|
109
113
|
- jetpants
|
110
114
|
extensions: []
|
111
115
|
|
112
116
|
extra_rdoc_files:
|
113
117
|
- README.rdoc
|
114
|
-
- doc/faq.rdoc
|
115
|
-
- doc/plugins.rdoc
|
116
|
-
- doc/jetpants_collins.rdoc
|
117
|
-
- doc/requirements.rdoc
|
118
118
|
- doc/configuration.rdoc
|
119
|
+
- doc/faq.rdoc
|
119
120
|
- doc/commands.rdoc
|
121
|
+
- doc/requirements.rdoc
|
122
|
+
- doc/jetpants_collins.rdoc
|
123
|
+
- doc/plugins.rdoc
|
120
124
|
files:
|
121
125
|
- Gemfile
|
122
126
|
- README.rdoc
|
123
|
-
- doc/faq.rdoc
|
124
|
-
- doc/plugins.rdoc
|
125
|
-
- doc/jetpants_collins.rdoc
|
126
|
-
- doc/requirements.rdoc
|
127
127
|
- doc/configuration.rdoc
|
128
|
+
- doc/faq.rdoc
|
128
129
|
- doc/commands.rdoc
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
- lib/jetpants/
|
130
|
+
- doc/requirements.rdoc
|
131
|
+
- doc/jetpants_collins.rdoc
|
132
|
+
- doc/plugins.rdoc
|
133
|
+
- lib/jetpants/shard.rb
|
133
134
|
- lib/jetpants/table.rb
|
134
|
-
- lib/jetpants/
|
135
|
-
- lib/jetpants/
|
135
|
+
- lib/jetpants/db.rb
|
136
|
+
- lib/jetpants/pool.rb
|
137
|
+
- lib/jetpants/db/privileges.rb
|
136
138
|
- lib/jetpants/db/state.rb
|
139
|
+
- lib/jetpants/db/import_export.rb
|
137
140
|
- lib/jetpants/db/server.rb
|
138
141
|
- lib/jetpants/db/client.rb
|
139
|
-
- lib/jetpants/db/privileges.rb
|
140
142
|
- lib/jetpants/db/replication.rb
|
141
|
-
- lib/jetpants/
|
142
|
-
- lib/jetpants/pool.rb
|
143
|
+
- lib/jetpants/callback.rb
|
143
144
|
- lib/jetpants/monkeypatch.rb
|
145
|
+
- lib/jetpants/topology.rb
|
146
|
+
- lib/jetpants/host.rb
|
147
|
+
- lib/jetpants.rb
|
144
148
|
- bin/jetpants
|
145
|
-
- plugins/simple_tracker/commandsuite.rb
|
146
|
-
- plugins/simple_tracker/topology.rb
|
147
|
-
- plugins/simple_tracker/db.rb
|
148
|
-
- plugins/simple_tracker/shard.rb
|
149
|
-
- plugins/simple_tracker/pool.rb
|
150
|
-
- plugins/simple_tracker/simple_tracker.rb
|
151
149
|
- plugins/jetpants_collins/jetpants_collins.rb
|
152
|
-
- plugins/jetpants_collins/topology.rb
|
153
|
-
- plugins/jetpants_collins/db.rb
|
154
|
-
- plugins/jetpants_collins/host.rb
|
155
|
-
- plugins/jetpants_collins/asset.rb
|
156
150
|
- plugins/jetpants_collins/shard.rb
|
151
|
+
- plugins/jetpants_collins/db.rb
|
157
152
|
- plugins/jetpants_collins/pool.rb
|
153
|
+
- plugins/jetpants_collins/asset.rb
|
154
|
+
- plugins/jetpants_collins/topology.rb
|
155
|
+
- plugins/jetpants_collins/host.rb
|
156
|
+
- plugins/simple_tracker/simple_tracker.rb
|
157
|
+
- plugins/simple_tracker/commandsuite.rb
|
158
|
+
- plugins/simple_tracker/shard.rb
|
159
|
+
- plugins/simple_tracker/db.rb
|
160
|
+
- plugins/simple_tracker/pool.rb
|
161
|
+
- plugins/simple_tracker/topology.rb
|
158
162
|
- etc/jetpants.yaml.sample
|
159
163
|
homepage: https://github.com/tumblr/jetpants/
|
160
164
|
licenses: []
|