roma-client 0.3.7 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,2 @@
1
+ = 0.4.0
2
+ - support ClientPool
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gem "rake"
4
+ gem "rspec"
5
+ gem "rr"
6
+
7
+ # add rdoc for darkfish format
8
+ gem "rdoc"
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ json (1.6.1)
6
+ rake (0.9.2.2)
7
+ rdoc (3.11)
8
+ json (~> 1.4)
9
+ rr (1.0.4)
10
+ rspec (2.7.0)
11
+ rspec-core (~> 2.7.0)
12
+ rspec-expectations (~> 2.7.0)
13
+ rspec-mocks (~> 2.7.0)
14
+ rspec-core (2.7.1)
15
+ rspec-expectations (2.7.0)
16
+ diff-lcs (~> 1.1.2)
17
+ rspec-mocks (2.7.0)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ rake
24
+ rdoc
25
+ rr
26
+ rspec
data/Rakefile CHANGED
@@ -1,13 +1,22 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'rubygems'
3
3
  require 'rake'
4
- require 'rake/gempackagetask'
5
- require 'rake/rdoctask'
4
+ require 'rubygems/package_task'
5
+
6
+ if File.exist?(File.expand_path('Gemfile', File.dirname(__FILE__)))
7
+ require 'bundler/setup'
8
+ end
9
+
10
+ begin
11
+ require 'rdoc/task'
12
+ rescue LoadError
13
+ require 'rake/rdoctask'
14
+ end
6
15
 
7
16
  RDOC_OPTIONS = [
8
17
  '--line-numbers',
9
18
  '--inline-source',
10
- "--main", "README.rdoc",
19
+ "--main", "README",
11
20
  "-c UTF-8",
12
21
  ]
13
22
 
@@ -20,9 +29,12 @@ PKG_FILES = FileList[
20
29
  'spec/**/*.rb',
21
30
  'doc/**/*',
22
31
  'examples/**/*',
23
- ]
32
+ ]
33
+
34
+ require File.expand_path(File.join("lib", "roma", "client", "version"),
35
+ File.dirname(__FILE__))
24
36
 
25
- VER_NUM = `ruby -Ilib -e 'require "roma/client/version"; puts Roma::Client::VERSION::STRING'`
37
+ VER_NUM = Roma::Client::VERSION::STRING
26
38
 
27
39
  if VER_NUM =~ /([0-9.]+)$/
28
40
  CURRENT_VERSION = $1
@@ -30,7 +42,21 @@ else
30
42
  CURRENT_VERSION = "0.0.0"
31
43
  end
32
44
 
45
+ begin
46
+ require 'rspec/core'
47
+ require 'rspec/core/rake_task'
48
+ rescue LoadError
49
+ puts "no rspec"
50
+ else
51
+ RSpec::Core::RakeTask.new(:spec) do |t|
52
+ t.ruby_opts=""
53
+ t.rcov = false
54
+ end
55
+ task :default => :spec
56
+ end
57
+
33
58
  SPEC = Gem::Specification.new do |s|
59
+ s.authors = ["Muga Nishizawa", "Junji Torii"]
34
60
  s.name = "roma-client"
35
61
  s.version = CURRENT_VERSION
36
62
  s.summary = "ROMA client library"
@@ -43,10 +69,10 @@ SPEC = Gem::Specification.new do |s|
43
69
 
44
70
  s.has_rdoc = true
45
71
  s.rdoc_options.concat RDOC_OPTIONS
46
- s.extra_rdoc_files = ["README"]
72
+ s.extra_rdoc_files = ["README", "CHANGELOG"]
47
73
  end
48
74
 
49
- package_task = Rake::GemPackageTask.new(SPEC) do |pkg|
75
+ package_task = Gem::PackageTask.new(SPEC) do |pkg|
50
76
  end
51
77
 
52
78
 
@@ -55,5 +81,7 @@ Rake::RDocTask.new("doc") { |rdoc|
55
81
  rdoc.title = "ROMA documents"
56
82
  rdoc.options.concat RDOC_OPTIONS
57
83
  rdoc.rdoc_files.include('lib/**/*.rb')
58
- rdoc.rdoc_files.include("README.rdoc")
84
+ rdoc.rdoc_files.include("README")
85
+ rdoc.rdoc_files.include("CHANGELOG")
59
86
  }
