rubyhaze 0.0.5-jruby → 0.0.6-jruby

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -32,7 +32,7 @@ Let's open another console to check how this distributed hash works:
32
32
 
33
33
  == Distributed Objects
34
34
 
35
- Check out the [rubyhaze-persisted|http://github.com/aemadrid/rubyhaze-persisted] gem to get your own distributed ruby objects:
35
+ Check out the http://github.com/aemadrid/rubyhaze-persisted gem to get your own distributed ruby objects:
36
36
 
37
37
  shell> rvm jruby
38
38
  shell> gem install rubyhaze-persisted
data/Rakefile CHANGED
@@ -7,8 +7,8 @@ begin
7
7
  require 'jeweler'
8
8
  Jeweler::Tasks.new do |gem|
9
9
  gem.name = "rubyhaze"
10
- gem.summary = %Q{JRuby wrapper to play with Hazelcast}
11
- gem.description = %Q{RubyHaze is a little gem that wraps the Java Hazelcast library into a more comfortable Ruby package (in JRuby, of course).}
10
+ gem.summary = %Q{Hazelcast distributed objects in my JRuby}
11
+ gem.description = %Q{RubyHaze is a little gem that wraps the Java Hazelcast library into a more comfortable JRuby package.}
12
12
  gem.email = "aemadrid@gmail.com"
13
13
  gem.homepage = "http://github.com/aemadrid/rubyhaze"
14
14
  gem.authors = ["Adrian Madrid"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
Binary file
@@ -4,7 +4,7 @@ require 'java'
4
4
  module RubyHaze
5
5
 
6
6
  MODE = "client" unless defined? MODE
7
- GEM_JAR_PATH = File.expand_path(File.dirname(__FILE__) + '/../../jars/hazelcast-client-1.8.5.jar') unless defined? GEM_JAR_PATH
7
+ GEM_JAR_PATH = File.expand_path(File.dirname(__FILE__) + '/../../jars/hazelcast-client-1.9-RC.jar') unless defined? GEM_JAR_PATH
8
8
  JAR_PATH = (ENV['HAZELCAST_CLIENT_JAR_PATH'] || GEM_JAR_PATH) unless defined? JAR_PATH
9
9
 
10
10
  end
data/lib/rubyhaze/node.rb CHANGED
@@ -4,7 +4,7 @@ require 'java'
4
4
  module RubyHaze
5
5
 
6
6
  MODE = "node" unless defined? MODE
7
- GEM_JAR_PATH = File.expand_path(File.dirname(__FILE__) + '/../../jars/hazelcast-1.8.5.jar') unless defined? GEM_JAR_PATH
7
+ GEM_JAR_PATH = File.expand_path(File.dirname(__FILE__) + '/../../jars/hazelcast-1.9-RC.jar') unless defined? GEM_JAR_PATH
8
8
  JAR_PATH = (ENV['HAZELCAST_NODE_JAR_PATH'] || GEM_JAR_PATH) unless defined? JAR_PATH
9
9
 
10
10
  end
@@ -9,4 +9,8 @@ class RubyHaze::Queue
9
9
  @proxy_object = Hazelcast.get_queue @name
10
10
  end
11
11
 
12
+ def poll(timeout = 5, unit = :seconds)
13
+ @proxy_object.poll timeout, java.util.concurrent.TimeUnit.const_get(unit.to_s.upcase)
14
+ end
15
+
12
16
  end
data/lib/rubyhaze.rb CHANGED
@@ -27,22 +27,30 @@ module RubyHaze
27
27
 
28
28
  java_import 'com.hazelcast.core.Hazelcast'
29
29
 
30
+ def connected?
31
+ !!@connected
32
+ end
33
+
30
34
  # To start a cluster we can pass a hash of options or nil to load it from ./hazelcast.yml if available and a Config
31
35
  # object will be generated.
32
36
  def init(options = nil)
33
- unless @connected
37
+ if connected?
38
+ puts ">> Already connected with Hazelcast ..."
39
+ false
40
+ else
34
41
  if options
35
42
  config = RubyHaze::Config.new(options).proxy_object
36
43
  Hazelcast.init config
37
- end
38
- at_exit do
39
- puts ">> Shutting down Hazelcast ..."
40
- Hazelcast.shutdown
41
- puts ">> ... done!"
44
+ else
45
+ Hazelcast.cluster
42
46
  end
43
47
  @connected = true
44
48
  end
45
- Hazelcast.cluster
49
+ end
50
+
51
+ def shutdown
52
+ @connected = false
53
+ Hazelcast.shutdown
46
54
  end
47
55
 
48
56
  def random_uuid
@@ -73,6 +81,14 @@ module RubyHaze
73
81
 
74
82
  end
75
83
 
84
+ at_exit do
85
+ if RubyHaze.connected?
86
+ puts ">> Shutting down Hazelcast before closing shop ..."
87
+ RubyHaze.shutdown
88
+ puts ">> ... done!"
89
+ end
90
+ end
91
+
76
92
  require 'rubyhaze/mixins/proxy'
77
93
  require 'rubyhaze/mixins/compare'
78
94
  require 'rubyhaze/mixins/native_exception'
data/test/helper.rb CHANGED
@@ -1,8 +1,35 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../lib/rubyhaze')
2
- require 'test/unit'
3
- require 'forwardable'
4
- require 'date'
1
+ unless HELPER_LOADED
5
2
 
6
- RubyHaze.init :group => { :username => "test", :password => "test" }
3
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/rubyhaze')
4
+ require 'test/unit'
5
+ require 'forwardable'
6
+ require 'date'
7
7
 
8
+ # Load the Hazelcast cluster
9
+ RubyHaze.init :group => { :username => "test", :password => "test" }
8
10
 
11
+ # Grab notices
12
+ class Notices
13
+ class << self
14
+ extend Forwardable
15
+ def all
16
+ @all ||= []
17
+ end
18
+ def_delegators :all, :size, :<<, :first, :last, :clear, :map
19
+ end
20
+ end
21
+
22
+ # Listen on messages
23
+ class TestListener
24
+ def initialize(name)
25
+ @name = name
26
+ end
27
+ def on_message(msg)
28
+ Notices << "[#{@name}] #{msg}"
29
+ end
30
+ end
31
+
32
+ # Finished loading helpers
33
+ HELPER_LOADED = true
34
+
35
+ end
data/test/test_queue.rb CHANGED
@@ -4,14 +4,15 @@ class TestRubyHazeQueue < Test::Unit::TestCase
4
4
 
5
5
  def test_single_queing
6
6
  tasks = RubyHaze::Queue[:test_single]
7
- 50.times { |idx| tasks.put [idx, Process.pid] }
7
+ qty = 50
8
+ qty.times { |idx| tasks.put [idx, Process.pid] }
8
9
  found = []
9
10
  while !tasks.empty? do
10
- task = tasks.poll 5, java.util.concurrent.TimeUnit::SECONDS
11
+ task = tasks.poll
11
12
  found << task
12
13
  end
13
14
  assert !found.empty?
14
- assert_equal found.size, 50
15
+ assert_equal found.size, qty
15
16
  end
16
17
 
17
18
  end
data/test/test_topic.rb CHANGED
@@ -1,23 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/helper')
2
-
3
- class Notices
4
- class << self
5
- extend Forwardable
6
- def all
7
- @all ||= []
8
- end
9
- def_delegators :all, :size, :<<, :first, :last, :clear, :map
10
- end
11
- end unless defined? Notices
12
-
13
- class TestListener
14
- def initialize(name)
15
- @name = name
16
- end
17
- def on_message(msg)
18
- Notices << "[#{@name}] #{msg}"
19
- end
20
- end
1
+ require File.expand_path(File.dirname(__FILE__) + '/helper') unless defined?(HELPER_LOADED)
21
2
 
22
3
  class TestRubyHazeTopic < Test::Unit::TestCase
23
4
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 6
9
+ version: 0.0.6
10
10
  platform: jruby
11
11
  authors:
12
12
  - Adrian Madrid
@@ -14,11 +14,11 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-30 00:00:00 -06:00
17
+ date: 2010-09-08 00:00:00 -06:00
18
18
  default_executable: rubyhaze_console
19
19
  dependencies: []
20
20
 
21
- description: RubyHaze is a little gem that wraps the Java Hazelcast library into a more comfortable Ruby package (in JRuby, of course).
21
+ description: RubyHaze is a little gem that wraps the Java Hazelcast library into a more comfortable JRuby package.
22
22
  email: aemadrid@gmail.com
23
23
  executables:
24
24
  - rubyhaze_console
@@ -33,8 +33,8 @@ files:
33
33
  - Rakefile
34
34
  - VERSION
35
35
  - bin/rubyhaze_console
36
- - jars/hazelcast-1.8.5.jar
37
- - jars/hazelcast-client-1.8.5.jar
36
+ - jars/hazelcast-1.9-RC.jar
37
+ - jars/hazelcast-client-1.9-RC.jar
38
38
  - lib/rubyhaze.rb
39
39
  - lib/rubyhaze/client.rb
40
40
  - lib/rubyhaze/configs/config.rb
@@ -88,7 +88,7 @@ rubyforge_project:
88
88
  rubygems_version: 1.3.6
89
89
  signing_key:
90
90
  specification_version: 3
91
- summary: JRuby wrapper to play with Hazelcast
91
+ summary: Hazelcast distributed objects in my JRuby
92
92
  test_files:
93
93
  - test/test_hash.rb
94
94
  - test/test_queue.rb
Binary file