@Override public boolean mknode(String path, boolean createParents) throws IOException { validatePath(path); return zkMkPath(path, CreateMode.PERSISTENT, createParents, getClientAcls()); }
@Override public void delete(String path, boolean recursive) throws IOException { validatePath(path); zkDelete(path, recursive, null); }
@Override public List<String> list(String path) throws IOException { validatePath(path); return zkList(path); }
@Override public void bind(String path, ServiceRecord record, int flags) throws IOException { Preconditions.checkArgument(record != null, "null record"); validatePath(path); // validate the record before putting it RegistryTypeUtils.validateServiceRecord(path, record); if (LOG.isDebugEnabled()) { LOG.debug("Bound at {} : ServiceRecord = {}", path, record); } CreateMode mode = CreateMode.PERSISTENT; byte[] bytes = serviceRecordMarshal.toBytes(record); zkSet(path, mode, bytes, getClientAcls(), ((flags & BindFlags.OVERWRITE) != 0)); }
@Override public boolean exists(String path) throws IOException { validatePath(path); return zkPathExists(path); }
@Override public RegistryPathStatus stat(String path) throws IOException { validatePath(path); Stat stat = zkStat(path); String name = RegistryPathUtils.lastPathEntry(path); RegistryPathStatus status = new RegistryPathStatus( name, stat.getCtime(), stat.getDataLength(), stat.getNumChildren()); if (LOG.isDebugEnabled()) { LOG.debug("Stat {} => {}", path, status); } return status; }
/** * Get the aggregate set of ACLs the client should use * to create directories * @return the ACL list */ public List<ACL> getClientAcls() { return getRegistrySecurity().getClientACLs(); }
/** * Stop the service: halt the executor. * @throws Exception exception. */ @Override protected void serviceStop() throws Exception { stopExecutor(); super.serviceStop(); }
/** * Init operation sets up the system ACLs. * @param conf configuration of the service * @throws Exception */ @Override protected void serviceInit(Configuration conf) throws Exception { super.serviceInit(conf); RegistrySecurity registrySecurity = getRegistrySecurity(); if (registrySecurity.isSecureRegistry()) { ACL sasl = registrySecurity.createSaslACLFromCurrentUser(ZooDefs.Perms.ALL); registrySecurity.addSystemACL(sasl); LOG.info("Registry System ACLs:", RegistrySecurity.aclsToString( registrySecurity.getSystemACLs())); } }
/** * Start the service, including creating base directories with permissions * @throws Exception */ @Override protected void serviceStart() throws Exception { super.serviceStart(); // create the root directories try { createRootRegistryPaths(); } catch (NoPathPermissionsException e) { String message = String.format(Locale.ENGLISH, "Failed to create root paths {%s};" + "%ndiagnostics={%s}" + "%ncurrent registry is:" + "%n{%s}", e, bindingDiagnosticDetails(), dumpRegistryRobustly(true)); LOG.error(" Failure {}", e, e); LOG.error(message); // TODO: this is something temporary to deal with the problem // that jenkins is failing this test throw new NoPathPermissionsException(e.getPath().toString(), message, e); } }
@Override public void bind(String path, ServiceRecord record, int flags) throws IOException { Preconditions.checkArgument(record != null, "null record"); validatePath(path); // validate the record before putting it RegistryTypeUtils.validateServiceRecord(path, record); LOG.info("Bound at {} : {}", path, record); CreateMode mode = CreateMode.PERSISTENT; byte[] bytes = serviceRecordMarshal.toBytes(record); zkSet(path, mode, bytes, getClientAcls(), ((flags & BindFlags.OVERWRITE) != 0)); }
@Override public boolean exists(String path) throws IOException { validatePath(path); return zkPathExists(path); }
@Override public RegistryPathStatus stat(String path) throws IOException { validatePath(path); Stat stat = zkStat(path); String name = RegistryPathUtils.lastPathEntry(path); RegistryPathStatus status = new RegistryPathStatus( name, stat.getCtime(), stat.getDataLength(), stat.getNumChildren()); if (LOG.isDebugEnabled()) { LOG.debug("Stat {} => {}", path, status); } return status; }
/** * Get the aggregate set of ACLs the client should use * to create directories * @return the ACL list */ public List<ACL> getClientAcls() { return getRegistrySecurity().getClientACLs(); }
/** * Stop the service: halt the executor. * @throws Exception exception. */ @Override protected void serviceStop() throws Exception { stopExecutor(); super.serviceStop(); }
/** * Init operation sets up the system ACLs. * @param conf configuration of the service * @throws Exception */ @Override protected void serviceInit(Configuration conf) throws Exception { super.serviceInit(conf); RegistrySecurity registrySecurity = getRegistrySecurity(); if (registrySecurity.isSecureRegistry()) { ACL sasl = registrySecurity.createSaslACLFromCurrentUser(ZooDefs.Perms.ALL); registrySecurity.addSystemACL(sasl); LOG.info("Registry System ACLs:", RegistrySecurity.aclsToString( registrySecurity.getSystemACLs())); } }
/** * Start the service, including creating base directories with permissions * @throws Exception */ @Override protected void serviceStart() throws Exception { super.serviceStart(); // create the root directories try { createRootRegistryPaths(); } catch (NoPathPermissionsException e) { String message = String.format(Locale.ENGLISH, "Failed to create root paths {%s};" + "%ndiagnostics={%s}" + "%ncurrent registry is:" + "%n{%s}", e, bindingDiagnosticDetails(), dumpRegistryRobustly(true)); LOG.error(" Failure {}", e, e); LOG.error(message); // TODO: this is something temporary to deal with the problem // that jenkins is failing this test throw new NoPathPermissionsException(e.getPath().toString(), message, e); } }
@Override public boolean mknode(String path, boolean createParents) throws IOException { validatePath(path); return zkMkPath(path, CreateMode.PERSISTENT, createParents, getClientAcls()); }
@Override public List<String> list(String path) throws IOException { validatePath(path); return zkList(path); }
@Override public void delete(String path, boolean recursive) throws IOException { validatePath(path); zkDelete(path, recursive, null); }