87
+
@@ -0,0 +1,128 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'singleton'
3
+
4
+ module Roma
5
+ module Client
6
+ # RomaClient Pool class
7
+ #
8
+ # This class is implemented as Singleton.
9
+ # You can get RomaClient as follows.
10
+ #
11
+ # client = Roma::Client::ClientPool.instance.client
12
+ #
13
+ # You can change pool size of RomaClient to call "max_pool_size=" method .
14
+ # Default max pool size is 1.
15
+ class ClientPool
16
+ private_class_method :new
17
+
18
+ attr_accessor :servers
19
+ attr_accessor :default_hash_name
20
+ attr_accessor :start_sync_routing_proc
21
+
22
+ @@client_pools = {}
23
+
24
+ # get ClientPool instance
25
+ # type:: identifier for client groups.
26
+ def self.instance(type = :default)
27
+ @@client_pools[type] ||= new
28
+ @@client_pools[type]
29
+ end
30
+
31
+ # get all pool
32
+ def self.client_pools
33
+ @@client_pools
34
+ end
35
+
36
+ # release all pool
37
+ def self.release_all
38
+ @@client_pools = {}
39
+ end
40
+
41
+ # get RomaClient instance
42
+ #
43
+ # type:: RomaClient instance group.
44
+ # return:: RomaClient instance
45
+ def client
46
+ c = nil
47
+ if @clients.empty?
48
+ client = Roma::Client::RomaClient.new(servers,
49
+ plugin_modules,
50
+ start_sync_routing_proc)
51
+ client.default_hash_name = default_hash_name
52
+ c = client
53
+ else
54
+ c = @clients.pop
55
+ end
56
+
57
+ return c unless block_given?
58
+
59
+ begin
60
+ yield c
61
+ ensure
62
+ push_client(c)
63
+ end
64
+ end
65
+
66
+ # get pool count of clients
67
+ def pool_count
68
+ @clients.size
69
+ end
70
+
71
+ # release all pool clients
72
+ def release
73
+ @clients.clear
74
+ true
75
+ end
76
+
77
+ # push RomaClient instance
78
+ def push_client(client)
79
+ if @clients.size < max_pool_size
80
+ @clients.push(client)
81
+ end
82
+ end
83
+
84
+ # get max pool size
85
+ def max_pool_size
86
+ @max_pool_size
87
+ end
88
+
89
+ # set max_pool_size
90
+ def max_pool_size=(count)
91
+ @max_pool_size = count
92
+ end
93
+
94
+ # get all clients
95
+ def clients
96
+ @clients
97
+ end
98
+
99
+ # get plugin_modules
100
+ def plugin_modules
101
+ @plugin_modules
102
+ end
103
+
104
+ # add plugin module
105
+ def add_plugin_module(m)
106
+ @plugin_modules ||= []
107
+ @plugin_modules.push(m)
108
+ end
109
+
110
+ # set plugin modules
111
+ #
112
+ # You can set class Array.
113
+ def plugin_modules=(modules)
114
+ @plugin_modules = modules
115
+ end
116
+
117
+ private
118
+ def initialize
119
+ @max_pool_size = 1
120
+ @clients = []
121
+ @plugin_modules = nil
122
+ self.servers = nil
123
+ self.default_hash_name = 'roma'
124
+ self.start_sync_routing_proc = true
125
+ end
126
+ end
127
+ end
128
+ end
@@ -9,15 +9,21 @@ module Roma
9
9
  include Singleton
10
10
 
11
11
  attr_accessor :maxlength
12
+ attr_accessor :expire_time
12
13
 
13
- def initialize(maxlength = 10)
14
+ def initialize(maxlength = 10, expire_time = 60)
14
15
  @pool = {}
15
16
  @maxlength = maxlength
17
+ @expire_time = expire_time
16
18
  @lock = Mutex.new
17
19
  end
18
20
 
19
21
  def get_connection(ap)
20
- ret = @pool[ap].shift if @pool.key?(ap) && @pool[ap].length > 0
22
+ ret,last = @pool[ap].shift if @pool.key?(ap) && @pool[ap].length > 0
23
+ if ret && last < Time.now - @expire_time
24
+ ret.close
25
+ ret = nil
26
+ end
21
27
  ret = create_connection(ap) unless ret
