cellect-server 1.3.3 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad603f50ab4f1cb53a8d2f67792f1acae0484d14
4
- data.tar.gz: 8c9c4df72fbddd0e1ae3f357f14dc6c3bac2c384
3
+ metadata.gz: 4ef80181a6f62fe2ba4b39b0377cc8805377da52
4
+ data.tar.gz: 7a306ae04dbaa28fde48068f1d628dba47cb1c44
5
5
  SHA512:
6
- metadata.gz: 49c3dbb9447b9f12920b49c8af8350e536b7318c2225228a8b1f64b8dc5e33fe6a2515d8dc8d0a2b2c63a39b2f16af844d2e1b94d5935c9c8abd978339a94dcd
7
- data.tar.gz: 1e772e5a66f80a5557be992a73460e46b132c6bbe2ccca8786988f56db0467bb531f288bad6d1dfdde97b501c9d3d1a980236db78f406c927e607810c7ef9555
6
+ metadata.gz: 2caf888d305d48e668d094e1216a438f4c6247968fba2991f89c1625121fda77641022320f714deb01ae5b90fbd980cc5290706f3bd9060327b0d4e16010fff1
7
+ data.tar.gz: b3c37669fe2308f65b4b77957cd41fc72017763ba03a8d598afc00cb91b87ffcc13a80f98e48850eb7f23905234ee9d3579d0fdd3efcd2ec98338bb1178e17b8
data/.travis.yml CHANGED
@@ -12,3 +12,5 @@ rvm:
12
12
  - 2.2.1
13
13
 
14
14
  script: bundle exec rake spec
15
+ services:
16
+ - redis-server
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}){ |m| "spec/#{ m[1] }_spec.rb" }
4
+ watch('spec/spec_helper.rb'){ 'spec' }
5
+ watch(%r{^spec/support/(.+)\.rb$}){ 'spec' }
6
+ end
data/README.md CHANGED
@@ -14,7 +14,7 @@ Available as
14
14
 
15
15
  ## Cellect::Server
16
16
 
