consistent-hashing 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MWE4MTk2NWU4MTcxMDMzMzA1NWU2MDlmZTc5NTdjMzQ2MTQ0NWYxYg==
5
+ data.tar.gz: !binary |-
6
+ MWU3ODg0ZTEyYjZiMTJjMjJjNmE4MzkwODA2MWZiZjFjMWVhYjE1Yg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MjNlZmQyNTZlMTVkNmQ3MDRjODY3ODQ4OWQzODg5YTA3MTQyYzg0YmE5YWEy
10
+ ODc5MmMxZDg0ZmU3ZTVhZDg3ZWU5OWVkYjNiOGU1ZGM1NmYyN2MwZDE1OGUy
11
+ MjE1ZjNlZjE1ZmE5YjkzNzZiNDgwNTM4ZGJhZGQ5YjAwNDlkMzM=
12
+ data.tar.gz: !binary |-
13
+ NmNhYjEyOGM3YjJkZDM2Yjk4ZmUyZDViNTdiODExZGNlNDg2YzljZTc5Mzc1
14
+ MGVjNTEzMmRlYmE1MGE0OWE3YWE4NjBlODZhYTZiOGExMGRkMjBhZmIzNzBm
15
+ NWI3NTZjNmIwYWRkY2IyMmU3OTI0NTlkOWM4NDBmMThjZWZiNWM=
@@ -1,3 +1,7 @@
1
+ == 1.0.0 / 2013-12-06
2
+
3
+ * separated << and add methods for the ring, add no longer returns a self reference (potentionally critical on large rings)
4
+
1
5
  == 0.2.1 / 2013-04-27
2
6
 
3
7
  * fixed build, removed bones gem dependency
@@ -14,4 +18,4 @@
14
18
 
15
19
  == 0.0.1 / 2012-04-15
16
20
 
17
- * Birthday!
21
+ * Birthday!
data/README.md CHANGED
@@ -29,6 +29,11 @@ ring.nodes # => ["192.168.1.101", "192.168.1.102"]
29
29
  ring.points # => [#<ConsistentHashing::VirtualPoint>, #<ConsistentHashing::VirtualPoint>, ...]
30
30
  ```
31
31
 
32
+ ## A note on large rings
33
+
34
+ For large amounts of nodes, avoid using the `<<` method. Use `add` instead to add the nodes to the ring. The reason for
35
+ this is, that each call to `<<` returns a reference to the complete ring, which can get quite big.
36
+
32
37
  ## Installation
33
38
 
34
39
  * `[sudo] gem install consistent-hashing`
@@ -31,10 +31,15 @@ module ConsistentHashing
31
31
 
32
32
  @ring[key] = VirtualPoint.new(node, key)
33
33
  end
34
+ end
34
35
 
36
+ # Public: adds a new node into the hash ring like `add` but returns
37
+ # a reference to the ring to be used as a fluent interface
38
+ #
39
+ def <<(node)
40
+ add(node)
35
41
  self
36
42
  end
37
- alias :<< :add
38
43
 
39
44
  # Public: removes a node from the hash ring
40
45
  #
@@ -25,6 +25,18 @@ class TestRing < ConsistentHashing::TestCase
25
25
  assert_equal 6, ring.length
26
26
  end
27
27
 
28
+ # builds a rather huge ring of 1024 nodes and 10 replicas each
29
+ #
30
+ def test_add_huge
31
+ replicas = 10
32
+ ring = ConsistentHashing::Ring.new([], replicas)
33
+ assert_equal 0, ring.length
34
+
35
+ (1..1024).map {|i| ring.add(i)}
36
+
37
+ assert_equal 10240, ring.length
38
+ end
39
+
28
40
  def test_get_node
29
41
  assert_equal "A", @ring.point_for(@examples["A"]).node
30
42
  assert_equal "B", @ring.point_for(@examples["B"]).node
@@ -1 +1 @@
1
- 0.2.1
1
+ 1.0.0
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consistent-hashing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dominik Liebler
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-27 00:00:00.000000000 Z
11
+ date: 2013-12-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: avl_tree
16
- requirement: &70246971619540 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.1.3
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70246971619540
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.3
25
27
  description: a Consistent Hashing implementation in pure Ruby using an AVL Tree
26
28
  email: liebler.dominik@googlemail.com
27
29
  executables: []
@@ -30,12 +32,12 @@ extra_rdoc_files:
30
32
  - History.txt
31
33
  files:
32
34
  - lib/consistent_hashing/avl_tree.rb
33
- - lib/consistent_hashing/ring.rb
34
35
  - lib/consistent_hashing/virtual_point.rb
36
+ - lib/consistent_hashing/ring.rb
35
37
  - lib/consistent_hashing.rb
38
+ - test/consistent_hashing/test_virtual_point.rb
36
39
  - test/consistent_hashing/test_avl_tree.rb
37
40
  - test/consistent_hashing/test_ring.rb
38
- - test/consistent_hashing/test_virtual_point.rb
39
41
  - test/test_consistent_hashing.rb
40
42
  - benchmark/benchmark.rb
41
43
  - README.md
@@ -44,6 +46,7 @@ files:
44
46
  - version.txt
45
47
  homepage: https://github.com/domnikl/consistent-hashing
46
48
  licenses: []
49
+ metadata: {}
47
50
  post_install_message:
48
51
  rdoc_options:
49
52
  - --main
@@ -51,25 +54,23 @@ rdoc_options:
51
54
  require_paths:
52
55
  - lib
53
56
  required_ruby_version: !ruby/object:Gem::Requirement
54
- none: false
55
57
  requirements:
56
58
  - - ! '>='
57
59
  - !ruby/object:Gem::Version
58
60
  version: '0'
59
61
  required_rubygems_version: !ruby/object:Gem::Requirement
60
- none: false
61
62
  requirements:
62
63
  - - ! '>='
63
64
  - !ruby/object:Gem::Version
64
65
  version: '0'
65
66
  requirements: []
66
67
  rubyforge_project: consistent-hashing
67
- rubygems_version: 1.8.16
68
+ rubygems_version: 2.0.3
68
69
  signing_key:
69
70
  specification_version: 3
70
71
  summary: ''
71
72
  test_files:
73
+ - test/consistent_hashing/test_virtual_point.rb
72
74
  - test/consistent_hashing/test_avl_tree.rb
73
75
  - test/consistent_hashing/test_ring.rb
74
- - test/consistent_hashing/test_virtual_point.rb
75
76
  - test/test_consistent_hashing.rb