22
28
  ret
23
29
  rescue
@@ -29,10 +35,10 @@ module Roma
29
35
  if @pool[ap].length > @maxlength
30
36
  con.close
31
37
  else
32
- @pool[ap] << con
38
+ @pool[ap] << [con, Time.now]
33
39
  end
34
40
  else
35
- @pool[ap] = [con]
41
+ @pool[ap] = [[con, Time.now]]
36
42
  end
37
43
  rescue
38
44
  end
@@ -24,7 +24,7 @@ module Roma
24
24
  #
25
25
  # [ini_nodes] ROMA nodes array
26
26
  # [plugin_modules] set plugin modules if you use .
27
- def initialize(ini_nodes,plugin_modules = nil)
27
+ def initialize(ini_nodes,plugin_modules = nil, start_sync_routing_proc = true)
28
28
  @retry_count_write = 10
29
29
  @retry_count_read = 5
30
30
  @default_hash_name = 'roma'
@@ -37,7 +37,7 @@ module Roma
37
37
 
38
38
  init_sender
39
39
  update_rttable(ini_nodes.map{|n| n.sub(':','_')})
40
- init_sync_routing_proc
40
+ init_sync_routing_proc if start_sync_routing_proc
41
41
  end
42
42
 
43
43
  def init_sync_routing_proc
@@ -45,7 +45,7 @@ module Roma
45
45
  begin
46
46
  loop {
47
47
  sleep 10
48
- update_rttable(@rttable.nodes)
48
+ update_rttable
49
49
  }
50
50
  rescue => e
51
51
  puts "#{e}\n#{$@}"
@@ -59,13 +59,14 @@ module Roma
59
59
  end
60
60
  private :init_sender
61
61
 
62
- def update_rttable(nodes)
62
+ def update_rttable(nodes = self.rttable.nodes)
63
63
  raise RuntimeError.new("nodes must not be nil.") unless nodes
64
64
 
65
65
  nodes.each { |node|
66
66
  rt = make_rttable(node)
67
67
  if rt
68
68
  @rttable = rt
69
+ @rttable_last_update = Time.now
69
70
  return
70
71
  end
71
72
  }
@@ -73,6 +74,10 @@ module Roma
73
74
  raise RuntimeError.new("fatal error")
74
75
  end
75
76
 
77
+ def rttable_last_update
78
+ @rttable_last_update
79
+ end
80
+
76
81
  def make_rttable(node)
77
82
  mklhash = @sender.send_route_mklhash_command(node)
78
83
  return nil unless mklhash
@@ -221,8 +226,30 @@ module Roma
221
226
  sender(:oneline_receiver, key, val, "prepend %s 0 %d %d", expt.to_i, val.length)
222
227
  end
223
228
 
224
- def cas(key, val, expt = 0)
225
- raise RuntimeError.new("Unsupported yet") # TODO
229
+ # Compare And Swap value .
230
+ #
231
+ # [key] key for cas .
232
+ # [value] store value .
233
+ # [exp] expire seconds .
234
+ #
235
+ # [return] return follow set status .
236
+ # - If method is success, return STORED .
237
+ # - If method cannot update value, return EXISTS .
238
+ # - If key doesn't exist in ROMA, this method return NOT_FOUND.
239
+ # - If server error, return SERVER_ERROR .
240
+ #
241
+ # If socket error occured, throw Exception .
242
+ #
243
+ # If socket timeout occured, throw TimeoutError .
244
+ def cas(key, expt = 0, raw = false)
245
+ raise "A block is required" unless block_given?
246
+
247
+ (val, casid) = gets_with_casid(key, raw)
248
+ return "NOT_FOUND" unless val
249
+ updated = yield val
250
+ val = raw ? updated : Marshal.dump(updated)
251
+
252
+ sender(:oneline_receiver, key, val, "cas %s 0 %d %d %s", expt.to_i, val.length, casid)
226
253
  end
227
254
 
228
255
  # Delete value .
@@ -367,6 +394,13 @@ module Roma
367
394
 
368
395
  private
369
396
 