17
- An actor based system that provides an API around subject selection actions. Server nodes are discovered via [ZooKeeper](http://zookeeper.apache.org/).
17
+ An actor based system that provides an API around subject selection actions. Server nodes are discovered via [Attention](https://github.com/parrish/attention).
18
18
 
19
19
  ### Cellect::Server::Adapters
20
20
 
@@ -25,7 +25,13 @@ We're overriding the default adapter with a customization in [cellect_panoptes](
25
25
 
26
26
  ## Cellect::Client
27
27
 
28
- Provides a mix of asynchronous and synchronous operations for server awareness and API communication.
28
+ Provides operations for server awareness and API communication.
29
+
30
+ API timeouts can be set with
31
+
32
+ ```ruby
33
+ Cellect::Client::Connection.timeout = 5 # seconds
34
+ ```
29
35
 
30
36
 
31
37
  ## Building
@@ -42,9 +48,7 @@ To install rice your Ruby must be compiled with shared libraries enabled, from t
42
48
 
43
49
  ## Testing
44
50
 
45
- * You'll need a local Zookeeper server to run the specs (they will auto start / stop the server for you).
46
- * `brew install zookeeper`
47
- * Note: this may require a Java Runtime (JRE) install, `brew cask install java`
51
+ * You'll need a local Redis server to run the specs.
48
52
 
49
53
  Run the specs with `rake`
50
54
 
data/bin/console ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'cellect'
5
+ require 'cellect/server'
6
+ require 'cellect/client'
7
+ require 'pry'
8
+
9
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
@@ -27,14 +27,15 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rspec'
28
28
  spec.add_development_dependency 'rack-test'
29
29
  spec.add_development_dependency 'pry'
30
+ spec.add_development_dependency 'guard'
31
+ spec.add_development_dependency 'guard-rspec'
30
32
  spec.add_development_dependency 'puma', '~> 2.8'
31
33
  spec.add_development_dependency 'pg', '~> 0.17'
32
34
  spec.add_development_dependency 'connection_pool', '~> 2.0'
33
35
 
34
36
  spec.add_runtime_dependency 'diff_set', '~> 0.0.3'
35
37
  spec.add_runtime_dependency 'celluloid', '0.16.0'
36
- spec.add_runtime_dependency 'celluloid-io', '0.16.0'
37
38
  spec.add_runtime_dependency 'http', '~> 0.6'
38
- spec.add_runtime_dependency 'zk', '~> 1.9'
39
+ spec.add_runtime_dependency 'attention', '~> 0.0.4'
39
40
  spec.add_runtime_dependency 'grape', '~> 0.7'
40
41
  end
data/cellect.gemspec CHANGED
@@ -23,8 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'oj'
24
24
  spec.add_development_dependency 'rspec'
25
25
  spec.add_development_dependency 'rack-test'
26
- spec.add_development_dependency 'zk-server'
27
26
  spec.add_development_dependency 'pry'
27
+ spec.add_development_dependency 'guard'
28
+ spec.add_development_dependency 'guard-rspec'
28
29
  spec.add_development_dependency 'puma', '~> 2.8'
29
30
  spec.add_development_dependency 'pg', '~> 0.17'
30
31
  spec.add_development_dependency 'connection_pool', '~> 2.0'
data/lib/cellect.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  require 'celluloid'
2
- require 'celluloid/io'
3
2
  require 'cellect/version'
3
+ require 'attention'
4
4
 
5
5
  module Cellect
6
-
7
6
  end
7
+
8
+ Attention.options[:namespace] = 'cellect'
9
+ Attention.options[:redis_url] = ENV['REDIS_URL'] if ENV['REDIS_URL']
10
+ Attention.options[:ttl] = 20
@@ -26,6 +26,6 @@ module Cellect
26
26
  false
27
27
  end
28
28
 
29
- Server.node_set = NodeSet.supervise
29
+ Server.node_set = NodeSet.new
30
30
  end
31
31
  end
@@ -13,7 +13,7 @@ module Cellect
13
13
  #
14
14
  # Provides system load information
15
15
  get :stats do
16
- node_set = Cellect::Server.node_set.actors.first
16
+ instance = Attention.instance
17
17
  usage = ->(keyword) do
18
18
  `ps axo #{ keyword }`.chomp.split("\n")[1..-1].collect(&:to_f).inject :+
19
19
  end
@@ -21,7 +21,7 @@ module Cellect
21
21
  {
22
22
  memory: usage.call('%mem'),
23
23
  cpu: usage.call('%cpu'),
24
- node_set: { id: node_set.id, ready: node_set.ready? },
24
+ instance: instance.id,
25
25
  status: Cellect::Server.adapter.status.merge({
26
26
  workflows_ready: Cellect::Server.ready?,
27
27
  workflows: Workflow.all.map(&:status)
@@ -1,22 +1,12 @@
1
- require 'cellect/node_set'
2
- require 'socket'
3
-
4
1
  module Cellect
5
2
  module Server
6
- class NodeSet < Cellect::NodeSet
7
- attr_accessor :id
8
-
9
- protected
3
+ class NodeSet
4
+ attr_reader :instance
10
5
 
11
- # Registers this server instance with ZooKeeper
12
- def setup
13
- zk.mkdir_p '/nodes'
14
- # Find the local ipv4 address
15
- address = Socket.ip_address_list.find{ |address| address.ipv4? && !address.ipv4_loopback? }
16
- raise "Cannot identify IP address" unless address
17
- # Register this instance with an autoincrementing id
18
- path = zk.create '/nodes/node', data: address.ip_address, mode: :ephemeral_sequential
19
- self.id = path.sub /^\/nodes\//, ''
6
+ # Registers this server instance
7
+ def initialize
8
+ Attention.activate
9
+ @instance = Attention.instance
20
10
  end
21
11
  end
22
12
  end
@@ -1,3 +1,3 @@
1
1
  module Cellect
2
- VERSION = '1.3.3'
2
+ VERSION = '2.0.0.beta1'
3
3
  end
File without changes
File without changes
File without changes
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ module Cellect::Server
4
+ describe NodeSet do
5
+ describe '#setup' do
6
+ it 'should activate this node' do
7
+ expect(Attention).to receive :activate
8
+ subject
9
+ end
10
+
11
+ it 'should register this node' do
12
+ expect(subject.instance).to be_a Attention::Instance
13
+ end
14
+ end
15
+ end
16
+ end
@@ -42,16 +42,7 @@ module Cellect::Server
42
42
  end
43
43
 
44
44
  it 'should include information' do
45
- expect(response.keys).to match_array %w(memory cpu node_set status)
46
- end
47
-
48
- context 'node_set' do
49
- let(:node_set){ response['node_set'] }
50
-
51
- it 'should include information' do
52
- expect(node_set['id']).to eql 'node0000000000'
53
- expect(node_set['ready']).to eql true
54
- end
45
+ expect(response.keys).to match_array %w(memory cpu instance status)
55
46
  end
56
47
 
57
48
  context 'status' do
File without changes
File without changes
data/spec/spec_helper.rb CHANGED
@@ -10,11 +10,8 @@ end
10
10
 
11
11
  Bundler.require :test, :development
12
12
 
13
- ENV['CELLECT_POOL_SIZE'] = '3'
14
- SPAWN_ZK = !ENV['ZK_URL']
15
13
  require 'pry'
16
14
  require 'oj'
17
- require './spec/support/zk_setup.rb'
18
15
  require 'cellect/server'
19
16
  require 'cellect/client'
20
17
  require 'celluloid/rspec'
@@ -33,12 +30,11 @@ RSpec.configure do |config|
33
30
  config.include CellectHelper
34
31
 
35
32
  config.around(:each) do |example|
33
+ Redis.new.flushdb
36
34
  Celluloid.boot
35
+ Attention.deactivate
37
36
  example.run
38
37
  Celluloid.shutdown
39
- end
40
-
41
- config.after(:suite) do
42
- ZK_Setup.stop_zk
38
+ Attention.deactivate
43
39
  end
44
40
  end
@@ -1,8 +1,8 @@
1
1
  require 'timeout'
2
2
 
3
3
  module CellectHelper
4
- def pass_until(&block)
5
- Timeout::timeout(1) do
4
+ def pass_until(timeout: 1, &block)
5
+ Timeout::timeout(timeout) do
6
6
  Thread.pass until block.call
7
7
  end
8
8
  rescue => e
@@ -10,7 +10,7 @@ module CellectHelper
10
10
  raise e
11
11
  end
12
12
 
13
- def pass_until_state_of(obj, is:)
13
+ def pass_until_state_of(obj, timeout: 1, is:)
14
14
  Timeout::timeout(1) do
15
15
  Thread.pass until obj.state == is
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cellect-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Parrish
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-12 00:00:00.000000000 Z
11
+ date: 2016-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: puma
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -164,20 +192,6 @@ dependencies:
164
192
  - - '='
165
193
  - !ruby/object:Gem::Version
166
194
  version: 0.16.0
167
- - !ruby/object:Gem::Dependency
168
- name: celluloid-io
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - '='
172
- - !ruby/object:Gem::Version
173
- version: 0.16.0
174
- type: :runtime
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - '='
179
- - !ruby/object:Gem::Version
180
- version: 0.16.0
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: http
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -193,19 +207,19 @@ dependencies:
193
207
  - !ruby/object:Gem::Version
194
208
  version: '0.6'
195
209
  - !ruby/object:Gem::Dependency
196
- name: zk
210
+ name: attention
197
211
  requirement: !ruby/object:Gem::Requirement
198
212
  requirements:
199
213
  - - "~>"
200
214
  - !ruby/object:Gem::Version
201
- version: '1.9'
215
+ version: 0.0.4
202
216
  type: :runtime
203
217
  prerelease: false
204
218
  version_requirements: !ruby/object:Gem::Requirement
205
219
  requirements:
206
220
  - - "~>"
207
221
  - !ruby/object:Gem::Version
208
- version: '1.9'
222
+ version: 0.0.4
209
223
  - !ruby/object:Gem::Dependency
210
224
  name: grape
211
225
  requirement: !ruby/object:Gem::Requirement
@@ -223,7 +237,9 @@ dependencies:
223
237
  description: ''
224
238
  email:
225
239
  - michael@zooniverse.org
226
- executables: []
240
+ executables:
241
+ - console
242
+ - setup
227
243
  extensions: []
228
244
  extra_rdoc_files: []
229
245
  files:
@@ -231,14 +247,16 @@ files:
231
247
  - ".rspec"
232
248
  - ".travis.yml"
233
249
  - Gemfile
250
+ - Guardfile
234
251
  - LICENSE
235
252
  - README.md
236
253
  - Rakefile
254
+ - bin/console
255
+ - bin/setup
237
256
  - cellect-server.gemspec
238
257
  - cellect.gemspec
239
258
  - data/.gitkeep
240
259
  - lib/cellect.rb
241
- - lib/cellect/node_set.rb
242
260
  - lib/cellect/server.rb
243
261
  - lib/cellect/server/adapters.rb
244
262
  - lib/cellect/server/adapters/default.rb
@@ -251,9 +269,18 @@ files:
251
269
  - lib/cellect/server/node_set.rb
252
270
  - lib/cellect/server/user.rb
253
271
  - lib/cellect/server/workflow.rb
254
- - lib/cellect/testing.rb
255
272
  - lib/cellect/version.rb
256
273
  - log/.gitkeep
274
+ - spec/cellect/server/api/add_seen_spec.rb
275
+ - spec/cellect/server/api/add_spec.rb
276
+ - spec/cellect/server/api/remove_spec.rb
277
+ - spec/cellect/server/api/sample_spec.rb
278
+ - spec/cellect/server/api/user_load_spec.rb
279
+ - spec/cellect/server/grouped_workflow_spec.rb
280
+ - spec/cellect/server/node_set_spec.rb
281
+ - spec/cellect/server/server_spec.rb
282
+ - spec/cellect/server/user_spec.rb
283
+ - spec/cellect/server/workflow_spec.rb
257
284
  - spec/fixtures/user_data/complete_user.json
258
285
  - spec/fixtures/user_data/new_user.json
259
286
  - spec/fixtures/user_data/partial_user.json
@@ -265,24 +292,12 @@ files:
265
292
  - spec/fixtures/workflow_data/pairwise_random.json
266
293
  - spec/fixtures/workflow_data/priority.json
267
294
  - spec/fixtures/workflow_data/random.json
268
- - spec/server/api/add_seen_spec.rb
269
- - spec/server/api/add_spec.rb
270
- - spec/server/api/remove_spec.rb
271
- - spec/server/api/sample_spec.rb
272
- - spec/server/api/user_load_spec.rb
273
- - spec/server/grouped_workflow_spec.rb
274
- - spec/server/node_set_spec.rb
275
- - spec/server/server_spec.rb
276
- - spec/server/user_spec.rb
277
- - spec/server/workflow_spec.rb
278
295
  - spec/spec_helper.rb
279
296
  - spec/support/cellect_helper.rb
280
297
  - spec/support/shared_api_context.rb
281
- - spec/support/shared_examples_for_node_set.rb
282
298
  - spec/support/shared_examples_for_set.rb
283
299
  - spec/support/shared_examples_for_workflow.rb
284
300
  - spec/support/spec_adapter.rb
285
- - spec/support/zk_setup.rb
286
301
  - tmp/.gitkeep
287
302
  homepage: https://github.com/parrish/Cellect
288
303
  licenses:
@@ -299,9 +314,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
299
314
  version: '0'
300
315
  required_rubygems_version: !ruby/object:Gem::Requirement
301
316
  requirements:
302
- - - ">="
317
+ - - ">"
303
318
  - !ruby/object:Gem::Version
304
- version: '0'
319
+ version: 1.3.1
305
320
  requirements: []
306
321
  rubyforge_project:
307
322
  rubygems_version: 2.4.2
@@ -309,6 +324,16 @@ signing_key:
309
324
  specification_version: 4
310
325
  summary: ''
311
326
  test_files:
327
+ - spec/cellect/server/api/add_seen_spec.rb
328
+ - spec/cellect/server/api/add_spec.rb
329
+ - spec/cellect/server/api/remove_spec.rb
330
+ - spec/cellect/server/api/sample_spec.rb
331
+ - spec/cellect/server/api/user_load_spec.rb
332
+ - spec/cellect/server/grouped_workflow_spec.rb
333
+ - spec/cellect/server/node_set_spec.rb
334
+ - spec/cellect/server/server_spec.rb
335
+ - spec/cellect/server/user_spec.rb
336
+ - spec/cellect/server/workflow_spec.rb
312
337
  - spec/fixtures/user_data/complete_user.json
313
338
  - spec/fixtures/user_data/new_user.json
314
339
  - spec/fixtures/user_data/partial_user.json
@@ -320,21 +345,9 @@ test_files:
320
345
  - spec/fixtures/workflow_data/pairwise_random.json
321
346
  - spec/fixtures/workflow_data/priority.json
322
347
  - spec/fixtures/workflow_data/random.json
323
- - spec/server/api/add_seen_spec.rb
324
- - spec/server/api/add_spec.rb
325
- - spec/server/api/remove_spec.rb
326
- - spec/server/api/sample_spec.rb
327
- - spec/server/api/user_load_spec.rb
328
- - spec/server/grouped_workflow_spec.rb
329
- - spec/server/node_set_spec.rb
330
- - spec/server/server_spec.rb
331
- - spec/server/user_spec.rb
332
- - spec/server/workflow_spec.rb
333
348
  - spec/spec_helper.rb
334
349
  - spec/support/cellect_helper.rb
335
350
  - spec/support/shared_api_context.rb
336
- - spec/support/shared_examples_for_node_set.rb
337
351
  - spec/support/shared_examples_for_set.rb
338
352
  - spec/support/shared_examples_for_workflow.rb
339
353
  - spec/support/spec_adapter.rb
340
- - spec/support/zk_setup.rb
@@ -1,44 +0,0 @@
1
- require 'zk'
2
-
3
- module Cellect
4
- class NodeSet
5
- include Celluloid
6
- ConnectionError = Class.new(StandardError)
7
-
8
- attr_accessor :zk, :state
9
-
10
- # Sets up the node set and starts connecting to ZooKeeper
11
- def initialize(zk_url = nil)
12
- @zk_url = zk_url
13
- self.state = :initializing
14
- after(0.001){ async.initialize_zk } # don't block waiting for ZK to connect
15
- end
16
-
17
- # Connect to ZooKeeper, setup this node, and change state
18
- def initialize_zk
19
- Timeout::timeout(timeout_duration) do
20
- self.zk = ZK.new zk_url, chroot: '/cellect'
21
- end
22
- setup
23
- self.state = :ready
24
- end
25
-
26
- def ready?
27
- state == :ready
28
- end
29
-
30
- protected
31
-
32
- def timeout_duration
33
- ENV.fetch('ZK_TIMEOUT', 5).to_i
34
- end
35
-
36
- def zk_url
37
- @zk_url || ENV.fetch('ZK_URL', 'localhost:2181')
38
- end
39
-
40
- def setup
41
- # Specialized in subclasses
42
- end
43
- end
44
- end
@@ -1,7 +0,0 @@
1
- module Cellect
2
- module Client
3
- def self.mock_zookeeper?
4
- true
5
- end
6
- end
7
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Cellect::Server
4
- describe NodeSet do
5
- it_behaves_like 'node set'
6
- let(:node_set){ Cellect::Server.node_set.actors.first }
7
-
8
- it 'should register this node' do
9
- expect(node_set.id).to eq 'node0000000000'
10
- expect(node_set.zk.get('/nodes/node0000000000').first).to match /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/
11
- end
12
- end
13
- end
@@ -1,28 +0,0 @@
1
- shared_examples_for 'node set' do
2
- let(:node_set){ Cellect::NodeSet.new }
3
-
4
- it 'should connect to zoo keeper' do
5
- expect(node_set.zk).to be_nil
6
- pass_until_state_of node_set, is: :ready
7
- expect(node_set.zk).to be_connected
8
- end
9
-
10
- it 'should know the connection state' do
11
- expect(node_set.state).to be :initializing
12
- pass_until_state_of node_set, is: :ready
13
- expect(node_set).to be_ready
14
- end
15
-
16
- it 'should accept a connection string' do
17
- url_before = ENV['ZK_URL']
18
- begin
19
- pass_until_state_of node_set, is: :ready
20
- ENV['ZK_URL'] = 'foobar'
21
- expect(node_set.send(:zk_url)).to eq 'foobar'
22
- ENV.delete 'ZK_URL'
23
- expect(node_set.send(:zk_url)).to eq 'localhost:2181'
24
- ensure
25
- ENV['ZK_URL'] = url_before
26
- end
27
- end
28
- end
@@ -1,51 +0,0 @@
1
- module ZK_Setup
2
- def self.start_zk(port=21811)
3
- @port = port
4
- if SPAWN_ZK
5
- kill_old_zk_servers
6
- remove_zk_data
7
- server = ZK::Server.new do |config|
8
- config.client_port = port
9
- config.client_port_address = 'localhost'
10
- config.force_sync = false
11
- config.tick_time = 2000
12
- config.init_limit = 10
13
- config.sync_limit = 5
14
- config.snap_count = 1000000
15
- config.base_dir = zk_dir
16
- end
17
- server.run
18
- @zk_server = server
19
- ENV['ZK_URL'] = "localhost:#{port}"
20
- end
21
- end
22
-
23
- def self.stop_zk
24
- if SPAWN_ZK
25
- @zk_server.shutdown
26
- end
27
- end
28
-
29
- def self.zk_dir
30
- File.join CELLECT_ROOT, 'tmp/zookeeper'
31
- end
32
-
33
- def self.zk_ok?
34
- `echo ruok | nc 127.0.0.1 #{@port}`.chomp == 'imok'
35
- end
36
-
37
- def self.kill_old_zk_servers
38
- if zk_ok?
39
- pid = `ps aux | grep -e 'Cellect[\/]tmp[\/]zookeeper'`.split[1]
40
- puts "Killing rogue zookeeper process: #{ pid }..."
41
- `kill -s TERM #{ pid }`
42
- sleep 1
43
- end
44
- end
45
-
46
- def self.remove_zk_data
47
- `rm -rf #{ zk_dir }; mkdir -p #{ zk_dir }`
48
- end
49
- end
50
-
51
- ZK_Setup.start_zk