hazelcast-client 0.0.4-jruby → 0.0.5-jruby
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/Gemfile.lock +22 -0
- data/README.rdoc +0 -1
- data/Rakefile +6 -6
- data/VERSION +1 -1
- data/bin/hazelcast-client-console +5 -4
- data/lib/hazelcast-client.rb +10 -8
- data/lib/hazelcast-client/lock.rb +1 -1
- data/lib/hazelcast-client/map.rb +75 -7
- data/lib/hazelcast-client/topic.rb +11 -1
- data/test/helper.rb +24 -2
- data/test/test_map.rb +81 -23
- data/test/test_queue.rb +2 -2
- data/test/test_topic.rb +3 -3
- metadata +123 -67
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
hazelcast-jars (2.5.1-java)
|
6
|
+
jeweler (1.8.4)
|
7
|
+
bundler (~> 1.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rdoc
|
11
|
+
json (1.7.7-java)
|
12
|
+
rake (10.0.4)
|
13
|
+
rdoc (4.0.1)
|
14
|
+
json (~> 1.4)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
java
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
bundler
|
21
|
+
hazelcast-jars (~> 2.5.1)
|
22
|
+
jeweler
|
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'rake'
|
6
6
|
require 'rake/testtask'
|
7
|
-
require '
|
7
|
+
require 'rdoc/task'
|
8
8
|
|
9
9
|
begin
|
10
10
|
require 'jeweler'
|
@@ -12,7 +12,7 @@ begin
|
|
12
12
|
gem.name = "hazelcast-client"
|
13
13
|
gem.authors = ["Adrian Madrid"]
|
14
14
|
gem.email = ["aemadrid@gmail.com"]
|
15
|
-
gem.homepage = ""
|
15
|
+
gem.homepage = "https://github.com/aemadrid/hazelcast-client"
|
16
16
|
gem.summary = %q{Connecting to a Hazelcast Cluster has never been easier!}
|
17
17
|
gem.description = %q{Hazelcast::Client is a little gem that wraps the Java Hazelcast Client library into a more comfortable JRuby package.}
|
18
18
|
gem.platform = "jruby"
|
@@ -25,7 +25,7 @@ begin
|
|
25
25
|
gem.executables = FileList['bin/*'].map { |f| File.basename(f) }
|
26
26
|
gem.require_paths = ["lib"]
|
27
27
|
|
28
|
-
gem.add_dependency "hazelcast-jars", "
|
28
|
+
gem.add_dependency "hazelcast-jars", "2.5.1"
|
29
29
|
end
|
30
30
|
Jeweler::GemcutterTasks.new
|
31
31
|
rescue LoadError
|
@@ -37,7 +37,7 @@ Rake::TestTask.new :test do |t|
|
|
37
37
|
t.test_files = FileList["test/**/test_*.rb"]
|
38
38
|
end
|
39
39
|
|
40
|
-
task :test
|
40
|
+
task :test
|
41
41
|
|
42
42
|
task :default => :test
|
43
43
|
|
@@ -54,12 +54,12 @@ rescue LoadError
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
require '
|
57
|
+
require 'rdoc/task'
|
58
58
|
Rake::RDocTask.new do |rdoc|
|
59
59
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
60
60
|
|
61
61
|
rdoc.rdoc_dir = 'rdoc'
|
62
|
-
rdoc.title = "
|
62
|
+
rdoc.title = "hazelcast-client #{version}"
|
63
63
|
rdoc.rdoc_files.include('README*')
|
64
64
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
65
65
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env jruby
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + "/../lib/hazelcast-client.rb")
|
3
3
|
|
4
|
-
@client = Hazelcast::Client.new ARGV[0], ARGV[1], ARGV[2]
|
4
|
+
@client = Hazelcast::Client.new ARGV[0] || 'dev', ARGV[1] || 'dev-pass', ARGV[2] || 'localhost'
|
5
5
|
|
6
|
-
puts ">> Starting
|
7
|
-
require '
|
6
|
+
puts ">> Starting Pry session..."
|
7
|
+
require 'pry'
|
8
8
|
ARGV.clear
|
9
|
-
|
9
|
+
|
10
|
+
Pry.start binding
|
data/lib/hazelcast-client.rb
CHANGED
@@ -9,8 +9,6 @@ module Hazelcast
|
|
9
9
|
Hazelcast::Jars.all
|
10
10
|
GEM_ROOT = File.expand_path(File.dirname(__FILE__)) unless defined?(GEM_ROOT)
|
11
11
|
|
12
|
-
java_import 'com.hazelcast.client.HazelcastClient'
|
13
|
-
|
14
12
|
attr_reader :username, :password, :host
|
15
13
|
|
16
14
|
def initialize(username = nil, password = nil, host = nil)
|
@@ -87,17 +85,21 @@ module Hazelcast
|
|
87
85
|
@connections ||= {}
|
88
86
|
end
|
89
87
|
|
90
|
-
def self.connection_id(username, password,
|
91
|
-
"#{username}:#{password}:#{
|
88
|
+
def self.connection_id(username, password, *hosts)
|
89
|
+
"#{username}:#{password}:#{hosts.map{ |x| x.to_s }.sort.join('|')}"
|
92
90
|
end
|
93
91
|
|
94
|
-
def self.connect(username, password,
|
95
|
-
conn_id = connection_id(username, password,
|
92
|
+
def self.connect(username, password, *hosts)
|
93
|
+
conn_id = connection_id(username, password, *hosts)
|
96
94
|
if connections.key? conn_id
|
97
95
|
connections[conn_id]
|
98
96
|
else
|
99
|
-
puts ">> Connecting to [#{
|
100
|
-
|
97
|
+
puts ">> Connecting to [#{hosts.inspect}] as [#{username}] with [#{password}]..."
|
98
|
+
client_config = com.hazelcast.client.ClientConfig.new
|
99
|
+
group_config = com.hazelcast.config.GroupConfig.new username, password
|
100
|
+
hosts.each {|host| client_config.add_address host }
|
101
|
+
client_config.set_group_config group_config
|
102
|
+
connections[conn_id] = com.hazelcast.client.HazelcastClient.newHazelcastClient client_config
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
@@ -4,7 +4,7 @@ class Java::ComHazelcastClient::LockClientProxy
|
|
4
4
|
# unlock()
|
5
5
|
|
6
6
|
def locking(options = {})
|
7
|
-
raise
|
7
|
+
raise 'Must provide a block' unless block_given?
|
8
8
|
tries = options[:tries] || 1
|
9
9
|
timeout = options[:timeout] || 5
|
10
10
|
unit = options[:unit] || :seconds
|
data/lib/hazelcast-client/map.rb
CHANGED
@@ -1,6 +1,58 @@
|
|
1
|
+
class Java::ComHazelcastImpl::DataAwareEntryEvent
|
2
|
+
|
3
|
+
alias_method :name, :getLongName
|
4
|
+
alias_method :source, :getSource
|
5
|
+
alias_method :member, :getMember
|
6
|
+
alias_method :source, :getSource
|
7
|
+
|
8
|
+
def type
|
9
|
+
getEventType.name
|
10
|
+
end
|
11
|
+
|
12
|
+
alias_method :key_data, :getKeyData
|
13
|
+
alias_method :key, :getKey
|
14
|
+
|
15
|
+
alias_method :old_value, :getOldValue
|
16
|
+
alias_method :old_value_data, :getOldValueData
|
17
|
+
alias_method :new_value, :getValue
|
18
|
+
alias_method :new_value_data, :getNewValueData
|
19
|
+
alias_method :value, :getValue
|
20
|
+
alias_method :value_data, :getNewValueData
|
21
|
+
|
22
|
+
alias_method :key_data, :getKeyData
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class Hazelcast::Client::DefaultMapListener
|
27
|
+
|
28
|
+
include com.hazelcast.core.EntryListener
|
29
|
+
|
30
|
+
def entryAdded(event)
|
31
|
+
puts "#{event.type} : #{event.key} : #{event.value}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def entryRemoved(event)
|
35
|
+
puts "#{event.type} : #{event.key} : #{event.value}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def entryUpdated(event)
|
39
|
+
puts "#{event.type} : #{event.key} : #{event.value}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def entryEvicted(event)
|
43
|
+
puts "#{event.type} : #{event.key} : #{event.value}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def method_missing(name, *params)
|
47
|
+
puts "method_missing : #{name} : #{params.inspect}"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
1
52
|
class Java::ComHazelcastClient::MapClientProxy
|
2
53
|
|
3
54
|
java_import 'com.hazelcast.query.SqlPredicate'
|
55
|
+
java_import 'com.hazelcast.core.EntryListener'
|
4
56
|
|
5
57
|
def [](key)
|
6
58
|
get key.to_s
|
@@ -22,7 +74,7 @@ class Java::ComHazelcastClient::MapClientProxy
|
|
22
74
|
unlearned_values(predicate).map
|
23
75
|
end
|
24
76
|
|
25
|
-
|
77
|
+
alias_method :find, :values
|
26
78
|
|
27
79
|
def prepare_predicate(predicate)
|
28
80
|
return if predicate.nil?
|
@@ -40,7 +92,7 @@ class Java::ComHazelcastClient::MapClientProxy
|
|
40
92
|
end.join(' AND ')
|
41
93
|
SqlPredicate.new query
|
42
94
|
else
|
43
|
-
raise
|
95
|
+
raise 'Unknown predicate type'
|
44
96
|
end
|
45
97
|
end
|
46
98
|
|
@@ -49,28 +101,44 @@ class Java::ComHazelcastClient::MapClientProxy
|
|
49
101
|
def on_entry_added(key = nil, include_value = true, &blk)
|
50
102
|
klass = Class.new
|
51
103
|
klass.send :include, EntryListener
|
52
|
-
klass.send :define_method, :
|
104
|
+
klass.send :define_method, :entryAdded, &blk
|
105
|
+
klass.send :define_method, :method_missing do |name, *params|
|
106
|
+
puts "method_missing : (#{name.class.name}) #{name} : #{params.inspect}"
|
107
|
+
true
|
108
|
+
end
|
53
109
|
key ? add_entry_listener(klass.new, key, include_value) : add_entry_listener(klass.new, include_value)
|
54
110
|
end
|
55
111
|
|
56
112
|
def on_entry_removed(key = nil, include_value = true, &blk)
|
57
113
|
klass = Class.new
|
58
114
|
klass.send :include, EntryListener
|
59
|
-
klass.send :define_method, :
|
60
|
-
|
115
|
+
klass.send :define_method, :entryRemoved, &blk
|
116
|
+
klass.send :define_method, :method_missing do |name, *params|
|
117
|
+
puts "method_missing : (#{name.class.name}) #{name} : #{params.inspect}"
|
118
|
+
true
|
119
|
+
end
|
120
|
+
key ? add_entry_listener(klass.new(), key, include_value) : add_entry_listener(klass.new, include_value)
|
61
121
|
end
|
62
122
|
|
63
123
|
def on_entry_updated(key = nil, include_value = true, &blk)
|
64
124
|
klass = Class.new
|
65
125
|
klass.send :include, EntryListener
|
66
|
-
klass.send :define_method, :
|
126
|
+
klass.send :define_method, :entryUpdated, &blk
|
127
|
+
klass.send :define_method, :method_missing do |name, *params|
|
128
|
+
puts "method_missing : (#{name.class.name}) #{name} : #{params.inspect}"
|
129
|
+
true
|
130
|
+
end
|
67
131
|
key ? add_entry_listener(klass.new, key, include_value) : add_entry_listener(klass.new, include_value)
|
68
132
|
end
|
69
133
|
|
70
134
|
def on_entry_evicted(key = nil, include_value = true, &blk)
|
71
135
|
klass = Class.new
|
72
136
|
klass.send :include, EntryListener
|
73
|
-
klass.send :define_method, :
|
137
|
+
klass.send :define_method, :entryEvicted, &blk
|
138
|
+
klass.send :define_method, :method_missing do |name, *params|
|
139
|
+
puts "method_missing : (#{name.class.name}) #{name} : #{params.inspect}"
|
140
|
+
true
|
141
|
+
end
|
74
142
|
key ? add_entry_listener(klass.new, key, include_value) : add_entry_listener(klass.new, include_value)
|
75
143
|
end
|
76
144
|
|
@@ -5,8 +5,18 @@ class Java::ComHazelcastClient::TopicClientProxy
|
|
5
5
|
def on_message(&blk)
|
6
6
|
klass = Class.new
|
7
7
|
klass.send :include, MessageListener
|
8
|
-
klass.send :define_method, :
|
8
|
+
klass.send :define_method, :onMessage, &blk
|
9
9
|
add_message_listener klass.new
|
10
10
|
end
|
11
11
|
|
12
|
+
end
|
13
|
+
|
14
|
+
class Java::ComHazelcastImpl::DataMessage
|
15
|
+
|
16
|
+
alias_method :original_to_s, :to_s
|
17
|
+
|
18
|
+
alias_method :message, :get_message_object
|
19
|
+
|
20
|
+
alias_method :to_s, :get_message_object
|
21
|
+
|
12
22
|
end
|
data/test/helper.rb
CHANGED
@@ -15,12 +15,12 @@ unless defined?(HELPER_LOADED)
|
|
15
15
|
def all
|
16
16
|
@all ||= []
|
17
17
|
end
|
18
|
-
def_delegators :all, :size, :<<, :first, :last, :clear, :map
|
18
|
+
def_delegators :all, :size, :<<, :first, :last, :clear, :map, :[]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
# Listen on messages
|
23
|
-
class
|
23
|
+
class TestMessageListener
|
24
24
|
def initialize(name)
|
25
25
|
@name = name
|
26
26
|
end
|
@@ -29,6 +29,28 @@ unless defined?(HELPER_LOADED)
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
# Listen on events
|
33
|
+
class TestEventListener
|
34
|
+
def initialize(name)
|
35
|
+
@name = name
|
36
|
+
end
|
37
|
+
def entryAdded(event)
|
38
|
+
Notices << "[#{@name}] added : #{event.key} : #{event.value}"
|
39
|
+
end
|
40
|
+
def entryRemoved(event)
|
41
|
+
Notices << "[#{@name}] removed : #{event.key} : #{event.value}"
|
42
|
+
end
|
43
|
+
def entryUpdated(event)
|
44
|
+
Notices << "[#{@name}] updated : #{event.key} : #{event.value}"
|
45
|
+
end
|
46
|
+
def entryEvicted(event)
|
47
|
+
Notices << "[#{@name}] evicted : #{event.key} : #{event.value}"
|
48
|
+
end
|
49
|
+
def method_missing(name, *params)
|
50
|
+
Notices << "[#{@name}] method_missing : #{name} : #{params.inspect}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
32
54
|
# Loading the Employee Java class
|
33
55
|
$CLASSPATH << File.expand_path(File.dirname(__FILE__)) + '/'
|
34
56
|
java_import 'Employee'
|
data/test/test_map.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestHazelcastMap < Test::Unit::TestCase
|
4
4
|
|
5
5
|
java_import 'com.hazelcast.query.SqlPredicate'
|
6
6
|
|
7
7
|
def test_same_object
|
8
8
|
hash = CLIENT.map :test_same_object
|
9
9
|
map = CLIENT.map :test_same_object
|
10
|
+
hash.clear
|
10
11
|
assert_equal hash.name, map.name
|
11
12
|
hash[:a] = 1
|
12
13
|
assert_equal hash[:a], map[:a]
|
13
14
|
end
|
14
15
|
|
15
16
|
def test_string_keys
|
16
|
-
hash
|
17
|
+
hash = CLIENT.map :test_string_keys
|
18
|
+
hash.clear
|
17
19
|
|
18
20
|
hash[:a] = 1
|
19
21
|
assert_equal hash['a'], 1
|
@@ -31,46 +33,45 @@ class TestRubyHazeHash < Test::Unit::TestCase
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def test_predicates
|
34
|
-
map
|
36
|
+
map = CLIENT.map :test_predicates
|
35
37
|
|
36
|
-
predicate = map.prepare_predicate
|
38
|
+
predicate = map.prepare_predicate 'active = false AND (age = 45 OR name = \'Joe Mategna\')'
|
37
39
|
assert_kind_of SqlPredicate, predicate
|
38
|
-
assert_equal
|
40
|
+
assert_equal '(active=false AND (age=45 OR name=Joe Mategna))', predicate.to_s
|
39
41
|
|
40
42
|
predicate = map.prepare_predicate :quantity => 3
|
41
43
|
assert_kind_of SqlPredicate, predicate
|
42
44
|
assert_equal 'quantity=3', predicate.to_s
|
43
45
|
|
44
|
-
predicate = map.prepare_predicate :country =>
|
46
|
+
predicate = map.prepare_predicate :country => 'Unites States of America'
|
45
47
|
assert_kind_of SqlPredicate, predicate
|
46
|
-
assert_equal
|
48
|
+
assert_equal 'country=Unites States of America', predicate.to_s
|
47
49
|
end
|
48
50
|
|
49
51
|
def test_entry_added
|
50
|
-
|
51
|
-
map
|
52
|
+
map = CLIENT.map :test_entry_added
|
53
|
+
Notices.clear; map.clear
|
52
54
|
map.on_entry_added do |event|
|
53
55
|
Notices << "added : #{event.key} : #{event.value}"
|
54
56
|
end
|
55
57
|
|
56
58
|
assert_equal Notices.size, 0
|
57
|
-
k, v
|
59
|
+
k, v = 'a1', 'b2'
|
58
60
|
map[k] = v
|
59
|
-
sleep
|
60
|
-
puts "Notices : #{Notices.all.inspect}"
|
61
|
+
sleep 1.5
|
61
62
|
assert_equal Notices.size, 1
|
62
63
|
assert_equal Notices.last, "added : #{k} : #{v}"
|
63
64
|
end
|
64
65
|
|
65
66
|
def test_entry_removed
|
66
|
-
|
67
|
-
map
|
67
|
+
map = CLIENT.map :test_entry_removed
|
68
|
+
Notices.clear; map.clear
|
68
69
|
map.on_entry_removed do |event|
|
69
70
|
Notices << "removed : #{event.key} : #{event.value}"
|
70
71
|
end
|
71
72
|
|
72
73
|
assert_equal Notices.size, 0
|
73
|
-
k, v
|
74
|
+
k, v = 'a1', 'b2'
|
74
75
|
map[k] = v
|
75
76
|
map.remove k
|
76
77
|
sleep 0.25
|
@@ -79,32 +80,32 @@ class TestRubyHazeHash < Test::Unit::TestCase
|
|
79
80
|
end
|
80
81
|
|
81
82
|
def test_entry_updated
|
82
|
-
|
83
|
-
map
|
83
|
+
map = CLIENT.map :test_entry_updated
|
84
|
+
Notices.clear; map.clear
|
84
85
|
map.on_entry_updated do |event|
|
85
86
|
Notices << "updated : #{event.key} : #{event.value}"
|
86
87
|
end
|
87
88
|
|
88
89
|
assert_equal Notices.size, 0
|
89
|
-
k, v
|
90
|
-
map[k] =
|
90
|
+
k, v = 'a1', 'b2'
|
91
|
+
map[k] = 'b0'
|
92
|
+
map[k] = 'b1'
|
91
93
|
map[k] = v
|
92
94
|
sleep 0.5
|
93
|
-
puts "Notices : #{Notices.all.inspect}"
|
94
95
|
assert_equal Notices.size, 2
|
95
96
|
assert_equal Notices.first, "updated : #{k} : b1"
|
96
97
|
assert_equal Notices.last, "updated : #{k} : #{v}"
|
97
98
|
end
|
98
99
|
|
99
100
|
def test_entry_evicted
|
100
|
-
|
101
|
-
map
|
101
|
+
map = CLIENT.map :test_entry_evicted
|
102
|
+
Notices.clear; map.clear
|
102
103
|
map.on_entry_evicted do |event|
|
103
104
|
Notices << "evicted : #{event.key} : #{event.value}"
|
104
105
|
end
|
105
106
|
|
106
107
|
assert_equal Notices.size, 0
|
107
|
-
k, v
|
108
|
+
k, v = 'a1', 'b2'
|
108
109
|
map[k] = v
|
109
110
|
map.evict k
|
110
111
|
sleep 0.25
|
@@ -112,4 +113,61 @@ class TestRubyHazeHash < Test::Unit::TestCase
|
|
112
113
|
assert_equal Notices.last, "evicted : #{k} : #{v}"
|
113
114
|
end
|
114
115
|
|
116
|
+
def test_class_entry_added
|
117
|
+
map = CLIENT.map :test_class_entry_added
|
118
|
+
Notices.clear; map.clear
|
119
|
+
map.add_entry_listener TestEventListener.new("test_class_entry_added"), true
|
120
|
+
|
121
|
+
assert_equal Notices.size, 0
|
122
|
+
k, v = 'a1', 'b2'
|
123
|
+
map[k] = v
|
124
|
+
sleep 1.5
|
125
|
+
assert_equal Notices.size, 1
|
126
|
+
assert_equal Notices.last, "[test_class_entry_added] added : #{k} : #{v}"
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_class_entry_removed
|
130
|
+
map = CLIENT.map :test_class_entry_removed
|
131
|
+
Notices.clear; map.clear
|
132
|
+
map.add_entry_listener TestEventListener.new("test_class_entry_removed"), true
|
133
|
+
|
134
|
+
assert_equal Notices.size, 0
|
135
|
+
k, v = 'a1', 'b2'
|
136
|
+
map[k] = v
|
137
|
+
map.remove k
|
138
|
+
sleep 0.25
|
139
|
+
assert_equal Notices.size, 2
|
140
|
+
assert_equal Notices.first, "[test_class_entry_removed] added : #{k} : #{v}"
|
141
|
+
assert_equal Notices.last, "[test_class_entry_removed] removed : #{k} : #{v}"
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_class_entry_updated
|
145
|
+
map = CLIENT.map :test_class_entry_updated
|
146
|
+
Notices.clear; map.clear
|
147
|
+
map.add_entry_listener TestEventListener.new("test_class_entry_updated"), true
|
148
|
+
|
149
|
+
assert_equal Notices.size, 0
|
150
|
+
k, v = 'a1', 'b2'
|
151
|
+
map[k] = 'b1'
|
152
|
+
map[k] = v
|
153
|
+
sleep 0.5
|
154
|
+
assert_equal Notices.size, 2
|
155
|
+
assert_equal Notices.first, "[test_class_entry_updated] added : #{k} : b1"
|
156
|
+
assert_equal Notices.last, "[test_class_entry_updated] updated : #{k} : b2"
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_class_entry_evicted
|
160
|
+
map = CLIENT.map :test_class_entry_evicted
|
161
|
+
Notices.clear; map.clear
|
162
|
+
map.add_entry_listener TestEventListener.new("test_class_entry_evicted"), true
|
163
|
+
|
164
|
+
assert_equal Notices.size, 0
|
165
|
+
k, v = 'a1', 'b2'
|
166
|
+
map[k] = v
|
167
|
+
map.evict k
|
168
|
+
sleep 0.25
|
169
|
+
assert_equal Notices.size, 2
|
170
|
+
assert_equal Notices.first, "[test_class_entry_evicted] added : #{k} : #{v}"
|
171
|
+
assert_equal Notices.last, "[test_class_entry_evicted] evicted : #{k} : #{v}"
|
172
|
+
end
|
115
173
|
end
|
data/test/test_queue.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
2
2
|
require 'yaml'
|
3
3
|
|
4
|
-
class
|
4
|
+
class TestHazelcastQueue < Test::Unit::TestCase
|
5
5
|
|
6
6
|
def test_single_queing
|
7
7
|
tasks = CLIENT.queue :test_single
|
@@ -10,7 +10,7 @@ class TestRubyHazeQueue < Test::Unit::TestCase
|
|
10
10
|
found = []
|
11
11
|
while !tasks.empty? do
|
12
12
|
task = tasks.poll
|
13
|
-
found <<
|
13
|
+
found << task
|
14
14
|
end
|
15
15
|
assert !found.empty?
|
16
16
|
assert_equal found.size, qty
|
data/test/test_topic.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/helper') unless defined?(HELPER_LOADED)
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestHazelcastTopic < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def test_block_listener
|
6
6
|
Notices.clear
|
7
7
|
topic = CLIENT.topic :test_block
|
8
8
|
topic.on_message do |msg|
|
9
|
-
Notices <<
|
9
|
+
Notices << msg.to_s
|
10
10
|
end
|
11
11
|
assert_equal Notices.size, 0
|
12
12
|
topic.publish "Hola!"
|
@@ -18,7 +18,7 @@ class TestRubyHazeTopic < Test::Unit::TestCase
|
|
18
18
|
def test_class_listener
|
19
19
|
Notices.clear
|
20
20
|
topic = CLIENT.topic :test_class
|
21
|
-
topic.add_message_listener
|
21
|
+
topic.add_message_listener TestMessageListener.new("test_class")
|
22
22
|
assert_equal Notices.size, 0
|
23
23
|
topic.publish "Hola!"
|
24
24
|
sleep 0.25
|
metadata
CHANGED
@@ -1,81 +1,137 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: hazelcast-client
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.5
|
6
6
|
platform: jruby
|
7
|
-
authors:
|
8
|
-
|
9
|
-
autorequire:
|
7
|
+
authors:
|
8
|
+
- Adrian Madrid
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
12
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: hazelcast-jars
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.5.1
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.5.1
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :runtime
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: !binary |-
|
37
|
+
MA==
|
38
|
+
none: false
|
39
|
+
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: !binary |-
|
44
|
+
MA==
|
45
|
+
none: false
|
46
|
+
prerelease: false
|
47
|
+
type: :development
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: jeweler
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: !binary |-
|
55
|
+
MA==
|
56
|
+
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: !binary |-
|
62
|
+
MA==
|
63
|
+
none: false
|
64
|
+
prerelease: false
|
65
|
+
type: :development
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: hazelcast-jars
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.5.1
|
73
|
+
none: false
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.5.1
|
79
|
+
none: false
|
80
|
+
prerelease: false
|
81
|
+
type: :runtime
|
26
82
|
description: Hazelcast::Client is a little gem that wraps the Java Hazelcast Client library into a more comfortable JRuby package.
|
27
|
-
email:
|
28
|
-
|
29
|
-
executables:
|
30
|
-
|
83
|
+
email:
|
84
|
+
- aemadrid@gmail.com
|
85
|
+
executables:
|
86
|
+
- hazelcast-client-console
|
31
87
|
extensions: []
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
88
|
+
extra_rdoc_files:
|
89
|
+
- LICENSE
|
90
|
+
- README.rdoc
|
91
|
+
files:
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- LICENSE
|
95
|
+
- README.rdoc
|
96
|
+
- Rakefile
|
97
|
+
- VERSION
|
98
|
+
- bin/hazelcast-client-console
|
99
|
+
- lib/hazelcast-client.rb
|
100
|
+
- lib/hazelcast-client/lock.rb
|
101
|
+
- lib/hazelcast-client/map.rb
|
102
|
+
- lib/hazelcast-client/queue.rb
|
103
|
+
- lib/hazelcast-client/topic.rb
|
104
|
+
- test/helper.rb
|
105
|
+
- test/test_map.rb
|
106
|
+
- test/test_queue.rb
|
107
|
+
- test/test_topic.rb
|
108
|
+
homepage: https://github.com/aemadrid/hazelcast-client
|
52
109
|
licenses: []
|
53
|
-
|
54
|
-
post_install_message:
|
110
|
+
post_install_message:
|
55
111
|
rdoc_options: []
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: !binary |-
|
119
|
+
MA==
|
60
120
|
none: false
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: !binary |-
|
126
|
+
MA==
|
66
127
|
none: false
|
67
|
-
requirements:
|
68
|
-
- - ">="
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: "0"
|
71
128
|
requirements: []
|
72
|
-
|
73
129
|
rubyforge_project: hazelcast-client
|
74
|
-
rubygems_version: 1.8.
|
75
|
-
signing_key:
|
130
|
+
rubygems_version: 1.8.24
|
131
|
+
signing_key:
|
76
132
|
specification_version: 3
|
77
133
|
summary: Connecting to a Hazelcast Cluster has never been easier!
|
78
|
-
test_files:
|
79
|
-
|
80
|
-
|
81
|
-
|
134
|
+
test_files:
|
135
|
+
- test/test_map.rb
|
136
|
+
- test/test_queue.rb
|
137
|
+
- test/test_topic.rb
|