397
+ def gets_with_casid(key, raw = false)
398
+ ret = sender(:value_casid_receiver, key, nil, "gets %s")
399
+ return [nil, nil] if ret.size <= 0
400
+ ret[0] = Marshal.load(ret[0]) unless raw
401
+ ret
402
+ end
403
+
370
404
  def sender(receiver, key, value ,cmd, *params)
371
405
  nid, d = @rttable.search_node(key)
372
406
  cmd2 = sprintf(cmd, "#{key}\e#{@default_hash_name}", *params)
@@ -37,7 +37,7 @@ module Roma
37
37
  return :error if routes_length < 0
38
38
  return nil
39
39
  end
40
-
40
+
41
41
  routes = ''
42
42
  while (routes.length != routes_length)
43
43
  routes = routes + conn.read(routes_length - routes.length)
@@ -56,7 +56,7 @@ module Roma
56
56
  def send_routedump_yaml_command(node_id)
57
57
  conn = ConPool.instance.get_connection(node_id)
58
58
  conn.write "routingdump yaml\r\n"
59
-
59
+
60
60
  yaml = ''
61
61
  while( (line = conn.gets) != "END\r\n" )
62
62
  yaml << line
@@ -64,7 +64,7 @@ module Roma
64
64
 
65
65
  rd = YAML.load(yaml)
66
66
  ConPool.instance.return_connection(node_id, conn)
67
- return rd
67
+ return rd
68
68
  end
69
69
 
70
70
  def send_stats_command
@@ -108,7 +108,7 @@ module Roma
108
108
  def oneline_receiver(con)
109
109
  ret = con.gets
110
110
  raise "connection closed" if ret.nil?
111
- ret.chomp
111
+ ret.chomp
112
112
  end
113
113
 
114
114
  def value_list_receiver(con)
@@ -131,9 +131,21 @@ module Roma
131
131
  read_bytes(con, 2)
132
132
  end
133
133
  ret
134
- end
134
+ end
135
+
136
+ def value_casid_receiver(con)
137
+ ret = []
138
+ while (line = con.gets) != "END\r\n"
139
+ s = line.split(' ')
140
+ return line.chomp if s[0] == 'SERVER_ERROR' || s[0] == 'CLIENT_ERROR'
141
+ ret << read_bytes(con, s[3].to_i)
142
+ ret << s[4]
143
+ read_bytes(con, 2)
144
+ end
145
+ ret
146
+ end
135
147
 
136
- def multiplelines_receiver(con)
148
+ def multiplelines_receiver(con)
137
149
  ret = []
138
150
  while (line = con.gets) != "END\r\n"
139
151
  ret << line.chomp
@@ -150,6 +162,5 @@ module Roma
150
162
  end
151
163
 
152
164
  end
153
-
154
165
  end
155
166
  end
@@ -13,10 +13,10 @@ module Roma #:nodoc:
13
13
  MAJOR = 0
14
14
 
15
15
  # マイナバージョン
16
- MINOR = 3
16
+ MINOR = 4
17
17
 
18
18
  # TINY version
19
- TINY = 7
19
+ TINY = 0
20
20
 
21
21
  # バージョン文字列
22
22
  STRING = [MAJOR, MINOR, TINY].join('.')
