poseidon_cluster 0.1.0 → 0.1.1

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: 572fd136cb5145934e5c5ee72cd5b679c80284d3
4
- data.tar.gz: f376b773d60c642603c45756a5626e3b67927037
3
+ metadata.gz: 54b28361ea6e2d74ad75503560e29230f928cf87
4
+ data.tar.gz: dce02dfed81efe6a59c210391d07c74cf3781083
5
5
  SHA512:
6
- metadata.gz: c09941bb0135cbfd85f6d761b3accae3d5e6bf37265a7afc8eb5cc32cf135d5a5f099d558d8bf8281afb7c7901a7a86eeb3dc5bcfe65acd0615d2683e5dc7dad
7
- data.tar.gz: ae1cd45aedc7587e7324b34c5a06f9ca1f196a445fc6f2b03cb4a449e396e0713e08102f6d5d85df261ce7320916f9c89398cc48bd702e11c329f4994f350300
6
+ metadata.gz: ac690a44445aa513d2131339f8a7bb06dfe0e442d569e1389e1aa6959c01b80b5224dee4c8733aff41d2629803a847335a4a794ae8adb59ca5bd2f6c4a0b15cc
7
+ data.tar.gz: 117990bd5fd6badf2bdc9286ecba6d1ec0eaaca0b87ebaaf6fb385fae371d4669adc2527593d177ffe28caecf210f4af4049873e5d0e3ef1480ac9069405b17d
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- poseidon_cluster (0.1.0)
10
+ poseidon_cluster (0.1.1)
11
11
  poseidon
12
12
  zk
13
13
 
@@ -54,9 +54,6 @@ GEM
54
54
  logging (~> 1.7.2)
55
55
  zookeeper (~> 1.4.0)
56
56
  zookeeper (1.4.8)
57
- zookeeper (1.4.8-java)
58
- slyphon-log4j (= 1.2.15)
59
- slyphon-zookeeper_jar (= 3.3.5)
60
57
 
61
58
  PLATFORMS
