dcell 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57917a3592a960a4cb0276862ef2265b605018a0
4
+ data.tar.gz: b881c6dbafb70e2c2cf5d2cd5310c5ae1e585207
5
+ SHA512:
6
+ metadata.gz: 8c37e73b4e12019a862db91488f9ee06e3e400efb9ed648b1a3a6ba623d372c640e702f37c4c7abe07a673a6420ddc2659c4c32e4ad8b6a68634b568cf2900de
7
+ data.tar.gz: 8e2ecb1b6901f8e946dc4dde669b31c49d7eacb30584e57ba1a14cc1b5aa5dc78cf78ab5b5055835a73b44998f3e035e8ab4391a776572e6374b71ec05b96257
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ 0.14.0 (2013-05-07)
2
+ -------------------
3
+ * Allow InfoService to run on linux when lsb-release is missing
4
+ * Remove broken moneta adapter
5
+ * Use ephemeral mode for ZK adapter
6
+ * Add support for executing blocks over DCell
7
+
1
8
  0.13.0
2
9
  ------
3
10
  * First semi-stable release in nearly forever! Yay!
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- #gem 'celluloid', github: 'celluloid/celluloid'
4
- #gem 'celluloid-io', github: 'celluloid/celluloid-io'
5
- #gem 'celluloid-zmq', github: 'celluloid/celluloid-zmq'
6
- #gem 'reel', github: 'celluloid/reel'
3
+ gem 'celluloid', github: 'celluloid/celluloid', branch: 'master'
4
+ gem 'celluloid-io', github: 'celluloid/celluloid-io', branch: 'master'
5
+ gem 'celluloid-zmq', github: 'celluloid/celluloid-zmq', branch: 'master'
6
+ gem 'reel', github: 'celluloid/reel', branch: 'master'
7
7
 
8
8
  #gem 'ffi-rzmq', github: 'chuckremes/ffi-rzmq'
9
9
 
@@ -12,3 +12,5 @@ gem 'coveralls', require: false
12
12
 
13
13
  # Specify your gem's dependencies in dcell.gemspec
14
14
  gemspec
15
+
16
+ gem 'zk'
@@ -1,4 +1,5 @@
1
1
  require 'celluloid'
2
+ require 'reel'
2
3
  require 'celluloid/zmq'
3
4
 
4
5
  Celluloid::ZMQ.init
@@ -19,7 +20,6 @@ require 'dcell/server'
19
20
  require 'dcell/info_service'
20
21
 
21
22
  require 'dcell/registries/redis_adapter'
22
- #require 'dcell/registries/moneta_adapter'
23
23
 
24
24
  require 'dcell/celluloid_ext'
25
25
 
@@ -73,8 +73,32 @@ module Celluloid
73
73
  class SyncCall
74
74
  def _dump(level)
75
75
  uuid = DCell::RPC::Manager.register self
76
- payload = Marshal.dump([@caller,@method,@arguments,@block])
77
- "#{uuid}@#{DCell.id}:#{payload}"
76
+ payload = Marshal.dump([@sender,@method,@arguments,@block])
77
+ "#{uuid}@#{DCell.id}:rpc:#{payload}"
78
+ end
79
+
80
+ def self._load(string)
81
+ DCell::RPC._load(string)
82
+ end
83
+ end
84
+
85
+ class BlockProxy
86
+ def _dump(level)
87
+ uuid = DCell::RPC::Manager.register self
88
+ payload = Marshal.dump([@mailbox,@execution,@arguments])
89
+ "#{uuid}@#{DCell.id}:rpb:#{payload}"
90
+ end
91
+
92
+ def self._load(string)
93
+ DCell::RPC._load(string)
94
+ end
95
+ end
96
+
97
+ class BlockCall
98
+ def _dump(level)
99
+ uuid = DCell::RPC::Manager.register self
100
+ payload = Marshal.dump([@block_proxy,@sender,@arguments])
101
+ "#{uuid}@#{DCell.id}:rpbc:#{payload}"
78
102
  end