@@ -0,0 +1,6 @@
1
+ require File.expand_path(File.join('roma', 'client'),
2
+ File.dirname(__FILE__))
3
+ require File.expand_path(File.join('roma', 'client', 'version'),
4
+ File.dirname(__FILE__))
5
+ require File.expand_path(File.join('roma', 'client', 'client_pool'),
6
+ File.dirname(__FILE__))
@@ -0,0 +1,288 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.expand_path(File.join('..', '..', 'spec_helper'), File.dirname(__FILE__))
3
+
4
+ describe Roma::Client::ClientPool do
5
+ def get_nodes
6
+ ['127.0.0.1:12001', '127.0.0.1:12002']
7
+ end
8
+
9
+ context "Singleton" do
10
+ subject { Roma::Client::ClientPool.instance(:test) }
11
+ it {
12
+ subject.class.should == Roma::Client::ClientPool
13
+ }
14
+
15
+ it {
16
+ subject.should be_equal Roma::Client::ClientPool.instance(:test)
17
+ }
18
+
19
+ it {
20
+ subject.should_not be_equal Roma::Client::ClientPool.instance(:test2)
21
+ }
22
+
23
+ it {
24
+ expect {
25
+ Roma::Client::ClientPool.new
26
+ }.to raise_error(NoMethodError,
27
+ "private method `new' called for Roma::Client::ClientPool:Class")
28
+ }
29
+ end
30
+
31
+ context "max pool size of default" do
32
+ subject{ Roma::Client::ClientPool.instance(:test) }
33
+ its(:max_pool_size) {
34
+ should == 1
35
+ }
36
+ end
37
+
38
+ context "set max pool size " do
39
+ it do
40
+ pool = Roma::Client::ClientPool.instance(:test)
41
+ pool.max_pool_size.should == 1
42
+ pool.max_pool_size = 3
43
+ pool.max_pool_size.should == 3
44
+
45
+ pool2 = Roma::Client::ClientPool.instance(:test2)
46
+ pool2.max_pool_size.should == 1
47
+ end
48
+ end
49
+
50
+ context "servers default" do
51
+ subject { Roma::Client::ClientPool.instance(:test) }
52
+ its(:servers) { should be_nil }
53
+ end
54
+
55
+ context "servers set" do
56
+ it {
57
+ pool = Roma::Client::ClientPool.instance(:test_servers_set)
58
+ pool.servers.should be_nil
59
+ nodes = get_nodes
60
+ pool.servers = nodes
61
+ pool.servers.should == nodes
62
+
63
+ Roma::Client::ClientPool.instance(:test_ini_nodes_set2).servers.should be_nil
64
+ }
65
+ end
66
+
67
+ context "client" do
68
+ subject do
69
+ pool = Roma::Client::ClientPool.instance(:test_client)
70
+ pool.servers = get_nodes
71
+ pool
72
+ end
73
+
74
+ it { pending 'TODO: startup or mock roma server'}
75
+ it { subject.pool_count.should == 0 }
76
+ it {
77
+ client = subject.client
78
+ client.class.should == Roma::Client::RomaClient
79
+ subject.push_client(client)
80
+ subject.pool_count.should == 1
81
+ }
82
+ it { pending "TODO: check nodes" }
83
+ end
84
+
85
+ context "client multi pool" do
86
+ subject do
87
+ pool = Roma::Client::ClientPool.instance(:test_client2)
88
+ pool.servers = get_nodes
89
+ pool
90
+ end
91
+
92
+ it {
93
+ subject.pool_count.should == 0
94
+ client = subject.client
95
+ client.should_not be_nil
96
+
97
+ client2 = subject.client
98
+ client2.should_not be_nil
99
+
100
+ subject.push_client(client)
101
+ subject.pool_count.should == 1
102
+
103
+ subject.push_client(client2)
104
+ subject.pool_count.should == 1
105
+
106
+ client.should be_equal subject.client
107
+ subject.pool_count.should == 0
108
+ }
109
+ end
110
+
111
+ context "plugin modules" do
112
+ module TestPlugin
113
+ def test_plugin
114
+ "test_plugin"
115
+ end
116
+ end
117
+
118
+ module TestPlugin2
119
+ def test_plugin2
120
+ "test_plugin2"
121
+ end
122
+ end
123
+
124
+ it {
125
+ pool = Roma::Client::ClientPool.instance(:pm_test)
126
+ pool.plugin_modules.should be_nil
127
+
128
+ pool.add_plugin_module(TestPlugin)
129
+ pool.plugin_modules.should_not be_nil
130
+ pool.plugin_modules.size.should == 1
131
+ pool.plugin_modules[0] == TestPlugin
132
+ }
133
+
134
+ it {
135
+ pool = Roma::Client::ClientPool.instance(:pms_test)
136
+ pool.plugin_modules.should be_nil
137
+
138
+ pool.plugin_modules = [TestPlugin, TestPlugin2]
139
+ pool.plugin_modules.size.should == 2
140
+ pool.plugin_modules[0] == TestPlugin
141
+ pool.plugin_modules[1] == TestPlugin2
142
+ }
143
+
144
+ it {
145
+ pool = Roma::Client::ClientPool.instance(:pms_test2)
146
+ pool.servers = get_nodes
147
+ pool.plugin_modules.should be_nil
148
+
149
+ pool.plugin_modules = [TestPlugin, TestPlugin2]
150
+ client = pool.client
151
+ client.should_not be_nil
152
+ client.test_plugin.should == "test_plugin"
153
+ client.test_plugin2.should == "test_plugin2"
154
+ }
155
+ end
156
+
157
+ context "default type" do
158
+ subject { Roma::Client::ClientPool.instance }
159
+ it { should_not be_nil }
160
+ it { subject.class.should == Roma::Client::ClientPool }
161
+ it { subject.should be_equal Roma::Client::ClientPool.instance(:default) }
162
+ end
163
+
164
+ context "support hash name" do
165
+ after(:all) {
166
+ Roma::Client::ClientPool.instance.default_hash_name = 'roma'
167
+ }
168
+
169
+ subject {
170
+ pool = Roma::Client::ClientPool.instance
171
+ pool.servers = get_nodes
172
+ pool
173
+ }
174
+
175
+ it { subject.default_hash_name.should == 'roma' }
176
+ it {
177
+ subject.default_hash_name = 'new_name'
178
+ subject.default_hash_name.should == 'new_name'
179
+ Roma::Client::ClientPool.instance.default_hash_name.should == 'new_name'
180
+ Roma::Client::ClientPool.instance(:other).default_hash_name.should == 'roma'
181
+
182
+ client = subject.client
183
+ client.default_hash_name.should == 'new_name'
184
+ }
185
+ end
186
+
187
+ context "release" do
188
+ subject {
189
+ pool = Roma::Client::ClientPool.instance(:release_test)
190
+ pool.servers = get_nodes
191
+ pool
192
+ }
193
+
194
+ it {
195
+ subject.pool_count.should == 0
196
+ subject.client do |client|
197
+ end
198
+
199
+ subject.pool_count.should == 1
200
+ subject.release.should be_true
201
+ subject.pool_count.should == 0
202
+ }
203
+ end
204
+
205
+ context "client block" do
206
+ before(:each) do
207
+ pool = Roma::Client::ClientPool.instance(:client_block)
208
+ pool.release
209
+ end
210
+
211
+ subject {
212
+ pool = Roma::Client::ClientPool.instance(:client_block)
213
+ pool.servers = get_nodes
214
+ pool
215
+ }
216
+
217
+ it "use block"do
218
+ subject.pool_count.should == 0
219
+ subject.client do |client|
220
+ client.set("test", "value").should == "STORED"
221
+ end
222
+ subject.pool_count.should == 1
223
+ end
224
+
225
+ it "raise exception in block, but pool certainly" do
226
+ subject.pool_count.should == 0
227
+ subject.client do |client|
228
+ client.set("test", "value").should == "STORED"
229
+ end
230
+ subject.pool_count.should == 1
231
+
232
+ lambda {
233
+ subject.client do |client|
234
+ raise "test error"
235
+ end
236
+ }.should raise_error RuntimeError, "test error"
237
+
238
+ subject.pool_count.should == 1
239
+ end
240
+ end
241
+
242
+ context "start sync routing proc" do
243
+ it {
244
+ pool = Roma::Client::ClientPool.instance(:sync_test)
245
+ pool.servers = get_nodes
246
+ old_thread_count = Thread.list.length
247
+ pool.client do |c|
248
+ end
249
+
250
+ pool.pool_count.should == 1
251
+ Thread.list.length.should == old_thread_count + 1
252
+ }
253
+
254
+ it {
255
+ pool = Roma::Client::ClientPool.instance(:no_sync_test)
256
+ pool.servers = get_nodes
257
+ pool.start_sync_routing_proc = false
258
+ old_thread_count = Thread.list.length
259
+ pool.client do |c|
260
+ end
261
+
262
+ pool.pool_count.should == 1
263
+ Thread.list.length.should == old_thread_count
264
+ }
265
+ end
266
+
267
+ context "release all" do
268
+ it {
269
+ pool = Roma::Client::ClientPool.instance(:release_all_1)
270
+ pool.servers = get_nodes
271
+ pool.client do |c|
272
+ end
273
+ Roma::Client::ClientPool.instance(:release_all_1).pool_count.should == 1
274
+
275
+ pool = Roma::Client::ClientPool.instance(:release_all_2)
276
+ pool.servers = get_nodes
277
+ pool.client do |c|
278
+ end
279
+ pool.pool_count.should == 1
280
+ Roma::Client::ClientPool.instance(:release_all_2).pool_count.should == 1
281
+
282
+ Roma::Client::ClientPool.release_all
283
+ Roma::Client::ClientPool.instance(:release_all_1).pool_count.should == 0
284
+ Roma::Client::ClientPool.instance(:release_all_2).pool_count.should == 0
285
+ }
286
+ end
287
+ end
288
+
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+ require File.expand_path(File.join('..', '..', 'spec_helper'), File.dirname(__FILE__))
3
+
4
+ describe Roma::Client::VERSION do
5
+ it 'should string' do
6
+ Roma::Client::VERSION::STRING.should ==
7
+ "#{Roma::Client::VERSION::MAJOR}." +
8
+ "#{Roma::Client::VERSION::MINOR}." +
9
+ "#{Roma::Client::VERSION::TINY}"
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'rspec'
3
+
4
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ Dir[File.dirname(__FILE__) + "/supports/**/*.rb"].each {|f| require f}
6
+
7
+ require 'roma-client'
8
+
9
+ RSpec.configure do |config|
10
+ config.mock_with :rr
11
+ end
12
+
metadata CHANGED
@@ -1,16 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roma-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
5
11
  platform: ruby
