slyphon-zookeeper 0.3.0-java → 0.8.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +34 -0
- data/Rakefile +25 -5
- data/ext/c_zookeeper.rb +214 -0
- data/ext/dbg.h +18 -2
- data/ext/depend +1 -2
- data/ext/zookeeper_base.rb +73 -99
- data/ext/zookeeper_c.c +52 -41
- data/ext/zookeeper_lib.c +90 -78
- data/ext/zookeeper_lib.h +0 -1
- data/java/zookeeper_base.rb +72 -154
- data/lib/zookeeper/common/queue_with_pipe.rb +78 -0
- data/lib/zookeeper/common.rb +73 -9
- data/lib/zookeeper/constants.rb +28 -0
- data/lib/zookeeper/em_client.rb +13 -138
- data/lib/zookeeper/exceptions.rb +4 -1
- data/lib/zookeeper.rb +51 -15
- data/slyphon-zookeeper.gemspec +1 -1
- data/spec/c_zookeeper_spec.rb +50 -0
- data/spec/chrooted_connection_spec.rb +121 -0
- data/spec/em_spec.rb +0 -61
- data/spec/shared/all_success_return_values.rb +10 -0
- data/spec/shared/connection_examples.rb +1007 -0
- data/spec/spec_helper.rb +42 -19
- data/spec/zookeeper_spec.rb +8 -1033
- metadata +16 -6
data/spec/spec_helper.rb
CHANGED
@@ -9,34 +9,57 @@ gem 'flexmock', '~> 0.8.11'
|
|
9
9
|
require 'flexmock'
|
10
10
|
require 'zookeeper'
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
Dir[File.expand_path('../support/**/*.rb', __FILE__)].sort.each { |f| require(f) }
|
13
|
+
|
14
|
+
if ENV['ZKRB_DEBUG']
|
15
|
+
Zookeeper.logger = Logger.new($stderr).tap { |l| l.level = Logger::DEBUG }
|
16
|
+
Zookeeper.set_debug_level(4)
|
17
|
+
else
|
18
|
+
Zookeeper.logger = Logger.new(File.expand_path('../../test.log', __FILE__)).tap do |log|
|
19
|
+
log.level = Logger::DEBUG
|
20
|
+
end
|
14
21
|
end
|
15
22
|
|
16
|
-
|
23
|
+
if ENV['ZKRB_NOLOG']
|
24
|
+
Zookeeper.logger.level = Logger::FATAL
|
25
|
+
Zookeeper.set_debug_level(0)
|
26
|
+
end
|
27
|
+
|
28
|
+
module ZookeeperSpecHeleprs
|
29
|
+
class TimeoutError < StandardError; end
|
17
30
|
|
18
|
-
|
19
|
-
|
20
|
-
|
31
|
+
def logger
|
32
|
+
Zookeeper.logger
|
33
|
+
end
|
21
34
|
|
22
|
-
#
|
23
|
-
#
|
35
|
+
# method to wait until block passed returns true or timeout (default is 10 seconds) is reached
|
36
|
+
# raises TiemoutError on timeout
|
37
|
+
def wait_until(timeout=10)
|
38
|
+
time_to_stop = Time.now + timeout
|
39
|
+
while true
|
40
|
+
rval = yield
|
41
|
+
return rval if rval
|
42
|
+
raise TimeoutError, "timeout of #{timeout}s exceeded" if Time.now > time_to_stop
|
43
|
+
Thread.pass
|
44
|
+
end
|
45
|
+
end
|
24
46
|
|
25
|
-
|
26
|
-
|
47
|
+
# inverse of wait_until
|
48
|
+
def wait_while(timeout=10)
|
49
|
+
time_to_stop = Time.now + timeout
|
50
|
+
while true
|
51
|
+
rval = yield
|
52
|
+
return rval unless rval
|
53
|
+
raise TimeoutError, "timeout of #{timeout}s exceeded" if Time.now > time_to_stop
|
54
|
+
Thread.pass
|
55
|
+
end
|
56
|
+
end
|
27
57
|
end
|
28
58
|
|
29
59
|
RSpec.configure do |config|
|
30
60
|
config.mock_with :flexmock
|
61
|
+
config.include ZookeeperSpecHeleprs
|
62
|
+
config.extend ZookeeperSpecHeleprs
|
31
63
|
end
|
32
64
|
|
33
65
|
|
34
|
-
# method to wait until block passed returns true or timeout (default is 10 seconds) is reached
|
35
|
-
def wait_until(timeout=10, &block)
|
36
|
-
time_to_stop = Time.now + timeout
|
37
|
-
until yield do
|
38
|
-
break if Time.now > time_to_stop
|
39
|
-
sleep 0.3
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|