79
103
 
80
104
  def self._load(string)
@@ -45,7 +45,7 @@ module DCell
45
45
 
46
46
  cores = cpu_info.scan(/core id\s+: \d+/).uniq.size
47
47
  @cpu_count = cores > 0 ? cores : 1
48
- @distribution = `lsb_release -d`[/Description:\s+(.*)\s*$/, 1]
48
+ @distribution = discover_distribution
49
49
  else
50
50
  @cpu_type = @cpu_vendor = @cpu_speed = @cpu_count = nil
51
51
  end
@@ -90,6 +90,11 @@ module DCell
90
90
  days_string ? Integer(days_string) : 0
91
91
  end
92
92
 
93
+ def discover_distribution
94
+ `lsb_release -d`[/Description:\s+(.*)\s*$/, 1]
95
+ rescue Errno::ENOENT
96
+ end
97
+
93
98
  def to_hash
94
99
  uptime_string = `uptime`
95
100
 
@@ -22,29 +22,29 @@ module DCell
22
22
 
23
23
  # Query a node for the address of an actor
24
24
  class Find < Message
25
- attr_reader :caller, :name
25
+ attr_reader :sender, :name
26
26
 
27
- def initialize(caller, name)
27
+ def initialize(sender, name)
28
28
  super()
29
- @caller, @name = caller, name
29
+ @sender, @name = sender, name
30
30
  end
31
31
 
32
32
  def dispatch
33
- @caller << SuccessResponse.new(@id, Celluloid::Actor[@name])
33
+ @sender << SuccessResponse.new(@id, Celluloid::Actor[@name])
34
34
  end
35
35
  end
36
36
 
37
37
  # List all registered actors
38
38
  class List < Message
39
- attr_reader :caller
39
+ attr_reader :sender
40
40
 
41
- def initialize(caller)
41
+ def initialize(sender)
42
42
  super()
43
- @caller = caller
43
+ @sender = sender
44
44
  end
45
45
 
46
46
  def dispatch
47
- @caller << SuccessResponse.new(@id, Celluloid::Actor.registered)
47
+ @sender << SuccessResponse.new(@id, Celluloid::Actor.registered)
48
48
  end
49
49
  end
50
50
 
@@ -36,76 +36,34 @@ module DCell
36
36
  end
37
37
 
38
38
  @zk = ZK.new(*servers)
39
- @node_registry = NodeRegistry.new(@zk, @base_path)
40
- @global_registry = GlobalRegistry.new(@zk, @base_path)
39
+ @node_registry = Registry.new(@zk, @base_path, :nodes, true)
40
+ @global_registry = Registry.new(@zk, @base_path, :globals, false)
41
41
  end
42
42
 
43
- def clear_nodes
44
- @node_registry.clear
45
- end
46
-
47
- def clear_globals
48
- @global_registry.clear
49
- end
50
-
51
- class NodeRegistry
52
- def initialize(zk, base_path)
53
- @zk, @base_path = zk, "#{base_path}/nodes"
54
- @zk.mkdir_p @base_path
55
- end
56
-
57
- def get(node_id)
58
- result, _ = @zk.get("#{@base_path}/#{node_id}")
59
- result
60
- rescue ZK::Exceptions::NoNode
61
- end
62
-
63
- def set(node_id, addr)
64
- path = "#{@base_path}/#{node_id}"
65
- @zk.set path, addr
66
- rescue ZK::Exceptions::NoNode
67
- @zk.create path, addr
68
- end
69
-
70
- def nodes
71
- @zk.children @base_path
72
- end
73
-
74
- def clear
75
- @zk.rm_rf @base_path
76
- @zk.mkdir_p @base_path
77
- end
78
- end
79
-
80
- def get_node(node_id); @node_registry.get(node_id) end
81
- def set_node(node_id, addr); @node_registry.set(node_id, addr) end
82
- def nodes; @node_registry.nodes end
83
-
84
- class GlobalRegistry
85
- def initialize(zk, base_path)
86
- @zk, @base_path = zk, "#{base_path}/globals"
43
+ class Registry
44
+ def initialize(zk, base_path, name, ephemeral)
45
+ @zk = zk
46
+ @base_path = File.join(base_path, name.to_s)
47
+ @ephemeral = ephemeral
87
48
  @zk.mkdir_p @base_path