6
- authors: []
7
-
12
+ authors:
13
+ - Muga Nishizawa
14
+ - Junji Torii
8
15
  autorequire:
9
16
  bindir: bin
10
17
  cert_chain: []
11
18
 
12
- date: 2010-02-19 00:00:00 +09:00
13
- default_executable:
19
+ date: 2011-12-21 00:00:00 Z
14
20
  dependencies: []
15
21
 
16
22
  description: " ROMA client library\n"
@@ -21,25 +27,33 @@ extensions: []
21
27
 
22
28
  extra_rdoc_files:
23
29
  - README
30
+ - CHANGELOG
24
31
  files:
25
- - Rakefile
26
32
  - README
33
+ - Rakefile
34
+ - CHANGELOG
35
+ - Gemfile.lock
27
36
  - LICENSE
28
- - bin/sample
29
- - bin/rcdaemon
37
+ - Gemfile
30
38
  - bin/showbalance
39
+ - bin/rcdaemon
40
+ - bin/sample
41
+ - lib/roma-client.rb
31
42
  - lib/roma/client/proxy/version.rb
32
43
  - lib/roma/client/proxy/daemon.rb
33
- - lib/roma/client/tools/showbalance.rb
34
44
  - lib/roma/client/con_pool.rb
35
45
  - lib/roma/client/version.rb
