infopark-politics 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWM4NzBmMTlmNTc2NGI4OTJmNzcxYzdhZWI4Yjg2MDIxOGIyMWU2Yg==
4
+ NTk3MGVhMDFjZDY5ZjUxOTdmOTUxYmVlZWFkNmEwMzRkNTRkNWQwOA==
5
5
  data.tar.gz: !binary |-
6
- MjVlOGE0ZWU2ZjI0Yzk4NmZmMjg3MTVjOTU3ZWQ1Mzk5NzA3OGE1Mw==
6
+ Y2FhMGQ3MDIyMzNiNTM0N2Y0NDc4NjVkYzA4MDg1NjcwODhiNmJkYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWRhMGJkYmI2OTE3NmFhOTE3YjRmYjc0ZDM4MGE0MTZiYWY1N2UxYmUxM2U1
10
- MzRmY2M4YzllN2EwYTI4MzFhNTYzNjg3YzA2OTYyMzZhOGRlMTM1ZjgxM2Mz
11
- MjQ4ZTgzZmNhZDU1ZTY4ZGM1MWJkMmNjODQ1NmZkZDkxM2JiZTg=
9
+ OTI5MzQ3MjY5NTcwMmM2YjdlMTMxZTlhNDBkYTM5NWJjNDRkZjExMzYyOTUx
10
+ NzhjMTlkMDM1ZWYyMTI5NzFlN2NiYTBkMDFjNWMyMDJjNzNjY2RhYjVjMzM5
11
+ MmIwNDdiZmE1NjFlYjgwM2I3M2ZhMjdmNDkzMjgwMjc1YzJkMjc=
12
12
  data.tar.gz: !binary |-
13
- NDVlODk5YzQ2NmY0ZGI1YTIyYjJiYjljOGJkNWU1MzJmZjM5YzRiNDc3NzFk
14
- NjY1ZWNkNmQ1YmZiMjZkMzQ2MjU2NzhjNDE2ZTkxMjZmNjZmN2M3M2VhNWNh
15
- NjU5YjI3OTVlZjRkOWQ5MmQ4ZjRmZWY1NDY3NjU1NDc5ZTBjOTE=
13
+ YzAyODE3MjBjMGFlOGUxNTllZjY0YzdkNTAxYTIzZWIwZTA4NTZjNDViMWRl
14
+ MWMwNzdhZjZkYjVjNTM5NWNhODc5OTBhMzcyM2E4ODJiNTA2NjVhZGM4NWJk
15
+ NjVlZWE0MzY0NjM1MjZiMTZjZjMzOGIwMDNlYzUwZWZiYWQwYzk=
@@ -6,7 +6,7 @@ end
6
6
 
7
7
  Gem::Specification.new do |gem|
8
8
  gem.name = "infopark-politics"
9
- gem.version = "0.5.2"
9
+ gem.version = "0.6.0"
10
10
  gem.summary = "Algorithms and Tools for Distributed Computing in Ruby."
11
11
  gem.description = ""
12
12
  gem.authors = ["Mike Perham", "Tilo Prütz"]
@@ -37,6 +37,7 @@ module Politics
37
37
  log.progname = uri
38
38
  log.info { "Registered in group #{group_name} at #{uri}" }
39
39
  at_exit do
40
+ internal_cleanup
40
41
  cleanup
41
42
  end
42
43
  end
@@ -219,14 +220,18 @@ module Politics
219
220
  "#{group_name}_restart"
220
221
  end
221
222
 
222
- def cleanup
223
- log.debug("cleanup: uri: #{uri}, leader_uri: #{leader_uri}, until_next_iteration: #{until_next_iteration}")
224
- if uri == leader_uri
223
+ def internal_cleanup
224
+ log.debug("uri: #{uri}, leader_uri: #{leader_uri}, until_next_iteration: #{until_next_iteration}")
225
+ if leader?
225
226
  @memcache_client.delete(token)
226
227
  @memcache_client.delete(restart_flag)
227
228
  end
228
229
  end
229
230
 
231
+ def cleanup
232
+ # for custom use
233
+ end
234
+
230
235
  def pause_until_expiry(elapsed)
231
236
  pause_time = (iteration_length - elapsed).to_f
232
237
  if pause_time > 0
@@ -43,6 +43,7 @@ describe UninitializedWorker do
43
43
  worker.should_receive(:at_exit).ordered.and_return {|&h| h}
44
44
  handler = worker.register_worker('worker', 10, :iteration_length => 10)
45
45
 
46
+ worker.should_receive(:internal_cleanup).ordered
46
47
  worker.should_receive(:cleanup).ordered
47
48
  handler.call
48
49
  end
@@ -464,12 +465,12 @@ describe Worker do
464
465
 
465
466
  it "should remove the leadership token from memcache" do
466
467
  memcache_client.should_receive(:delete).with('the group_token')
467
- worker.send(:cleanup)
468
+ worker.send(:internal_cleanup)
468
469
  end
469
470
 
470
471
  it "should remove the restart wanted flag from memcache" do
471
472
  memcache_client.should_receive(:delete).with('the group_restart')
472
- worker.send(:cleanup)
473
+ worker.send(:internal_cleanup)
473
474
  end
474
475
  end
475
476
 
@@ -480,7 +481,7 @@ describe Worker do
480
481
 
481
482
  it "should not remove anything from memcache" do
482
483
  memcache_client.should_not_receive(:delete)
483
- worker.send(:cleanup)
484
+ worker.send(:internal_cleanup)
484
485
  end
485
486
  end
486
487
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark-politics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-01 00:00:00.000000000 Z
12
+ date: 2014-05-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec