Module: Zookeeper::ClientMethods
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
- #associating? ⇒ Boolean
-
#close ⇒ Object
close this client and any underyling 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) ⇒ Object
-
#pause_before_fork_in_parent ⇒ Object
stop all underlying threads in preparation for a fork().
- #reopen(timeout = 10, watcher = nil) ⇒ 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
Methods included from Constants
#event_by_value, #state_by_value
Instance Method Details
#associating? ⇒ Boolean
156 157 158 |
# File 'lib/zookeeper/client_methods.rb', line 156 def associating? super end |
#close ⇒ Object
close this client and any underyling connections
140 141 142 |
# File 'lib/zookeeper/client_methods.rb', line 140 def close super end |
#closed? ⇒ Boolean
has the underlying connection been closed?
176 177 178 |
# File 'lib/zookeeper/client_methods.rb', line 176 def closed? super end |
#connected? ⇒ Boolean
148 149 150 |
# File 'lib/zookeeper/client_methods.rb', line 148 def connected? super end |
#connecting? ⇒ Boolean
152 153 154 |
# File 'lib/zookeeper/client_methods.rb', line 152 def connecting? super end |
#create(options = {}) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/zookeeper/client_methods.rb', line 66 def create( = {}) assert_open assert_supported_keys(, [:path, :data, :acl, :ephemeral, :sequence, :callback, :callback_context]) assert_required_keys(, [: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
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/zookeeper/client_methods.rb', line 85 def delete( = {}) assert_open assert_supported_keys(, [:path, :version, :callback, :callback_context]) assert_required_keys(, [: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.
166 167 168 |
# File 'lib/zookeeper/client_methods.rb', line 166 def event_dispatch_thread? super end |
#get(options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/zookeeper/client_methods.rb', line 16 def get( = {}) assert_open assert_supported_keys(, [:path, :watcher, :watcher_context, :callback, :callback_context]) assert_required_keys(, [: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
127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/zookeeper/client_methods.rb', line 127 def get_acl( = {}) assert_open assert_supported_keys(, [:path, :callback, :callback_context]) assert_required_keys(, [: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
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/zookeeper/client_methods.rb', line 42 def get_children( = {}) assert_open assert_supported_keys(, [:path, :callback, :callback_context, :watcher, :watcher_context]) assert_required_keys(, [: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) ⇒ Object
12 13 14 |
# File 'lib/zookeeper/client_methods.rb', line 12 def initialize(host, timeout=10, watcher=nil) super end |
#pause_before_fork_in_parent ⇒ Object
stop all underlying threads in preparation for a fork()
196 197 198 |
# File 'lib/zookeeper/client_methods.rb', line 196 def pause_before_fork_in_parent super end |
#reopen(timeout = 10, watcher = nil) ⇒ Object
7 8 9 10 |
# File 'lib/zookeeper/client_methods.rb', line 7 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()
201 202 203 |
# File 'lib/zookeeper/client_methods.rb', line 201 def resume_after_fork_in_parent super end |
#running? ⇒ Boolean
is the event delivery system running?
181 182 183 |
# File 'lib/zookeeper/client_methods.rb', line 181 def running? super end |
#session_id ⇒ Object
return the session id of the current connection as an Fixnum
186 187 188 |
# File 'lib/zookeeper/client_methods.rb', line 186 def session_id super end |
#session_passwd ⇒ Object
Return the passwd portion of this connection’s credentials as a String
191 192 193 |
# File 'lib/zookeeper/client_methods.rb', line 191 def session_passwd super end |
#set(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/zookeeper/client_methods.rb', line 28 def set( = {}) assert_open assert_supported_keys(, [:path, :data, :version, :callback, :callback_context]) assert_required_keys(, [: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
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/zookeeper/client_methods.rb', line 115 def set_acl( = {}) assert_open assert_supported_keys(, [:path, :acl, :version, :callback, :callback_context]) assert_required_keys(, [: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
171 172 173 |
# File 'lib/zookeeper/client_methods.rb', line 171 def set_debug_level(val) super end |
#stat(options = {}) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/zookeeper/client_methods.rb', line 54 def stat( = {}) assert_open assert_supported_keys(, [:path, :callback, :callback_context, :watcher, :watcher_context]) assert_required_keys(, [: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
144 145 146 |
# File 'lib/zookeeper/client_methods.rb', line 144 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
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/zookeeper/client_methods.rb', line 103 def sync( = {}) assert_open assert_supported_keys(, [:path, :callback, :callback_context]) assert_required_keys(, [: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 |