Module: Zookeeper::ClientMethods
- Extended by:
- Forwardable
- 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
Constants included from ACLs::Constants
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
- #add_auth(options = {}) ⇒ Object
- #associating? ⇒ Boolean
-
#close ⇒ Object
close this client and any underlying connections.
-
#closed? ⇒ Boolean
has the underlying connection been closed?.
- #connected? ⇒ Boolean
- #connecting? ⇒ Boolean
- #create(options = {}) ⇒ Object
- #delete(options = {}) ⇒ Object
-
#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).
- #get(options = {}) ⇒ Object
- #get_acl(options = {}) ⇒ Object
- #get_children(options = {}) ⇒ Object
- #initialize(host, timeout = 10, watcher = nil, opts = {}) ⇒ Object
-
#pause_before_fork_in_parent ⇒ Object
stop all underlying threads in preparation for a fork().
- #reopen(timeout = 10, watcher = nil, opts = {}) ⇒ Object
-
#resume_after_fork_in_parent ⇒ Object
re-start all underlying threads after performing a fork().
-
#running? ⇒ Boolean
is the event delivery system running?.
-
#session_id ⇒ Object
return the session id of the current connection as an Fixnum.
-
#session_passwd ⇒ Object
Return the passwd portion of this connection’s credentials as a String.
- #set(options = {}) ⇒ Object
- #set_acl(options = {}) ⇒ Object
-
#set_debug_level(val) ⇒ Object
DEPRECATED: use the class-level method instead.
- #stat(options = {}) ⇒ Object
- #state ⇒ Object
-
#sync(options = {}) ⇒ Object
this method is only asynchronous.
Methods included from Logger
included, wrapped_logger, wrapped_logger=
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( = {}) assert_open assert_keys(, :supported => [:scheme, :cert], :required => [:scheme, :cert]) req_id = setup_call(:add_auth, ) rc = super(req_id, [:scheme], [: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 underlying 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( = {}) assert_open assert_keys(, :supported => [:path, :data, :acl, :ephemeral, :sequence, :callback, :callback_context], :required => [:path]) assert_valid_data_size!([:data]) flags = 0 flags |= ZOO_EPHEMERAL if [:ephemeral] flags |= ZOO_SEQUENCE if [:sequence] [:acl] ||= ZOO_OPEN_ACL_UNSAFE req_id = setup_call(:create, ) rc, newpath = super(req_id, [:path], [:data], [:callback], [:acl], flags) rv = { :req_id => req_id, :rc => rc } [: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( = {}) assert_open assert_keys(, :supported => [:path, :version, :callback, :callback_context], :required => [:path]) [:version] ||= -1 req_id = setup_call(:delete, ) rc = super(req_id, [:path], [:version], [: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( = {}) assert_open assert_keys(, :supported => [:path, :watcher, :watcher_context, :callback, :callback_context], :required => [:path]) req_id = setup_call(:get, ) rc, value, stat = super(req_id, [:path], [:callback], [:watcher]) rv = { :req_id => req_id, :rc => rc } [: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( = {}) assert_open assert_keys(, :supported => [:path, :callback, :callback_context], :required => [:path]) req_id = setup_call(:get_acl, ) rc, acls, stat = super(req_id, [:path], [:callback]) rv = { :req_id => req_id, :rc => rc } [: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( = {}) assert_open assert_keys(, :supported => [:path, :callback, :callback_context, :watcher, :watcher_context], :required => [:path]) req_id = setup_call(:get_children, ) rc, children, stat = super(req_id, [:path], [:callback], [:watcher]) rv = { :req_id => req_id, :rc => rc } [:callback] ? rv : rv.merge(:children => children, :stat => Stat.new(stat)) end |
#initialize(host, timeout = 10, watcher = nil, opts = {}) ⇒ Object
17 18 19 |
# File 'lib/zookeeper/client_methods.rb', line 17 def initialize(host, timeout=10, watcher=nil, opts = {}) 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, opts = {}) ⇒ Object
12 13 14 15 |
# File 'lib/zookeeper/client_methods.rb', line 12 def reopen(timeout=10, watcher=nil, opts = {}) 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( = {}) assert_open assert_keys(, :supported => [:path, :data, :version, :callback, :callback_context], :required => [:path]) assert_valid_data_size!([:data]) [:version] ||= -1 req_id = setup_call(:set, ) rc, stat = super(req_id, [:path], [:data], [:callback], [:version]) rv = { :req_id => req_id, :rc => rc } [: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( = {}) assert_open assert_keys(, :supported => [:path, :acl, :version, :callback, :callback_context], :required => [:path, :acl]) [:version] ||= -1 req_id = setup_call(:set_acl, ) rc = super(req_id, [:path], [:acl], [:callback], [: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( = {}) assert_open assert_keys(, :supported => [:path, :callback, :callback_context, :watcher, :watcher_context], :required => [:path]) req_id = setup_call(:stat, ) rc, stat = exists(req_id, [:path], [:callback], [:watcher]) rv = { :req_id => req_id, :rc => rc } [: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
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( = {}) assert_open assert_keys(, :supported => [:path, :callback, :callback_context], :required => [:path, :callback]) req_id = setup_call(:sync, ) rc = super(req_id, [:path]) # we don't pass options[:callback] here as this method is *always* async { :req_id => req_id, :rc => rc } end |