88
49
  end
89
50
 
90
51
  def get(key)
91
- value, _ = @zk.get "#{@base_path}/#{key}"
92
- Marshal.load value
52
+ result, _ = @zk.get("#{@base_path}/#{key}")
53
+ Marshal.load result
93
54
  rescue ZK::Exceptions::NoNode
94
55
  end
95
56
 
96
- # Set a global value
97
57
  def set(key, value)
98
58
  path = "#{@base_path}/#{key}"
99
59
  string = Marshal.dump value
100
-
101
60
  @zk.set path, string
102
61
  rescue ZK::Exceptions::NoNode
103
- @zk.create path, string
62
+ @zk.create path, string, :ephemeral => @ephemeral
104
63
  end
105
64
 
106
- # The keys to all globals in the system
107
- def global_keys
108
- @zk.children(@base_path)
65
+ def all
66
+ @zk.children @base_path
109
67
  end
110
68
 
111
69
  def clear
@@ -114,9 +72,16 @@ module DCell
114
72
  end
115
73
  end
116
74
 
75
+ def get_node(node_id); @node_registry.get(node_id) end
76
+ def set_node(node_id, addr); @node_registry.set(node_id, addr) end
77
+ def nodes; @node_registry.all end
78
+ def clear_nodes; @node_registry.clear end
79
+
117
80
  def get_global(key); @global_registry.get(key) end
118
81
  def set_global(key, value); @global_registry.set(key, value) end
119
- def global_keys; @global_registry.global_keys end
82
+ def global_keys; @global_registry.all end
83
+ def clear_globals; @global_registry.clear end
84
+
120
85
  end
121
86
  end
122
- end
87
+ end
@@ -1,15 +1,39 @@
1
1
  require 'weakref'
2
2
 
3
3
  module DCell
4
+ class RPB < Celluloid::BlockProxy
5
+ def initialize(id, mailbox, execution, arguments)
6
+ @id, @mailbox, @execution, @arguments = id, mailbox, execution, arguments
7
+ end
8
+
9
+ # Custom marshaller for compatibility with Celluloid::Mailbox marshalling
10
+ def _dump(level)
11
+ payload = Marshal.dump [@mailbox, @execution, @arguments]
12
+ "#{@id}:rpb:#{payload}"
13
+ end
14
+ end
15
+
16
+ class RPBC < Celluloid::BlockCall
17
+ def initialize(id, block_proxy, sender, arguments)
18
+ @id, @block_proxy, @sender, @arguments = id, block_proxy, sender, arguments
19
+ end
20
+
21
+ # Custom marshaller for compatibility with Celluloid::Mailbox marshalling
22
+ def _dump(level)
23
+ payload = Marshal.dump [@block_proxy, @sender, @arguments]
24
+ "#{@id}:rpbc:#{payload}"
25
+ end
26
+ end
27
+
4
28
  class RPC < Celluloid::SyncCall
5
- def initialize(id, caller, method, arguments, block)
6
- @id, @caller, @method, @arguments, @block = id, caller, method, arguments, block
29
+ def initialize(id, sender, method, arguments, block)
30
+ @id, @sender, @method, @arguments, @block = id, sender, method, arguments, block
7
31
  end
8
32
 
9
33
  # Custom marshaller for compatibility with Celluloid::Mailbox marshalling
10
34
  def _dump(level)
