Class: Zookeeper::JavaBase

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_skynet/zookeeper/extensions/java_base.rb

Instance Method Summary collapse

Instance Method Details

#get(req_id, path, callback, watcher) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ruby_skynet/zookeeper/extensions/java_base.rb', line 9

def get(req_id, path, callback, watcher)
  handle_keeper_exception do
    watch_cb = watcher ? create_watcher(req_id, path) : false

    if callback
      jzk.getData(path, watch_cb, JavaCB::DataCallback.new(req_id), event_queue)
      [Code::Ok, nil, nil]    # the 'nil, nil' isn't strictly necessary here
    else # sync
      stat = JZKD::Stat.new
      value = jzk.getData(path, watch_cb, stat)
      data = String.from_java_bytes(value) unless value.nil?

      [Code::Ok, data, stat.to_hash]
    end
  end
end