stn-dcell 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +7 -0
  4. data/.rspec +4 -0
  5. data/.travis.yml +30 -0
  6. data/CHANGES.md +53 -0
  7. data/Gemfile +18 -0
  8. data/LICENSE.txt +20 -0
  9. data/README.md +168 -0
  10. data/Rakefile +4 -0
  11. data/benchmarks/messaging.rb +73 -0
  12. data/benchmarks/receiver.rb +37 -0
  13. data/dcell.gemspec +29 -0
  14. data/examples/itchy.rb +26 -0
  15. data/examples/scratchy.rb +12 -0
  16. data/explorer/css/bootstrap-responsive.css +686 -0
  17. data/explorer/css/bootstrap-responsive.min.css +12 -0
  18. data/explorer/css/bootstrap.css +3990 -0
  19. data/explorer/css/bootstrap.min.css +689 -0
  20. data/explorer/css/explorer.css +28 -0
  21. data/explorer/ico/favicon.ico +0 -0
  22. data/explorer/img/glyphicons-halflings-white.png +0 -0
  23. data/explorer/img/glyphicons-halflings.png +0 -0
  24. data/explorer/img/logo.png +0 -0
  25. data/explorer/index.html.erb +94 -0
  26. data/explorer/js/bootstrap.js +1726 -0
  27. data/explorer/js/bootstrap.min.js +6 -0
  28. data/lib/dcell.rb +127 -0
  29. data/lib/dcell/actor_proxy.rb +30 -0
  30. data/lib/dcell/celluloid_ext.rb +120 -0
  31. data/lib/dcell/directory.rb +31 -0
  32. data/lib/dcell/explorer.rb +74 -0
  33. data/lib/dcell/future_proxy.rb +32 -0
  34. data/lib/dcell/global.rb +23 -0
  35. data/lib/dcell/info_service.rb +122 -0
  36. data/lib/dcell/mailbox_proxy.rb +53 -0
  37. data/lib/dcell/messages.rb +65 -0
  38. data/lib/dcell/node.rb +138 -0
  39. data/lib/dcell/node_manager.rb +79 -0
  40. data/lib/dcell/registries/cassandra_adapter.rb +126 -0
  41. data/lib/dcell/registries/mongodb_adapter.rb +85 -0
  42. data/lib/dcell/registries/redis_adapter.rb +95 -0
  43. data/lib/dcell/registries/zk_adapter.rb +123 -0
  44. data/lib/dcell/responses.rb +16 -0
  45. data/lib/dcell/router.rb +46 -0
  46. data/lib/dcell/rpc.rb +95 -0
  47. data/lib/dcell/rspec.rb +1 -0
  48. data/lib/dcell/server.rb +73 -0
  49. data/lib/dcell/version.rb +3 -0
  50. data/logo.png +0 -0
  51. data/spec/dcell/actor_proxy_spec.rb +72 -0
  52. data/spec/dcell/celluloid_ext_spec.rb +32 -0
  53. data/spec/dcell/directory_spec.rb +22 -0
  54. data/spec/dcell/explorer_spec.rb +17 -0
  55. data/spec/dcell/global_spec.rb +25 -0
  56. data/spec/dcell/node_spec.rb +23 -0
  57. data/spec/dcell/registries/mongodb_adapter_spec.rb +7 -0
  58. data/spec/dcell/registries/redis_adapter_spec.rb +6 -0
  59. data/spec/dcell/registries/zk_adapter_spec.rb +28 -0
  60. data/spec/options/01-options.rb +10 -0
  61. data/spec/options/02-registry.rb +13 -0
  62. data/spec/spec_helper.rb +28 -0
  63. data/spec/support/helpers.rb +46 -0
  64. data/spec/support/registry_examples.rb +35 -0
  65. data/spec/test_node.rb +38 -0
  66. data/tasks/cassandra.task +84 -0
  67. data/tasks/rspec.task +7 -0
  68. data/tasks/zookeeper.task +58 -0
  69. metadata +239 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 99f99f9345e669d2241b7fce6fc22464cc0d8469
