private int getMaxSequenceNumber(CuratorFramework zkClient) throws Exception { return ByteBuffer.wrap(zkClient.getData() .forPath(BLOBSTORE_MAX_KEY_SEQUENCE_SUBTREE + "/" + key)).getInt(); } }
public Object getData(String path) { path = "/" + path; try { Object data; if (_curator.checkExists().forPath(path) != null) { // Use parseWithException instead of parse so we can capture deserialization errors in the log. // They are likely to be bugs in the spout code. try { data = JSONValue.parseWithException(new String(_curator.getData().forPath(path), "UTF-8")); } catch (ParseException e) { LOG.warn("Failed to deserialize zookeeper data for path {}", path, e); data = null; } } else { data = null; } LOG.debug("Get. [path = {}] => [data = {}]", path, data); return data; } catch (Exception e) { throw new RuntimeException(e); } }
public static byte[] getData(CuratorFramework zk, String path, boolean watch) { try { String npath = normalizePath(path); if (existsNode(zk, npath, watch)) { if (watch) { return zk.getData().watched().forPath(npath); } else { return zk.getData().forPath(npath); } } } catch (Exception e) { if (Utils.exceptionCauseIsInstanceOf(KeeperException.NoNodeException.class, e)) { // this is fine b/c we still have a watch from the successful exists call } else { throw Utils.wrapInRuntime(e); } } return null; }
private int getMaxSequenceNumber(CuratorFramework zkClient) throws Exception { return ByteBuffer.wrap(zkClient.getData() .forPath(BLOBSTORE_MAX_KEY_SEQUENCE_SUBTREE + "/" + key)).getInt(); } }
public Object getData(String path) { path = "/" + path; try { if(_curator.checkExists().forPath(path)!=null) { return _des.deserializeObject(_curator.getData().forPath(path)); } else { return null; } } catch(Exception e) { throw new RuntimeException(e); } }
public Object getData(String path) { path = "/" + path; try { Object data; if(_curator.checkExists().forPath(path) != null) { // Use parseWithException instead of parse so we can capture deserialization errors in the log. // They are likely to be bugs in the spout code. try { data = JSONValue.parseWithException(new String(_curator.getData().forPath(path), "UTF-8")); } catch (ParseException e) { LOG.warn("Failed to deserialize zookeeper data for path {}", path, e); data = null; } } else { data = null; } LOG.debug("Get. [path = {}] => [data = {}]", path, data); return data; } catch(Exception e) { throw new RuntimeException(e); } }
@Override public void process(WatchedEvent we) { try { this.client.checkExists().usingWatcher(this).forPath(this.name); LOG.debug("Renewed watch for path {}", this.name); } catch (Exception ex) { LOG.error("Error renewing watch.", ex); } switch (we.getType()) { case NodeCreated: LOG.debug("Node created."); break; case NodeDataChanged: LOG.debug("Received signal."); try { this.listener.onSignal(this.client.getData().forPath(we.getPath())); } catch (Exception e) { LOG.warn("Unable to process signal.", e); } break; case NodeDeleted: LOG.debug("NodeDeleted"); break; } }
public static byte[] getData(CuratorFramework zk, String path, boolean watch){ try { String npath = normalizePath(path); if (existsNode(zk, npath, watch)) { if (watch) { return zk.getData().watched().forPath(npath); } else { return zk.getData().forPath(npath); } } } catch (Exception e) { if (Utils.exceptionCauseIsInstanceOf(KeeperException.NoNodeException.class, e)) { // this is fine b/c we still have a watch from the successful exists call } else { throw Utils.wrapInRuntime(e); } } return null; }