Module: Zookeeper::ClientMethods
- Extended by:
- Forwardable
- Includes:
- ACLs, Constants, Logger
- Defined in:
- lib/zookeeper/client_methods.rb
Constant Summary
Constants included
from Constants
Zookeeper::Constants::CONNECTED_EVENT_VALUES, Zookeeper::Constants::EVENT_TYPE_NAMES, Zookeeper::Constants::STATE_NAMES, Zookeeper::Constants::ZAPIERROR, Zookeeper::Constants::ZAUTHFAILED, Zookeeper::Constants::ZBADARGUMENTS, Zookeeper::Constants::ZBADVERSION, Zookeeper::Constants::ZCLOSING, Zookeeper::Constants::ZCONNECTIONLOSS, Zookeeper::Constants::ZDATAINCONSISTENCY, Zookeeper::Constants::ZINVALIDACL, Zookeeper::Constants::ZINVALIDCALLBACK, Zookeeper::Constants::ZINVALIDSTATE, Zookeeper::Constants::ZKRB_ASYNC_CONTN_ID, Zookeeper::Constants::ZKRB_GLOBAL_CB_REQ, Zookeeper::Constants::ZMARSHALLINGERROR, Zookeeper::Constants::ZNOAUTH, Zookeeper::Constants::ZNOCHILDRENFOREPHEMERALS, Zookeeper::Constants::ZNODEEXISTS, Zookeeper::Constants::ZNONODE, Zookeeper::Constants::ZNOTEMPTY, Zookeeper::Constants::ZNOTHING, Zookeeper::Constants::ZOK, Zookeeper::Constants::ZOO_ASSOCIATING_STATE, Zookeeper::Constants::ZOO_AUTH_FAILED_STATE, Zookeeper::Constants::ZOO_CHANGED_EVENT, Zookeeper::Constants::ZOO_CHILD_EVENT, Zookeeper::Constants::ZOO_CLOSED_STATE, Zookeeper::Constants::ZOO_CONNECTED_STATE, Zookeeper::Constants::ZOO_CONNECTING_STATE, Zookeeper::Constants::ZOO_CREATED_EVENT, Zookeeper::Constants::ZOO_DELETED_EVENT, Zookeeper::Constants::ZOO_EPHEMERAL, Zookeeper::Constants::ZOO_EXPIRED_SESSION_STATE, Zookeeper::Constants::ZOO_LOG_LEVEL_DEBUG, Zookeeper::Constants::ZOO_LOG_LEVEL_ERROR, Zookeeper::Constants::ZOO_LOG_LEVEL_INFO, Zookeeper::Constants::ZOO_LOG_LEVEL_WARN, Zookeeper::Constants::ZOO_NOTWATCHING_EVENT, Zookeeper::Constants::ZOO_SEQUENCE, Zookeeper::Constants::ZOO_SESSION_EVENT, Zookeeper::Constants::ZOPERATIONTIMEOUT, Zookeeper::Constants::ZRUNTIMEINCONSISTENCY, Zookeeper::Constants::ZSESSIONEXPIRED, Zookeeper::Constants::ZSESSIONMOVED, Zookeeper::Constants::ZSYSTEMERROR, Zookeeper::Constants::ZUNIMPLEMENTED
ACLs::Constants::ZOO_ANYONE_ID_UNSAFE, ACLs::Constants::ZOO_AUTH_IDS, ACLs::Constants::ZOO_CREATOR_ALL_ACL, ACLs::Constants::ZOO_OPEN_ACL_UNSAFE, ACLs::Constants::ZOO_PERM_ADMIN, ACLs::Constants::ZOO_PERM_ALL, ACLs::Constants::ZOO_PERM_CREATE, ACLs::Constants::ZOO_PERM_DELETE, ACLs::Constants::ZOO_PERM_READ, ACLs::Constants::ZOO_PERM_WRITE, ACLs::Constants::ZOO_READ_ACL_UNSAFE
Instance Method Summary
collapse
Methods included from Logger
included, set_default
Methods included from Constants
#event_by_value, #state_by_value
Instance Method Details
#add_auth(options = {}) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/zookeeper/client_methods.rb', line 21
def add_auth(options = {})
assert_open
assert_keys(options,
:supported => [:scheme, :cert],
:required => [:scheme, :cert])
req_id = setup_call(:add_auth, options)
rc = super(req_id, options[:scheme], options[:cert])
{ :req_id => req_id, :rc => rc }
end
|
#associating? ⇒ Boolean
185
186
187
|
# File 'lib/zookeeper/client_methods.rb', line 185
def associating?
super
end
|
#close ⇒ Object
close this client and any underyling connections
169
170
171
|
# File 'lib/zookeeper/client_methods.rb', line 169
def close
super
end
|
#closed? ⇒ Boolean
has the underlying connection been closed?
205
206
207
|
# File 'lib/zookeeper/client_methods.rb', line 205
def closed?
super
end
|
#connected? ⇒ Boolean
177
178
179
|
# File 'lib/zookeeper/client_methods.rb', line 177
def connected?
super
end
|
#connecting? ⇒ Boolean
181
182
183
|
# File 'lib/zookeeper/client_methods.rb', line 181
def connecting?
super
end
|
#create(options = {}) ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/zookeeper/client_methods.rb', line 88
def create(options = {})
assert_open
assert_keys(options,
:supported => [:path, :data, :acl, :ephemeral, :sequence, :callback, :callback_context],
:required => [:path])
assert_valid_data_size!(options[:data])
flags = 0
flags |= ZOO_EPHEMERAL if options[:ephemeral]
flags |= ZOO_SEQUENCE if options[:sequence]
options[:acl] ||= ZOO_OPEN_ACL_UNSAFE
req_id = setup_call(:create, options)
rc, newpath = super(req_id, options[:path], options[:data], options[:callback], options[:acl], flags)
rv = { :req_id => req_id, :rc => rc }
options[:callback] ? rv : rv.merge(:path => newpath)
end
|
#delete(options = {}) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/zookeeper/client_methods.rb', line 109
def delete(options = {})
assert_open
assert_keys(options,
:supported => [:path, :version, :callback, :callback_context],
:required => [:path])
options[:version] ||= -1
req_id = setup_call(:delete, options)
rc = super(req_id, options[:path], options[:version], options[:callback])
{ :req_id => req_id, :rc => rc }
end
|
#event_dispatch_thread? ⇒ Boolean
There are some operations that are dangerous in the context of the event dispatch thread (because they would block further event delivery). This method allows clients to know if they’re currently executing in the context of an event.
195
196
197
|
# File 'lib/zookeeper/client_methods.rb', line 195
def event_dispatch_thread?
super
end
|
#get(options = {}) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/zookeeper/client_methods.rb', line 33
def get(options = {})
assert_open
assert_keys(options,
:supported => [:path, :watcher, :watcher_context, :callback, :callback_context],
:required => [:path])
req_id = setup_call(:get, options)
rc, value, stat = super(req_id, options[:path], options[:callback], options[:watcher])
rv = { :req_id => req_id, :rc => rc }
options[:callback] ? rv : rv.merge(:data => value, :stat => Stat.new(stat))
end
|
#get_acl(options = {}) ⇒ Object
155
156
157
158
159
160
161
162
163
164
165
166
|
# File 'lib/zookeeper/client_methods.rb', line 155
def get_acl(options = {})
assert_open
assert_keys(options,
:supported => [:path, :callback, :callback_context],
:required => [:path])
req_id = setup_call(:get_acl, options)
rc, acls, stat = super(req_id, options[:path], options[:callback])
rv = { :req_id => req_id, :rc => rc }
options[:callback] ? rv : rv.merge(:acl => acls, :stat => Stat.new(stat))
end
|
#get_children(options = {}) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/zookeeper/client_methods.rb', line 62
def get_children(options = {})
assert_open
assert_keys(options,
:supported => [:path, :callback, :callback_context, :watcher, :watcher_context],
:required => [:path])
req_id = setup_call(:get_children, options)
rc, children, stat = super(req_id, options[:path], options[:callback], options[:watcher])
rv = { :req_id => req_id, :rc => rc }
options[:callback] ? rv : rv.merge(:children => children, :stat => Stat.new(stat))
end
|
#initialize(host, timeout = 10, watcher = nil) ⇒ Object
17
18
19
|
# File 'lib/zookeeper/client_methods.rb', line 17
def initialize(host, timeout=10, watcher=nil)
super
end
|
#pause_before_fork_in_parent ⇒ Object
stop all underlying threads in preparation for a fork()
225
226
227
|
# File 'lib/zookeeper/client_methods.rb', line 225
def pause_before_fork_in_parent
super
end
|
#reopen(timeout = 10, watcher = nil) ⇒ Object
12
13
14
15
|
# File 'lib/zookeeper/client_methods.rb', line 12
def reopen(timeout=10, watcher=nil)
warn "WARN: ZookeeperBase#reopen watcher argument is now ignored" if watcher
super
end
|
#resume_after_fork_in_parent ⇒ Object
re-start all underlying threads after performing a fork()
230
231
232
|
# File 'lib/zookeeper/client_methods.rb', line 230
def resume_after_fork_in_parent
super
end
|
#running? ⇒ Boolean
is the event delivery system running?
210
211
212
|
# File 'lib/zookeeper/client_methods.rb', line 210
def running?
super
end
|
#session_id ⇒ Object
return the session id of the current connection as an Fixnum
215
216
217
|
# File 'lib/zookeeper/client_methods.rb', line 215
def session_id
super
end
|
#session_passwd ⇒ Object
Return the passwd portion of this connection’s credentials as a String
220
221
222
|
# File 'lib/zookeeper/client_methods.rb', line 220
def session_passwd
super
end
|
#set(options = {}) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/zookeeper/client_methods.rb', line 46
def set(options = {})
assert_open
assert_keys(options,
:supported => [:path, :data, :version, :callback, :callback_context],
:required => [:path])
assert_valid_data_size!(options[:data])
options[:version] ||= -1
req_id = setup_call(:set, options)
rc, stat = super(req_id, options[:path], options[:data], options[:callback], options[:version])
rv = { :req_id => req_id, :rc => rc }
options[:callback] ? rv : rv.merge(:stat => Stat.new(stat))
end
|
#set_acl(options = {}) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/zookeeper/client_methods.rb', line 142
def set_acl(options = {})
assert_open
assert_keys(options,
:supported => [:path, :acl, :version, :callback, :callback_context],
:required => [:path, :acl])
options[:version] ||= -1
req_id = setup_call(:set_acl, options)
rc = super(req_id, options[:path], options[:acl], options[:callback], options[:version])
{ :req_id => req_id, :rc => rc }
end
|
#set_debug_level(val) ⇒ Object
DEPRECATED: use the class-level method instead
200
201
202
|
# File 'lib/zookeeper/client_methods.rb', line 200
def set_debug_level(val)
super
end
|
#stat(options = {}) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/zookeeper/client_methods.rb', line 75
def stat(options = {})
assert_open
assert_keys(options,
:supported => [:path, :callback, :callback_context, :watcher, :watcher_context],
:required => [:path])
req_id = setup_call(:stat, options)
rc, stat = exists(req_id, options[:path], options[:callback], options[:watcher])
rv = { :req_id => req_id, :rc => rc }
options[:callback] ? rv : rv.merge(:stat => Stat.new(stat))
end
|
#state ⇒ Object
173
174
175
|
# File 'lib/zookeeper/client_methods.rb', line 173
def state
super
end
|
#sync(options = {}) ⇒ Object
Note:
There is a discrepancy between the zkc and java versions. zkc takes a string_callback_t, java takes a VoidCallback. You should most likely use the Zookeeper::Callbacks::VoidCallback and not rely on the string value.
this method is only asynchronous
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/zookeeper/client_methods.rb', line 129
def sync(options = {})
assert_open
assert_keys(options,
:supported => [:path, :callback, :callback_context],
:required => [:path, :callback])
req_id = setup_call(:sync, options)
rc = super(req_id, options[:path])
{ :req_id => req_id, :rc => rc }
end
|