36
- - lib/roma/client/sender.rb
37
46
  - lib/roma/client/rlogger.rb
47
+ - lib/roma/client/client_pool.rb
38
48
  - lib/roma/client/routing/routing_data.rb
49
+ - lib/roma/client/sender.rb
39
50
  - lib/roma/client/rclient.rb
40
51
  - lib/roma/client/client_rttable.rb
52
+ - lib/roma/client/tools/showbalance.rb
41
53
  - lib/roma/client.rb
42
- has_rdoc: true
54
+ - spec/roma/client/client_pool_spec.rb
55
+ - spec/roma/client/version_spec.rb
56
+ - spec/spec_helper.rb
43
57
  homepage:
44
58
  licenses: []
45
59
 
@@ -48,26 +62,32 @@ rdoc_options:
48
62
  - --line-numbers
49
63
  - --inline-source
50
64
  - --main
51
- - README.rdoc
65
+ - README
52
66
  - -c UTF-8
53
67
  require_paths:
54
68
  - lib
55
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
56
71
  requirements:
57
72
  - - ">="
58
73
  - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
59
77
  version: "0"
60
- version:
61
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
62
80
  requirements:
63
81
  - - ">="
64
82
  - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
65
86
  version: "0"
66
- version:
67
87
  requirements: []
68
88
 
69
89
  rubyforge_project:
70
- rubygems_version: 1.3.5
90
+ rubygems_version: 1.8.12
71
91
  signing_key:
72
92
  specification_version: 3
73
93
  summary: ROMA client library