Module: Zookeeper::ClientMethods
- Includes:
- ACLs, Constants
- 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_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 Constants
#event_by_value, #state_by_value
Instance Method Details
#associating? ⇒ Boolean
155
156
157
|
# File 'lib/zookeeper/client_methods.rb', line 155
def associating?
super
end
|
#close ⇒ Object
close this client and any underyling connections
139
140
141
|
# File 'lib/zookeeper/client_methods.rb', line 139
def close
super
end
|
#closed? ⇒ Boolean
has the underlying connection been closed?
175
176
177
|
# File 'lib/zookeeper/client_methods.rb', line 175
def closed?
super
end
|
#connected? ⇒ Boolean
147
148
149
|
# File 'lib/zookeeper/client_methods.rb', line 147
def connected?
super
end
|
#connecting? ⇒ Boolean
151
152
153
|
# File 'lib/zookeeper/client_methods.rb', line 151
def connecting?
super
end
|
#create(options = {}) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/zookeeper/client_methods.rb', line 65
def create(options = {})
assert_open
assert_supported_keys(options, [:path, :data, :acl, :ephemeral, :sequence, :callback, :callback_context])
assert_required_keys(options, [: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
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/zookeeper/client_methods.rb', line 84
def delete(options = {})
assert_open
assert_supported_keys(options, [:path, :version, :callback, :callback_context])
assert_required_keys(options, [: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.
165
166
167
|
# File 'lib/zookeeper/client_methods.rb', line 165
def event_dispatch_thread?
super
end
|
#get(options = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/zookeeper/client_methods.rb', line 15
def get(options = {})
assert_open
assert_supported_keys(options, [:path, :watcher, :watcher_context, :callback, :callback_context])
assert_required_keys(options, [: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
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/zookeeper/client_methods.rb', line 126
def get_acl(options = {})
assert_open
assert_supported_keys(options, [:path, :callback, :callback_context])
assert_required_keys(options, [: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
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/zookeeper/client_methods.rb', line 41
def get_children(options = {})
assert_open
assert_supported_keys(options, [:path, :callback, :callback_context, :watcher, :watcher_context])
assert_required_keys(options, [: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
11
12
13
|
# File 'lib/zookeeper/client_methods.rb', line 11
def initialize(host, timeout=10, watcher=nil)
super
end
|
#reopen(timeout = 10, watcher = nil) ⇒ Object
6
7
8
9
|
# File 'lib/zookeeper/client_methods.rb', line 6
def reopen(timeout=10, watcher=nil)
warn "WARN: ZookeeperBase#reopen watcher argument is now ignored" if watcher
super
end
|
#running? ⇒ Boolean
is the event delivery system running?
180
181
182
|
# File 'lib/zookeeper/client_methods.rb', line 180
def running?
super
end
|
#session_id ⇒ Object
return the session id of the current connection as an Fixnum
185
186
187
|
# File 'lib/zookeeper/client_methods.rb', line 185
def session_id
super
end
|
#session_passwd ⇒ Object
Return the passwd portion of this connection’s credentials as a String
190
191
192
|
# File 'lib/zookeeper/client_methods.rb', line 190
def session_passwd
super
end
|
#set(options = {}) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/zookeeper/client_methods.rb', line 27
def set(options = {})
assert_open
assert_supported_keys(options, [:path, :data, :version, :callback, :callback_context])
assert_required_keys(options, [: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
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/zookeeper/client_methods.rb', line 114
def set_acl(options = {})
assert_open
assert_supported_keys(options, [:path, :acl, :version, :callback, :callback_context])
assert_required_keys(options, [: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
170
171
172
|
# File 'lib/zookeeper/client_methods.rb', line 170
def set_debug_level(val)
super
end
|
#stat(options = {}) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/zookeeper/client_methods.rb', line 53
def stat(options = {})
assert_open
assert_supported_keys(options, [:path, :callback, :callback_context, :watcher, :watcher_context])
assert_required_keys(options, [: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
143
144
145
|
# File 'lib/zookeeper/client_methods.rb', line 143
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 ZookeeperCallbacks::VoidCallback and not rely on the string value.
this method is only asynchronous
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/zookeeper/client_methods.rb', line 102
def sync(options = {})
assert_open
assert_supported_keys(options, [:path, :callback, :callback_context])
assert_required_keys(options, [:path, :callback])
req_id = setup_call(:sync, options)
rc = super(req_id, options[:path])
{ :req_id => req_id, :rc => rc }
end
|