11
- payload = Marshal.dump [@caller, @method, @arguments, @block]
12
- "#{@id}:#{payload}"
35
+ payload = Marshal.dump [@sender, @method, @arguments, @block]
36
+ "#{@id}:rpc:#{payload}"
13
37
  end
14
38
 
15
39
  # Loader for custom marshal format
@@ -23,8 +47,13 @@ module DCell
23
47
  if DCell.id == node_id
24
48
  Manager.claim uuid
25
49
  else
26
- caller, method, arguments, block = Marshal.load(string)
27
- RPC.new("#{uuid}@#{node_id}", caller, method, arguments, block)
50
+ type = string.slice!(0, string.index(":") + 1)
51
+ types = {
52
+ "rpc" => RPC,
53
+ "rpb" => RPB,
54
+ "rpbc" => RPBC,
55
+ }
56
+ types.fetch(type[0..-2]).new("#{uuid}@#{node_id}", *Marshal.load(string))
28
57
  end
29
58
  end
30
59
 
@@ -1,3 +1,3 @@
1
1
  module DCell
2
- VERSION = "0.13.0"
2
+ VERSION = "0.14.0"
3
3
  end
@@ -26,6 +26,14 @@ describe DCell::ActorProxy do
26
26
  @remote_actor.value.should == 42
27
27
  end
28
28
 
29
+ it "handles blocks" do
30
+ result = nil
31
+ @remote_actor.win do |value|
32
+ result = value
33
+ end
34
+ result.should == 10000
35
+ end
36
+
29
37
  it "makes future calls to remote actors" do
30
38
  @remote_actor.future(:value).value.should == 42
31
39
  end
@@ -1,11 +1,7 @@
1
- # The Zookeeper CRuby dependency is pretty annoying :(
2
- # Disabling until this can be spun off into a separate gem
3
- =begin
4
1
  require 'spec_helper'
5
2
  require 'dcell/registries/zk_adapter'
6
3
 
7
- describe DCell::Registry::ZkAdapter do
4
+ describe DCell::Registry::ZkAdapter, :pending => ENV["CI"] && "no zookeeper" do
8
5
  subject { DCell::Registry::ZkAdapter.new :server => 'localhost', :env => 'test' }
9
6
  it_behaves_like "a DCell registry"
10
7
  end
11
- =end
@@ -20,6 +20,11 @@ class TestActor
20
20
  DCell::Global[:the_answer]
21
21
  end
22
22
 
23
+ def win(&block)
24
+ yield 10000
25
+ 20000
26
+ end
27
+
23
28
  def crash
24
29
  raise "the spec purposely crashed me :("
25
30
  end
metadata CHANGED
@@ -1,126 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dcell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
5
- prerelease:
4
+ version: 0.14.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tony Arcieri
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-19 00:00:00.000000000 Z
11
+ date: 2013-05-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: celluloid
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.13.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.13.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: celluloid-zmq
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.13.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.13.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: reel
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: redis
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: redis-namespace
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rake
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rspec
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '0'
126
111
  description: DCell is an distributed object framework based on Celluloid built on
@@ -170,7 +155,6 @@ files:
170
155
  - lib/dcell/node.rb
171
156
  - lib/dcell/node_manager.rb
172
157
  - lib/dcell/registries/cassandra_adapter.rb
173
- - lib/dcell/registries/moneta_adapter.rb
174
158
  - lib/dcell/registries/redis_adapter.rb
175
159
  - lib/dcell/registries/zk_adapter.rb
176
160
  - lib/dcell/responses.rb
@@ -186,7 +170,6 @@ files:
186
170
  - spec/dcell/explorer_spec.rb
187
171
  - spec/dcell/global_spec.rb
188
172
  - spec/dcell/node_spec.rb
189
- - spec/dcell/registries/moneta_adapter_spec.rb
190
173
  - spec/dcell/registries/redis_adapter_spec.rb
191
174
  - spec/dcell/registries/zk_adapter_spec.rb
192
175
  - spec/spec_helper.rb
