/** * Read data on a path * @param path path of operation * @return the data * @throws IOException read failure */ public byte[] zkRead(String path) throws IOException { checkServiceLive(); String fullpath = createFullPath(path); try { if (LOG.isDebugEnabled()) { LOG.debug("Reading {}", fullpath); } return curator.getData().forPath(fullpath); } catch (Exception e) { throw operationFailure(fullpath, "read()", e); } }
/** * Read data on a path. * * @param path path of operation * @return the data * @throws IOException read failure */ public byte[] zkRead(String path) throws IOException { checkServiceLive(); String fullpath = createFullPath(path); try { if (LOG.isDebugEnabled()) { LOG.debug("Reading {}", fullpath); } return curator.getData().forPath(fullpath); } catch (Exception e) { throw operationFailure(fullpath, "read()", e); } }
/** * List all children of a path * @param path path of operation * @return a possibly empty list of children * @throws IOException */ public List<String> zkList(String path) throws IOException { checkServiceLive(); String fullpath = createFullPath(path); try { if (LOG.isDebugEnabled()) { LOG.debug("ls {}", fullpath); } GetChildrenBuilder builder = curator.getChildren(); List<String> children = builder.forPath(fullpath); return children; } catch (Exception e) { throw operationFailure(path, "ls()", e); } }
/** * List all children of a path. * * @param path path of operation * @return a possibly empty list of children * @throws IOException */ public List<String> zkList(String path) throws IOException { checkServiceLive(); String fullpath = createFullPath(path); try { if (LOG.isDebugEnabled()) { LOG.debug("ls {}", fullpath); } GetChildrenBuilder builder = curator.getChildren(); List<String> children = builder.forPath(fullpath); return children; } catch (Exception e) { throw operationFailure(path, "ls()", e); } }
/** * Update the data for a path * @param path path of operation * @param data new data * @throws IOException */ public void zkUpdate(String path, byte[] data) throws IOException { Preconditions.checkArgument(data != null, "null data"); checkServiceLive(); path = createFullPath(path); try { if (LOG.isDebugEnabled()) { LOG.debug("Updating {} with {} bytes", path, data.length); } curator.setData().forPath(path, data); } catch (Exception e) { throw operationFailure(path, "update()", e); } }
/** * Update the data for a path. * * @param path path of operation * @param data new data * @throws IOException */ public void zkUpdate(String path, byte[] data) throws IOException { Preconditions.checkArgument(data != null, "null data"); checkServiceLive(); path = createFullPath(path); try { if (LOG.isDebugEnabled()) { LOG.debug("Updating {} with {} bytes", path, data.length); } curator.setData().forPath(path, data); } catch (Exception e) { throw operationFailure(path, "update()", e); } }
/** * Stat the file. * * @param path path of operation * @return a curator stat entry * @throws IOException on a failure * @throws PathNotFoundException if the path was not found */ public Stat zkStat(String path) throws IOException { checkServiceLive(); String fullpath = createFullPath(path); Stat stat; try { if (LOG.isDebugEnabled()) { LOG.debug("Stat {}", fullpath); } stat = curator.checkExists().forPath(fullpath); } catch (Exception e) { throw operationFailure(fullpath, "read()", e); } if (stat == null) { throw new PathNotFoundException(path); } return stat; }
/** * Stat the file * @param path path of operation * @return a curator stat entry * @throws IOException on a failure * @throws PathNotFoundException if the path was not found */ public Stat zkStat(String path) throws IOException { checkServiceLive(); String fullpath = createFullPath(path); Stat stat; try { if (LOG.isDebugEnabled()) { LOG.debug("Stat {}", fullpath); } stat = curator.checkExists().forPath(fullpath); } catch (Exception e) { throw operationFailure(fullpath, "read()", e); } if (stat == null) { throw new PathNotFoundException(path); } return stat; }
/** * Create a path with given data. byte[0] is used for a path * without data * @param path path of operation * @param data initial data * @param acls * @throws IOException */ public void zkCreate(String path, CreateMode mode, byte[] data, List<ACL> acls) throws IOException { Preconditions.checkArgument(data != null, "null data"); checkServiceLive(); String fullpath = createFullPath(path); try { if (LOG.isDebugEnabled()) { LOG.debug("Creating {} with {} bytes of data and ACL {}", fullpath, data.length, new RegistrySecurity.AclListInfo(acls)); } curator.create().withMode(mode).withACL(acls).forPath(fullpath, data); } catch (Exception e) { throw operationFailure(fullpath, "create()", e, acls); } }
throws IOException { checkServiceLive(); path = createFullPath(path); if (acls == null || acls.isEmpty()) { throw new NoPathPermissionsException(path, "Empty ACL list");
/** * Create a path with given data. byte[0] is used for a path * without data. * * @param path path of operation * @param data initial data * @param acls * @throws IOException */ public void zkCreate(String path, CreateMode mode, byte[] data, List<ACL> acls) throws IOException { Preconditions.checkArgument(data != null, "null data"); checkServiceLive(); String fullpath = createFullPath(path); try { if (LOG.isDebugEnabled()) { LOG.debug("Creating {} with {} bytes of data and ACL {}", fullpath, data.length, new RegistrySecurity.AclListInfo(acls)); } curator.create().withMode(mode).withACL(acls).forPath(fullpath, data); } catch (Exception e) { throw operationFailure(fullpath, "create()", e, acls); } }
/** * Get the ACLs of a path * @param path path of operation * @return a possibly empty list of ACLs * @throws IOException */ public List<ACL> zkGetACLS(String path) throws IOException { checkServiceLive(); String fullpath = createFullPath(path); List<ACL> acls; try { if (LOG.isDebugEnabled()) { LOG.debug("GetACLS {}", fullpath); } acls = curator.getACL().forPath(fullpath); } catch (Exception e) { throw operationFailure(fullpath, "read()", e); } if (acls == null) { throw new PathNotFoundException(path); } return acls; }
BackgroundCallback backgroundCallback) throws IOException { checkServiceLive(); String fullpath = createFullPath(path); try { if (LOG.isDebugEnabled()) {
/** * Get the ACLs of a path. * * @param path path of operation * @return a possibly empty list of ACLs * @throws IOException */ public List<ACL> zkGetACLS(String path) throws IOException { checkServiceLive(); String fullpath = createFullPath(path); List<ACL> acls; try { if (LOG.isDebugEnabled()) { LOG.debug("GetACLS {}", fullpath); } acls = curator.getACL().forPath(fullpath); } catch (Exception e) { throw operationFailure(fullpath, "read()", e); } if (acls == null) { throw new PathNotFoundException(path); } return acls; }
throws IOException { checkServiceLive(); path = createFullPath(path); if (acls == null || acls.isEmpty()) { throw new NoPathPermissionsException(path, "Empty ACL list");
BackgroundCallback backgroundCallback) throws IOException { checkServiceLive(); String fullpath = createFullPath(path); try { if (LOG.isDebugEnabled()) {