infopark-politics 0.8.3 → 0.8.4

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
- MGY5OTVjNDVkMmZiZDM4NzE4MDY1YjkyOWE3ZWRmOWM3OGI5ZjVmYg==
4
+ M2Y0YWFlODFhZTgwYzc3Nzc1NTI5ZGJkNjEwOGRkNzFiMmE2YzFkOQ==
5
5
  data.tar.gz: !binary |-
6
- OGY1NmUxYmE0ODRlMGFhYjU2ZjU2NTI0MGQ0MTA0MDgxYzE5Yjk2NA==
6
+ MzdhYzlhN2E0YzYxMmMyMjJkMWM4NTAyZTc5MWRjMzFkNDgyOWFiZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWMwZWFmYmRlMWY4MTNiM2U5NWJiMTAyZmVhZDEzNTNjNGI0YmQ4NTJiNjZh
10
- YTUzZDBmZDJkODc2OTFjN2FiOGQyNjA4MmQ1OGQ2NDMzMTdjNWVmMGVkNTUz
11
- ODZkOTRhNTYwNmJlOWMzMGQyZTY4ZTIxMGRlYjM1MDgzM2I4YjI=
9
+ N2IwOTBjNjljOWNhOTI4N2I5OTY4MWNhMDI0ZjQ4ZGYyMzA3ZjM5YjAyMDJi
10
+ ZDU3MTU0OTQ1YWUzOGQ5Y2ZkYmNkYTg4ZGQwZmZhNDA0NGY1MjY3ODhkZTgz
11
+ MTcyYjQ4Mzk5Zjg5MDU3MzIzMDdjOWM3ZjM0NmJkYTI1MzJhOGE=
12
12
  data.tar.gz: !binary |-
13
- MTlhOWI1ODNhNWNhNWViZDZhNDRiMWYzNzY4YTcxOGE5MTEzZDllY2U5YjY4
14
- MzExYjkxNDdmNTgwMzdjNTU2MDY1NDAzMjU3YWU0YjE0YzJlYTY3M2EyYjY3
15
- NGEwOWRkNTcyNzI0YWJmMzQ1MGE4YWY2NGU2YTNiZDk5MTJlMmY=
13
+ NDFlODU5NTVmYzE2YzRlMGFlNjdmZjAwMDY5Y2E0MGVkNTEzNzNiZTMzOTY0
14
+ Y2U3ZTUzMmFjYWZiOGMyNWU2YTRkY2VkMWQ1MDc1Y2I4ZGY1MTdmNDRiMzcy
15
+ NDQ2YTVhODVmNWUzMDRhMWI5NWY1ZmM2MTU3YmM5ZmQxMDg4MzM=
@@ -6,7 +6,7 @@ end
6
6
 
7
7
  Gem::Specification.new do |gem|
8
8
  gem.name = "infopark-politics"
9
- gem.version = "0.8.3"
9
+ gem.version = "0.8.4"
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"]
@@ -89,33 +89,35 @@ module Politics
89
89
  end
90
90
 
91
91
  def perform_leader_duties
92
- # The DRb thread handles the requests to the leader.
93
- # This method performs the bucket managing.
94
- log.info { "has been elected leader" }
95
- before_perform_leader_duties
96
- # keeping leader state as long as buckets are being initialized
97
- as_dictator { initialize_buckets }
98
-
99
- while !buckets.empty?
100
- # keeping leader state as long as buckets are available by renominating before
101
- # nomination times out
102
- as_dictator { update_buckets } unless restart_wanted?
92
+ with_errors_logged('leader duties') do
93
+ # The DRb thread handles the requests to the leader.
94
+ # This method performs the bucket managing.
95
+ log.info { "has been elected leader" }
96
+ before_perform_leader_duties
97
+ # keeping leader state as long as buckets are being initialized
98
+ as_dictator { initialize_buckets }
99
+
100
+ while !buckets.empty?
101
+ # keeping leader state as long as buckets are available by renominating before
102
+ # nomination times out
103
+ as_dictator { update_buckets } unless restart_wanted?
104
+ end
103
105
  end
104
106
 
105
- if restart_wanted?
106
- log.info "restart triggered"
107
- as_dictator { populate_followers_to_stop }
108
- # keeping leader state as long as there are followers to stop
109
- while !followers_to_stop.empty?
110
- log.info "waiting fo workers to stop: #{followers_to_stop}"
111
- relax(until_next_iteration / 2)
112
- seize_leadership
107
+ with_errors_logged('termination handling') do
108
+ if restart_wanted?
109
+ log.info "restart triggered"
110
+ as_dictator { populate_followers_to_stop }
111
+ # keeping leader state as long as there are followers to stop
112
+ while !followers_to_stop.empty?
113
+ log.info "waiting fo workers to stop: #{followers_to_stop}"
114
+ relax(until_next_iteration / 2)
115
+ seize_leadership
116
+ end
117
+ log.info "leader exiting due to trigger"
118
+ exit 0
113
119
  end
114
- log.info "leader exiting due to trigger"
115
- exit 0
116
120
  end
117
- rescue StandardError => e
118
- log.error("error while performing leader duties: #{e}\n#{e.backtrace.join("\n")}")
119
121
  end
120
122
 
121
123
  def populate_followers_to_stop
@@ -182,6 +184,12 @@ module Politics
182
184
 
183
185
  attr_reader :iteration_end, :memcache_client
184
186
 
187
+ def with_errors_logged(task)
188
+ yield
189
+ rescue StandardError => e
190
+ log.error("error while performing #{task}: #{e}\n#{e.backtrace.join("\n")}")
191
+ end
192
+
185
193
  def set_iteration_end(interval = iteration_length)
186
194
  @iteration_end = Time.now + interval
187
195
  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.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Perham