@@ -198,33 +181,26 @@ files:
198
181
  - tasks/zookeeper.task
199
182
  homepage: http://github.com/celluloid/dcell
200
183
  licenses: []
184
+ metadata: {}
201
185
  post_install_message:
202
186
  rdoc_options: []
203
187
  require_paths:
204
188
  - lib
205
189
  required_ruby_version: !ruby/object:Gem::Requirement
206
- none: false
207
190
  requirements:
208
- - - ! '>='
191
+ - - '>='
209
192
  - !ruby/object:Gem::Version
210
193
  version: '0'
211
- segments:
212
- - 0
213
- hash: 3616164111420951130
214
194
  required_rubygems_version: !ruby/object:Gem::Requirement
215
- none: false
216
195
  requirements:
217
- - - ! '>='
196
+ - - '>='
218
197
  - !ruby/object:Gem::Version
219
198
  version: '0'
220
- segments:
221
- - 0
222
- hash: 3616164111420951130
223
199
  requirements: []
224
200
  rubyforge_project:
225
- rubygems_version: 1.8.23
201
+ rubygems_version: 2.0.3
226
202
  signing_key:
227
- specification_version: 3
203
+ specification_version: 4
228
204
  summary: An asynchronous distributed object framework based on Celluloid
229
205
  test_files:
230
206
  - spec/dcell/actor_proxy_spec.rb
@@ -233,7 +209,6 @@ test_files:
233
209
  - spec/dcell/explorer_spec.rb
234
210
  - spec/dcell/global_spec.rb
235
211
  - spec/dcell/node_spec.rb
236
- - spec/dcell/registries/moneta_adapter_spec.rb
237
212
  - spec/dcell/registries/redis_adapter_spec.rb
238
213
  - spec/dcell/registries/zk_adapter_spec.rb
239
214
  - spec/spec_helper.rb
@@ -1,61 +0,0 @@
1
- require 'moneta'
2
- require 'moneta/memory'
3
-
4
- module DCell
5
- module Registry
6
- class MonetaAdapter
7
- def initialize(options)
8
- # Convert all options to symbols :/
9
- options = options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
10
-
11
- @env = options[:env] || 'production'
12
- @namespace = options[:namespace] || "dcell_#{@env}"
13
-
14
- # We might want to use something like a TieredCache later..
15
- # Memory + BasicFile..
16
- # @moneta = Moneta::TieredCache.new options
17
- @moneta = Moneta::Memory.new options
18
-
19
- @node_registry = Registry.new(@moneta, :nodes)
20
- @global_registry = Registry.new(@moneta, :globals)
21
- end
22
-
23
- class Registry
24
- def initialize(moneta, name)
25
- @name = name
26
- @moneta = moneta
27
- end
28
-
29
- def get(key)
30
- @moneta[@name][key.to_s]
31
- end
32
-
33
- def set(key, value)
34
- @moneta[@name][key.to_s] = value
35
- end
36
-
37
- def all
38
- @moneta[@name].keys
39
- end
40
-
41
- # DCell registry behaviors
42
- alias_method :nodes, :all
43
- alias_method :global_keys, :all
44
-
45
- def clear
46
- @moneta.delete(@name)
47
- end
48
- end
49
-
50
- def get_node(node_id); @node_registry.get(node_id) end
51
- def set_node(node_id, addr); @node_registry.set(node_id, addr) end
52
- def nodes; @node_registry.nodes end
53
- def clear_nodes; @node_registry.clear end
54
-
55
- def get_global(key); @global_registry.get(key) end
56
- def set_global(key, value); @global_registry.set(key, value) end
57
- def global_keys; @global_registry.global_keys end
58
- def clear_globals; @global_registry.clear end
59
- end
60
- end
61
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
-
3
- =begin
4
- describe DCell::Registry::MonetaAdapter do
5
- subject { DCell::Registry::MonetaAdapter.new :env => "test" }
6
- it_behaves_like "a DCell registry"
7
- end
8
- =end