slyphon-zookeeper 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,16 @@
1
+ v0.8.3 fix NonLocalJump exception in event delivery thread shutdown code
2
+
3
+ * hit a corner case where we're waiting for the zkc handle setup
4
+ and the user decides to shutdown, but before we've had a chance
5
+ to enter the delivery loop.
6
+
7
+ * Cleaned up some nasty code in ZookeeperConstants
8
+
9
+ * removed ZookeeperConstants#print_events and ZookeeperConstants#print_states
10
+
11
+ * changed EVENT_TYPE_NAMES and EVENT_STATE_NAMES in ZookeeperConstants
12
+ to use string values instead of symbols
13
+
1
14
  v0.8.2 fix close after a fork()
2
15
 
3
16
  * The dispatch thread will be dead in this situation, so we need to
data/ext/c_zookeeper.rb CHANGED
@@ -135,32 +135,30 @@ class CZookeeper
135
135
  end
136
136
 
137
137
  def setup_event_thread!
138
- @event_thread ||= Thread.new do
139
- Thread.current.abort_on_exception = true # remove this once this is confirmed to work
138
+ @event_thread ||= Thread.new(&method(:_event_thread_body))
139
+ end
140
140
 
141
- logger.debug { "event_thread waiting until running: #{@_running}" }
141
+ def _event_thread_body
142
+ logger.debug { "event_thread waiting until running: #{@_running}" }
142
143
 
143
- @start_stop_mutex.synchronize do
144
- @running_cond.wait_until { @_running }
144
+ @start_stop_mutex.synchronize do
145
+ @running_cond.wait_until { @_running }
145
146
 
146
- if @_shutting_down
147
- logger.error { "event thread saw @_shutting_down, bailing without entering loop" }
148
- return
149
- end
147
+ if @_shutting_down
148
+ logger.error { "event thread saw @_shutting_down, bailing without entering loop" }
149
+ return
150
150
  end
151
+ end
151
152
 
152
- logger.debug { "event_thread running: #{@_running}" }
153
+ logger.debug { "event_thread running: #{@_running}" }
153
154
 
154
- while true
155
- begin
156
- _iterate_event_delivery
157
- rescue GotNilEventException
158
- logger.debug { "#{self.class}##{__method__}: event delivery thread is exiting" }
159
- break
160
- end
155
+ while true
156
+ begin
157
+ _iterate_event_delivery
158
+ rescue GotNilEventException
159
+ logger.debug { "#{self.class}##{__method__}: event delivery thread is exiting" }
160
+ break
161
161
  end
162
-
163
- # TODO: should we try iterating events after this point? to see if any are left?
164
162
  end
165
163
  end
166
164
 
@@ -28,56 +28,30 @@ module ZookeeperConstants
28
28
  # used to find the name for a numeric event
29
29
  # @private
30
30
  EVENT_TYPE_NAMES = {
31
- 1 => :created,
32
- 2 => :deleted,
33
- 3 => :changed,
34
- 4 => :child,
35
- -1 => :session,
36
- -2 => :notwatching,
31
+ 1 => 'created',
32
+ 2 => 'deleted',
33
+ 3 => 'changed',
34
+ 4 => 'child',
35
+ -1 => 'session',
36
+ -2 => 'notwatching',
37
37
  }
38
38
 
39
39
  # used to pretty print the state name
40
40
  # @private
41
41
  STATE_NAMES = {
42
- -112 => :expired_session,
43
- -113 => :auth_failed,
44
- 0 => :closed,
45
- 1 => :connecting,
46
- 2 => :associating,
47
- 3 => :connected,
42
+ -112 => 'expired_session',
43
+ -113 => 'auth_failed',
44
+ 0 => 'closed',
45
+ 1 => 'connecting',
46
+ 2 => 'associating',
47
+ 3 => 'connected',
48
48
  }
49
49
 
50
- def print_events
51
- puts "ZK events:"
52
- ZookeeperConstants::constants.each do |c|
53
- puts "\t #{c}" if c =~ /^ZOO..*EVENT$/
54
- end
55
- end
56
-
57
- def print_states
58
- puts "ZK states:"
59
- ZookeeperConstants::constants.each do |c|
60
- puts "\t #{c}" if c =~ /^ZOO..*STATE$/
61
- end
62
- end
63
-
64
50
  def event_by_value(v)
65
- return unless v
66
- ZookeeperConstants::constants.each do |c|
67
- next unless c =~ /^ZOO..*EVENT$/
68
- if eval("ZookeeperConstants::#{c}") == v
69
- return c
70
- end
71
- end
51
+ (name = EVENT_TYPE_NAMES[v]) ? "ZOO_#{name.upcase}_EVENT" : ''
72
52
  end
73
-
53
+
74
54
  def state_by_value(v)
75
- return unless v
76
- ZookeeperConstants::constants.each do |c|
77
- next unless c =~ /^ZOO..*STATE$/
78
- if eval("ZookeeperConstants::#{c}") == v
79
- return c
80
- end
81
- end
55
+ (name = STATE_NAMES[v]) ? "ZOO_#{name.upcase}_STATE" : ''
82
56
  end
83
57
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "slyphon-zookeeper"
6
- s.version = '0.8.2'
6
+ s.version = '0.8.3'
7
7
 
8
8
  s.authors = ["Phillip Pearson", "Eric Maland", "Evan Weaver", "Brian Wickman", "Neil Conway", "Jonathan D. Simms"]
9
9
  s.email = ["slyphon@gmail.com"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slyphon-zookeeper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 2
10
- version: 0.8.2
9
+ - 3
10
+ version: 0.8.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Phillip Pearson
@@ -20,7 +20,7 @@ autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
22
 
23
- date: 2012-04-23 00:00:00 Z
23
+ date: 2012-04-25 00:00:00 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
@@ -62,7 +62,7 @@ dependencies:
62
62
  requirements:
63
63
  - - "="
64
64
  - !ruby/object:Gem::Version
65
- hash: -1854519556
65
+ hash: -746177298
66
66
  segments:
67
67
  - 1
68
68
  - 0