62
59
  java
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Poseidon Cluster [![Build Status](https://travis-ci.org/bsm/poseidon_cluster.png?branch=master)](https://travis-ci.org/bsm/poseidon_cluster) [![Coverage Status](https://coveralls.io/repos/bsm/poseidon_cluster/badge.png)](https://coveralls.io/r/bsm/poseidon_cluster)
1
+ # Poseidon Cluster [![Build Status](https://travis-ci.org/bsm/poseidon_cluster.png?branch=master)](https://travis-ci.org/bsm/poseidon_cluster) [![Coverage Status](https://coveralls.io/repos/bsm/poseidon_cluster/badge.png?branch=master)](https://coveralls.io/r/bsm/poseidon_cluster?branch=master)
2
2
 
3
3
  Poseidon Cluster is a cluster extension the excellent [Poseidon](http://github.com/bpot/poseidon) Ruby client for Kafka 0.8+. It implements the distribution concept of self-rebalancing *Consumer Groups* and supports the consumption of a single topic from multiple instances.
4
4
 
@@ -30,7 +30,7 @@ class Poseidon::ConsumerGroup
30
30
  # @api private
31
31
  class Consumer < ::Poseidon::PartitionConsumer
32
32
 
33
- # @attr_reader [Integer] partition Consumer partition
33
+ # @attr_reader [Integer] partition consumer partition
34
34
  attr_reader :partition
35
35
 
36
36
  # @api private
@@ -158,10 +158,8 @@ class Poseidon::ConsumerGroup
158
158
  # Closes the consumer group gracefully, only really useful in tests
159
159
  # @api private
160
160
  def close
161
- @mutex.synchronize do
162
- release_all!
163
- zk.close
164
- end
161
+ release_all!
162
+ zk.close
165
163
  end
166
164
 
167
165
  # @param [Integer] partition
@@ -222,18 +220,18 @@ class Poseidon::ConsumerGroup
222
220
  #
223
221
  # @api public
224
222
  def checkout(opts = {})
225
- @mutex.synchronize do
226
- consumer = @consumers.shift
227
- break false unless consumer
223
+ return false if @rebalancing
228
224
 
229
- @consumers.push(consumer)
230
- result = yield(consumer)
225
+ consumer = @consumers.shift
226
+ return false unless consumer
231
227
 
232
- unless opts[:commit] == false || result == false
233
- commit consumer.partition, consumer.offset
234
- end
235
- true
228
+ @consumers.push(consumer)
229
+ result = yield(consumer)
230
+
231
+ unless opts[:commit] == false || result == false
232
+ commit consumer.partition, consumer.offset
236
233
  end
234
+ true
237
235
  end
238
236
 
239
237
  # Convenience method to fetch messages from the broker.
@@ -360,19 +358,7 @@ class Poseidon::ConsumerGroup
360
358
  # * let POS be our index position in CG and let N = size(PT)/size(CG)
361
359
  # * assign partitions from POS*N to (POS+1)*N-1
362
360
  def rebalance!
363
- @mutex.synchronize do
364
- reload
365
- release_all!
366
-
367
- ids = zk.children(registries[:consumer], watch: true)
368
- pms = partitions
369
- rng = self.class.pick(pms.size, ids, id)
370
-
371
- pms[rng].each do |pm|
372
- consumer = claim!(pm.id)
373
- @consumers.push(consumer)
374
- end if rng
375
- end
361
+ @mutex.synchronize { perform_rebalance! }
376
362
  end
377
363
 
378
364
  # Release all consumer claims
@@ -385,10 +371,10 @@ class Poseidon::ConsumerGroup
385
371
  # @raise [Timeout::Error]
386
372
  def claim!(partition)
387
373
  path = claim_path(partition)
388
- Timeout.timeout(options[:claim_timout] || DEFAULT_CLAIM_TIMEOUT) do
389
- sleep(0.01) while zk.create(path, id, ephemeral: true, ignore: :node_exists).nil?
374
+ Timeout.timeout options[:claim_timout] || DEFAULT_CLAIM_TIMEOUT do
375
+ sleep(0.1) while zk.create(path, id, ephemeral: true, ignore: :node_exists).nil?
390
376
  end
391
- Consumer.new(self, partition, options.dup)
377
+ Consumer.new self, partition, options.dup
392
378
  end
393
379
 
394
380
  # Release ownership of the partition
@@ -413,4 +399,21 @@ class Poseidon::ConsumerGroup
413
399
  "#{registries[:consumer]}/#{id}"
414
400
  end
415
401
 
402
+ def perform_rebalance!
403
+ @rebalancing = true
404
+ reload
405
+ release_all!
406
+
407
+ ids = zk.children(registries[:consumer], watch: true)
408
+ pms = partitions
409
+ rng = self.class.pick(pms.size, ids, id)
410
+
411
+ pms[rng].each do |pm|
412
+ consumer = claim!(pm.id)
413
+ @consumers.push(consumer)
414
+ end if rng
415
+ ensure
416
+ @rebalancing = nil
417
+ end
418
+
416
419
  end
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.name = File.basename(__FILE__, '.gemspec')
6
6
  s.summary = "Poseidon cluster extensions"
7
7
  s.description = "Cluster extensions for Poseidon, a producer and consumer implementation for Kafka >= 0.8"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.authors = ["Black Square Media"]
11
11
  s.email = "info@blacksquaremedia.com"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poseidon_cluster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Black Square Media
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-03 00:00:00.000000000 Z
11
+ date: 2014-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: poseidon
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  version: 1.8.0
151
151
  requirements: []
152
152
  rubyforge_project:
153
- rubygems_version: 2.2.1
153
+ rubygems_version: 2.2.0.rc.1
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: Poseidon cluster extensions