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 +8 -8
- data/infopark-politics.gemspec +1 -1
- data/lib/politics/static_queue_worker.rb +31 -23
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2Y0YWFlODFhZTgwYzc3Nzc1NTI5ZGJkNjEwOGRkNzFiMmE2YzFkOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzdhYzlhN2E0YzYxMmMyMjJkMWM4NTAyZTc5MWRjMzFkNDgyOWFiZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2IwOTBjNjljOWNhOTI4N2I5OTY4MWNhMDI0ZjQ4ZGYyMzA3ZjM5YjAyMDJi
|
10
|
+
ZDU3MTU0OTQ1YWUzOGQ5Y2ZkYmNkYTg4ZGQwZmZhNDA0NGY1MjY3ODhkZTgz
|
11
|
+
MTcyYjQ4Mzk5Zjg5MDU3MzIzMDdjOWM3ZjM0NmJkYTI1MzJhOGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDFlODU5NTVmYzE2YzRlMGFlNjdmZjAwMDY5Y2E0MGVkNTEzNzNiZTMzOTY0
|
14
|
+
Y2U3ZTUzMmFjYWZiOGMyNWU2YTRkY2VkMWQ1MDc1Y2I4ZGY1MTdmNDRiMzcy
|
15
|
+
NDQ2YTVhODVmNWUzMDRhMWI5NWY1ZmM2MTU3YmM5ZmQxMDg4MzM=
|
data/infopark-politics.gemspec
CHANGED
@@ -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.
|
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
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|