4
+ data.tar.gz: 604466b8723cb8e228474a4d1f44e1adbab62812
5
+ SHA512:
6
+ metadata.gz: 673cc9abf920468319875aca305aafd1afa25aa7f69795dd12a693935390c5acb1e2d998118d3b56ba733343e2728e29e4c4c035c94572c42d36803344b6801d
7
+ data.tar.gz: f162d1bb986e35f1b2d6ff8049d483cc057915dac713556cf44d60fc3c4dceb5bd2430c3d16458f230a5cc63c9bba68a313b8964706b4b37bfb5b3ca4a088796
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service-name: travis-pro
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ tmp/*
6
+ zookeeper/*
7
+ coverage
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --format documentation
3
+ --backtrace
4
+ --warnings
data/.travis.yml ADDED
@@ -0,0 +1,30 @@
1
+ language: ruby
2
+
3
+ before_install: sudo apt-get install libzmq3-dev
4
+
5
+ services:
6
+ - mongodb
7
+ - redis-server
8
+
9
+ rvm:
10
+ - 1.9.3
11
+ - 2.0.0
12
+ - ruby-head
13
+ - jruby-19mode
14
+ - jruby-head
15
+ - rbx-19mode
16
+
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: ruby-head
20
+ - rvm: jruby-head
21
+ - rvm: jruby-19mode
22
+ - rvm: rbx-19mode # rbx seems to be losing exception messages o_O
23
+
24
+ branches:
25
+ only:
26
+ - master
27
+
28
+ env:
29
+ - DCELL_TEST_ADAPTER=redis
30
+ - DCELL_TEST_ADAPTER=mongodb
data/CHANGES.md ADDED
@@ -0,0 +1,53 @@
1
+ 0.16.0 (2014-09-04)
2
+ -------------------
3
+ * Timeouts for cell discovery
4
+ * Update Explorer to use new Reel API
5
+
6
+ 0.15.0 (2013-09-04)
7
+ -------------------
8
+ * Tracking release for Celluloid 0.15
9
+ * Use the celluloid-redis gem with the Redis adapter
10
+
11
+ 0.14.0 (2013-05-07)
12
+ -------------------
13
+ * Allow InfoService to run on linux when lsb-release is missing
14
+ * Remove broken moneta adapter
15
+ * Use ephemeral mode for ZK adapter
16
+ * Add support for executing blocks over DCell
17
+
18
+ 0.13.0
19
+ ------
20
+ * First semi-stable release in nearly forever! Yay!
21
+ * Rip out the unstable gossip system, replace the original Zookeeper and
22
+ Redis adapters.
23
+ * Compatibility fixes with newer versions of the Celluloid suite
24
+
25
+ 0.10.0
26
+ ------
27
+ * DCell::Explorer provides a web UI with Reel
28
+ * Info service at DCell::Node#[:info]
29
+ * Distributed gossip protocol, now default adapter
30
+ * Support for marshaling Celluloid::Futures
31
+ * Cassandra registry
32
+ * Initial DCell::NodeManager
33
+ * celluloid-zmq split out into a separate gem
34
+ * Use Celluloid.uuid for mailbox and call IDs
35
+
36
+ 0.9.0
37
+ -----
38
+ * Use new Celluloid::ZMQ APIs
39
+
40
+ 0.8.0
41
+ -----
42
+ * Track calls in-flight with DCell::RPC and DCell::RPC::Manager
43
+ * Compatibility changes for Celluloid 0.8.0
44
+
45
+ 0.7.1
46
+ -----
47
+ * Bump version to match Celluloid
48
+ * Factor 0MQ bindings into the celluloid-zmq gem
49
+ * Heartbeat system for detecting downed nodes
50
+
51
+ 0.0.1
52
+ -----
53
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'celluloid', github: 'celluloid/celluloid', tag: 'v0.16.0'
4
+ gem 'celluloid-io', github: 'celluloid/celluloid-io', tag: 'v0.16.1'
5
+ gem 'celluloid-zmq', github: 'celluloid/celluloid-zmq', tag: 'v0.16.0'
6
+ gem 'celluloid-redis', github: 'celluloid/celluloid-redis', branch: 'master'
7
+ gem 'reel', github: 'celluloid/reel', tag: 'v0.4.0'
8
+
9
+ #gem 'ffi-rzmq', github: 'chuckremes/ffi-rzmq'
10
+
11
+ gem 'jruby-openssl', platform: :jruby
12
+ gem 'coveralls', require: false
13
+
14
+ # Specify your gem's dependencies in dcell.gemspec
15
+ gemspec
16
+
17
+ gem 'zk'
18
+ gem 'mongoid'
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Tony Arcieri
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,168 @@
1
+ ![DCell](https://github.com/celluloid/dcell/raw/master/logo.png)
2
+ =====
3
+ [![Gem Version](https://badge.fury.io/rb/dcell.png)](http://rubygems.org/gems/dcell)
4
+ [![Build Status](https://secure.travis-ci.org/celluloid/dcell.png?branch=master)](http://travis-ci.org/celluloid/dcell)
5
+ [![Code Climate](https://codeclimate.com/github/celluloid/dcell.png)](https://codeclimate.com/github/celluloid/dcell)
6
+ [![Coverage Status](https://coveralls.io/repos/celluloid/dcell/badge.png?branch=master)](https://coveralls.io/r/celluloid/dcell)
7
+
8
+ > "Objects can message objects transparently that live on other machines
9
+ > over the network, and you don't have to worry about the networking gunk,
10
+ > and you don't have to worry about finding them, and you don't have to
11
+ > worry about anything. It's just as if you messaged an object that's
12
+ > right next door."
13
+ > _--Steve Jobs describing the NeXT Portable Distributed Object system_
14
+
15
+ DCell is a simple and easy way to build distributed applications in Ruby.
16
+ Somewhat similar to DRb, DCell lets you easily expose Ruby objects as network
17
+ services, and call them remotely just like you would any other Ruby object.
18
+ However, unlike DRb all objects in the system are concurrent. You can create
19
+ and register several available services on a given node, obtain handles to
20
+ them, and easily pass these handles around the network just like any other
21
+ objects.
22
+
23
+ DCell is a distributed extension to [Celluloid][celluloid], which provides
24
+ concurrent objects for Ruby with many of the features of Erlang, such as the
25
+ ability to supervise objects and restart them when they crash, and also link to
26
+ other objects and receive event notifications of when they crash. This makes
27
+ it easier to build robust, fault-tolerant distributed systems.
28
+
29
+ DCell uses the [0MQ][zeromq] messaging protocol which provides a robust,
30
+ fault-tolerant brokerless transport for asynchronous messages sent between
31
+ nodes. DCell is built on top of the [Celluloid::ZMQ][celluloid-zmq] library,
32
+ which provides a Celluloid-oriented wrapper around the underlying
33
+ [ffi-rzmq][ffi-rzmq] library.
34
+
35
+ [Please see the DCell Wiki](https://github.com/celluloid/dcell/wiki)
36
+ for more detailed documentation and usage notes.
37
+
38
+ Like DCell? [Join the Celluloid Google Group][googlegroup]
39
+
40
+ [celluloid]: http://celluloid.io/
41
+ [zeromq]: http://www.zeromq.org/
42
+ [celluloid-zmq]: https://github.com/celluloid/celluloid-zmq
43
+ [ffi-rzmq]: https://github.com/chuckremes/ffi-rzmq
44
+ [googlegroup]: http://groups.google.com/group/celluloid-ruby
45
+
46
+ ### Is it any good?
47
+
48
+ [Yes.](http://news.ycombinator.com/item?id=3067434)
49
+
50
+ ### Is It "Production Ready™"?
51
+
52
+ Not entirely, but eager early adopters are welcome!
53
+
54
+ Installation
55
+ ------------
56
+
57
+ Add this line to your application's Gemfile:
58
+
59
+ gem 'dcell'
60
+
61
+ And then execute:
62
+
63
+ $ bundle
64
+
65
+ Or install it yourself as:
66
+
67
+ $ gem install dcell
68
+
69
+ Inside of your Ruby program do:
70
+
71
+ require 'dcell'
72
+
73
+ ...to pull it in as a dependency.
74
+
75
+ Example
76
+ -------
77
+
78
+ Copy and paste this into `itchy.rb` (or run `bundle exec examples/itchy.rb`):
79
+
80
+ ```ruby
81
+ require 'dcell'
82
+
83
+ DCell.start :id => "itchy", :addr => "tcp://127.0.0.1:9001"
84
+
85
+ class Itchy
86
+ include Celluloid
87
+
88
+ def initialize
89
+ puts "Ready for mayhem!"
90
+ @n = 0
91
+ end
92
+
93
+ def fight
94
+ @n = (@n % 6) + 1
95
+ if @n <= 3
96
+ puts "Bite!"
97
+ else
98
+ puts "Fight!"
99
+ end
100
+ end
101
+ end
102
+
103
+ Itchy.supervise_as :itchy
104
+ sleep
105
+ ```
106
+
107
+ You can now launch itchy with:
108
+
109
+ ```
110
+ ruby itchy.rb
111
+ ```
112
+
113
+ Now copy and paste the following into `scratchy.rb` (also in examples)
114
+
115
+ ```ruby
116
+ require 'dcell'
117
+
118
+ DCell.start :id => "scratchy", :addr => "tcp://127.0.0.1:9002"
119
+ itchy_node = DCell::Node["itchy"]
120
+
121
+ puts "Fighting itchy! (check itchy's output)"
122
+
123
+ 6.times do
124
+ itchy_node[:itchy].fight
125
+ sleep 1
126
+ end
127
+ ```
128
+
129
+ Now run scratchy side-by-side with itchy. You should see this on itchy:
130
+
131
+ ```
132
+ $ bundle exec examples/itchy.rb
133
+ Ready for mayhem!
134
+ I, [2012-12-25T22:52:45.362355 #74272] INFO -- : Connected to scratchy
135
+ Bite!
136
+ Bite!
137
+ Bite!
138
+ Fight!
139
+ Fight!
140
+ Fight!
141
+ ```
142
+
143
+ This is a basic example how individual DCell::Nodes have registered Celluloid actors which can be accessed remotely by other DCell::Nodes.
144
+
145
+ Supported Platforms
146
+ -------------------
147
+
148
+ DCell works on Ruby 1.9.3, JRuby 1.6, and Rubinius 2.0.
149
+
150
+ DCell requires Ruby 1.9 mode on all interpreters. This works out of the
151
+ box on MRI/YARV, and requires the following flags elsewhere:
152
+
153
+ * JRuby: --1.9 command line option, or JRUBY_OPTS=--1.9 environment variable
154
+ * rbx: -X19 command line option
155
+
156
+ Contributing to DCell
157
+ -------------------------
158
+
159
+ * Fork this repository on github
160
+ * Make your changes and send me a pull request
161
+ * If I like them I'll merge them
162
+ * If I've accepted a patch, feel free to ask for commit access
163
+
164
+ Copyright
165
+ ---------
166
+
167
+ Copyright (c) 2012 Tony Arcieri. Distributed under the MIT License.
168
+ See LICENSE.txt for further details.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ Dir["tasks/**/*.task"].each { |task| load task }
3
+
4
+ task :default => :spec
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'benchmark'
4
+
5
+ require 'rubygems'
6
+ require 'bundler'
7
+ Bundler.setup
8
+
9
+ require 'dcell'
10
+ DCell.setup
11
+ DCell.run!
12
+
13
+ RECEIVER_PORT = 2043
14
+
15
+ $receiver_pid = Process.spawn Gem.ruby, File.expand_path("../receiver.rb", __FILE__)
16
+ STDERR.print "Waiting for test node to start up..."
17
+
18
+ socket = nil
19
+ 30.times do
20
+ begin
21
+ socket = TCPSocket.open("127.0.0.1", RECEIVER_PORT)
22
+ break if socket
23
+ rescue Errno::ECONNREFUSED
24
+ STDERR.print "."
25
+ sleep 1
26
+ end
27
+ end
28
+
29
+ if socket
30
+ STDERR.puts " done!"
31
+ socket.close
32
+ else
33
+ STDERR.puts " FAILED!"
34
+ raise "couldn't connect to test node!"
35
+ end
36
+
37
+ class AsyncPerformanceTest
38
+ include Celluloid
39
+
40
+ def initialize(progenator, n = 10000)
41
+ @n = n
42
+ @receiver = progenator.spawn_async_receiver(n, current_actor)
43
+ end
44
+
45
+ def run
46
+ @n.times { @receiver.async.increment }
47
+ wait :complete
48
+ end
49
+
50
+ def complete
51
+ signal :complete
52
+ end
53
+ end
54
+
55
+ DCell.start :id => "messaging_node", :addr => "tcp://127.0.0.1:2042",
56
+ :directory => {
57
+ :id => "benchmark_receiver",
58
+ :addr => "tcp://127.0.0.1:#{RECEIVER_PORT}"
59
+ }
60
+
61
+ receiver = DCell::Node['benchmark_receiver']
62
+ progenator = receiver[:progenator]
63
+
64
+ test = AsyncPerformanceTest.new progenator
65
+ time = Benchmark.measure { test.run }.real
66
+ messages_per_second = 1 / time * 10000
67
+
68
+ puts "messages_per_second: #{"%0.2f" % messages_per_second}"
69
+
70
+ Process.kill 9, $receiver_pid
71
+ Process.wait $receiver_pid rescue nil
72
+
73
+ exit 0
@@ -0,0 +1,37 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require 'dcell'
6
+ DCell.start :id => 'benchmark_receiver', :addr => 'tcp://127.0.0.1:2043'
7
+
8
+ class AsyncReceiver
9
+ include Celluloid
10
+ attr_reader :count
11
+
12
+ def initialize(n, actor)
13
+ @n, @actor = n, actor
14
+ @count = 0
15
+ end
16
+
17
+ def increment
18
+ @count += 1
19
+ @actor.async.complete if @count == @n
20
+ @count
21
+ end
22
+ end
23
+
24
+ class Progenator
25
+ include Celluloid
26
+
27
+ def spawn_async_receiver(n, actor)
28
+ AsyncReceiver.new(n, actor)
29
+ end
30
+ end
31
+
32
+ class BenchmarkApplication < Celluloid::SupervisionGroup
33
+ supervise DCell::SupervisionGroup
34
+ supervise Progenator, :as => :progenator
35
+ end
36
+
37
+ BenchmarkApplication.run
data/dcell.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "dcell/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "stn-dcell"
7
+ gem.version = DCell::VERSION
8
+ gem.license = 'MIT'
9
+ gem.authors = ["Tony Arcieri"]
10
+ gem.email = ["tony.arcieri@gmail.com"]
11
+ gem.homepage = "http://github.com/celluloid/dcell"
12
+ gem.summary = "An asynchronous distributed object framework based on Celluloid"
13
+ gem.description = "DCell is an distributed object framework based on Celluloid built on 0MQ and Zookeeper"
14
+
15
+ gem.files = `git ls-files`.split("\n")
16
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency "celluloid", "~> 0.16.0"
21
+ gem.add_runtime_dependency "celluloid-zmq", "~> 0.16.0"
22
+ gem.add_runtime_dependency "reel", "~> 0.4.0"
23
+ gem.add_runtime_dependency "http", "~> 0.5.0"
24
+ gem.add_runtime_dependency "celluloid-redis"
25
+ gem.add_runtime_dependency "redis-namespace"
26
+
27
+ gem.add_development_dependency "rake"
28
+ gem.add_development_dependency "rspec", "~> 2.14.0"
29
+ end