ruby-kafka-ec2 0.1.5 → 0.1.6

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
  SHA256:
3
- metadata.gz: 8dde731c3652090bf18202d68b916cbdcff9ed09673bd84d5f20470a37c63373
4
- data.tar.gz: d1a95de4724b3b5f85230c55a70469cc5e6c1e6008423b83f74c415bf2c9d289
3
+ metadata.gz: b87f937f29a107174e7a972b79e2a717780bdd28b28fa37e3601633ff1f075b0
4
+ data.tar.gz: 413c79ff75ccb9f9304dd5c57dfb2fb1f26b0b673eeae9cb7e7d86cb68d65e74
5
5
  SHA512:
6
- metadata.gz: f37b8fa41b773933aac85f170884adb75fc0e446faf9fb92c109aa039f5a869874194dbdf3a9099899e273ef8543f75c5f7aca0fd99cff1845bc43ac081bde50
7
- data.tar.gz: 78bc5df7157441563d73e19f35804069ddbb2c1863bccfe2711594c27a6caed78a5209fdd2ca7f55a3cf2302bed326ec47302720bf4253a9f8b4df950e5a0d0f
6
+ metadata.gz: 22dfa6ddf4e0e0f8eb5db7bd6cb9c54b25edb175186bba989b32df698e23c705754c8dff057e7d82df480a3835bea110a363177b36739bca73432206227ac680
7
+ data.tar.gz: 1deda3ac8da64c41f9d598e26049b667aec2d81956a98dc7ded279c8a13e517d7dc4042ab34f9f4e8a05365be46c570e274207bd5bd430210b7de458972cace3
@@ -74,28 +74,29 @@ module Kafka
74
74
  member_ids = instance_id_to_member_ids[instance_id]
75
75
  member_ids.each do |member_id|
76
76
  acceptable_partition_weight = capacity * partition_weight_per_capacity / member_ids.size
77
- loop do
77
+ while last_index < topic_partitions.size
78
78
  topic, partition = topic_partitions[last_index]
79
79
  partition_weight = partition_weights.dig(topic, partition)
80
- if last_index == topic_partitions.size || acceptable_partition_weight - partition_weight < 0
81
- member_id_to_acceptable_partition_weight[member_id] = acceptable_partition_weight
82
- break
83
- end
80
+ break if acceptable_partition_weight - partition_weight < 0
84
81
 
85
82
  group_assignment[member_id].assign(topic, [partition])
86
- last_index += 1
87
83
  acceptable_partition_weight -= partition_weight
84
+
85
+ last_index += 1
88
86
  end
87
+
88
+ member_id_to_acceptable_partition_weight[member_id] = acceptable_partition_weight
89
89
  end
90
90
  end
91
91
 
92
- if last_index < topic_partitions.size
93
- member_id_to_acceptable_partition_weight.sort_by { |_, remaining| -remaining }.each do |member_id, _|
94
- topic, partition = topic_partitions[last_index]
95
- group_assignment[member_id].assign(topic, [partition])
96
- last_index += 1
97
- break if last_index == topic_partitions.size
98
- end
92
+ while last_index < topic_partitions.size
93
+ member_id, _ = member_id_to_acceptable_partition_weight.max_by { |_, remaining| remaining }
94
+ topic, partition = topic_partitions[last_index]
95
+ group_assignment[member_id].assign(topic, [partition])
96
+
97
+ member_id_to_acceptable_partition_weight[member_id] -= partition_weights.dig(topic, partition)
98
+
99
+ last_index += 1
99
100
  end
100
101
 
101
102
  group_assignment
@@ -1,5 +1,5 @@
1
1
  module Kafka
2
2
  class EC2
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-kafka-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - abicky