/** * Add a component * @param serviceClass service class to use under ~user * @param componentName component name * @param record record to put * @throws IOException */ public void putComponent(String serviceClass, String serviceName, String componentName, ServiceRecord record) throws IOException { String path = RegistryUtils.componentPath( user, serviceClass, serviceName, componentName); registryOperations.mknode(RegistryPathUtils.parentOf(path), true); registryOperations.bind(path, record, BindFlags.OVERWRITE); }
/** * Add a service under a path, optionally purging any history * @param username user * @param serviceClass service class to use under ~user * @param serviceName name of the service * @param record service record * @param deleteTreeFirst perform recursive delete of the path first. * @return the path the service was created at * @throws IOException */ public String putService(String username, String serviceClass, String serviceName, ServiceRecord record, boolean deleteTreeFirst) throws IOException { String path = RegistryUtils.servicePath( username, serviceClass, serviceName); if (deleteTreeFirst) { registryOperations.delete(path, true); } registryOperations.mknode(RegistryPathUtils.parentOf(path), true); registryOperations.bind(path, record, BindFlags.OVERWRITE); return path; }
private String getAdjustedParentPath(String path) { Preconditions.checkNotNull(path); String adjustedPath = null; adjustedPath = getPathRelativeToRegistryRoot(path); try { return RegistryPathUtils.parentOf(adjustedPath); } catch (PathNotFoundException e) { // attempt to use passed in path return path; } }
/** * Recursively make a path * @param path path to create * @param acl ACL for path * @throws IOException any problem */ public void zkMkParentPath(String path, List<ACL> acl) throws IOException { // split path into elements zkMkPath(RegistryPathUtils.parentOf(path), CreateMode.PERSISTENT, true, acl); }
/** * Recursively make a path. * * @param path path to create * @param acl ACL for path * @throws IOException any problem */ public void zkMkParentPath(String path, List<ACL> acl) throws IOException { // split path into elements zkMkPath(RegistryPathUtils.parentOf(path), CreateMode.PERSISTENT, true, acl); }
/** * Returns the DNS name constructed from the container role/component name. * * @return the DNS naem. * @throws PathNotFoundException * @throws TextParseException */ protected Name getContainerName() throws PathNotFoundException, TextParseException { String service = RegistryPathUtils.lastPathEntry( RegistryPathUtils.parentOf(RegistryPathUtils.parentOf(getPath()))); String description = getRecord().description.toLowerCase(); String user = RegistryPathUtils.getUsername(getPath()); return Name.fromString(MessageFormat.format("{0}.{1}.{2}.{3}", description, service, user, domain)); }
@Test(expected = PathNotFoundException.class) public void testParentOfRoot() throws Throwable { parentOf("/"); }
@Test(expected = PathNotFoundException.class) public void testParentOfRoot() throws Throwable { parentOf("/"); }
/** * Return the DNS name constructed from the component name. * * @return the DNS naem. * @throws PathNotFoundException * @throws TextParseException */ protected Name getComponentName() throws PathNotFoundException, TextParseException { String service = RegistryPathUtils.lastPathEntry( RegistryPathUtils.parentOf(RegistryPathUtils.parentOf(getPath()))); String component = getRecord().get("yarn:component").toLowerCase(); String user = RegistryPathUtils.getUsername(getPath()); return Name.fromString(MessageFormat.format("{0}.{1}.{2}.{3}", component, service, user, domain)); }
/** * Add a component * @param serviceClass service class to use under ~user * @param componentName component name * @param record record to put * @throws IOException */ public void putComponent(String serviceClass, String serviceName, String componentName, ServiceRecord record) throws IOException { String path = RegistryUtils.componentPath( user, serviceClass, serviceName, componentName); registryOperations.mknode(RegistryPathUtils.parentOf(path), true); registryOperations.bind(path, record, BindFlags.OVERWRITE); }
/** * Add a component * @param serviceClass service class to use under ~user * @param componentName component name * @param record record to put * @throws IOException */ public void putComponent(String serviceClass, String serviceName, String componentName, ServiceRecord record) throws IOException { String path = RegistryUtils.componentPath( user, serviceClass, serviceName, componentName); registryOperations.mknode(RegistryPathUtils.parentOf(path), true); registryOperations.bind(path, record, BindFlags.OVERWRITE); }
/** * Add a service under a path, optionally purging any history * @param username user * @param serviceClass service class to use under ~user * @param serviceName name of the service * @param record service record * @param deleteTreeFirst perform recursive delete of the path first. * @return the path the service was created at * @throws IOException */ public String putService(String username, String serviceClass, String serviceName, ServiceRecord record, boolean deleteTreeFirst) throws IOException { String path = RegistryUtils.servicePath( username, serviceClass, serviceName); if (deleteTreeFirst) { registryOperations.delete(path, true); } registryOperations.mknode(RegistryPathUtils.parentOf(path), true); registryOperations.bind(path, record, BindFlags.OVERWRITE); return path; }
/** * Add a service under a path, optionally purging any history * @param username user * @param serviceClass service class to use under ~user * @param serviceName name of the service * @param record service record * @param deleteTreeFirst perform recursive delete of the path first. * @return the path the service was created at * @throws IOException */ public String putService(String username, String serviceClass, String serviceName, ServiceRecord record, boolean deleteTreeFirst) throws IOException { String path = RegistryUtils.servicePath( username, serviceClass, serviceName); if (deleteTreeFirst) { registryOperations.delete(path, true); } registryOperations.mknode(RegistryPathUtils.parentOf(path), true); registryOperations.bind(path, record, BindFlags.OVERWRITE); return path; }
/** * Create a service entry with the sample endpoints, and put it * at the destination * @param path path * @param createFlags flags * @return the record * @throws IOException on a failure */ protected ServiceRecord putExampleServiceEntry(String path, int createFlags, String persistence) throws IOException, URISyntaxException { ServiceRecord record = buildExampleServiceEntry(persistence); registry.mknode(RegistryPathUtils.parentOf(path), true); operations.bind(path, record, createFlags); return record; }
/** * Create a service entry with the sample endpoints, and put it * at the destination * @param path path * @param createFlags flags * @return the record * @throws IOException on a failure */ protected ServiceRecord putExampleServiceEntry(String path, int createFlags, String persistence) throws IOException, URISyntaxException { ServiceRecord record = buildExampleServiceEntry(persistence); registry.mknode(RegistryPathUtils.parentOf(path), true); operations.bind(path, record, createFlags); return record; }
@Test public void testPutGetContainerPersistenceServiceEntry() throws Throwable { String path = ENTRY_PATH; ServiceRecord written = buildExampleServiceEntry( PersistencePolicies.CONTAINER); operations.mknode(RegistryPathUtils.parentOf(path), true); operations.bind(path, written, BindFlags.CREATE); ServiceRecord resolved = operations.resolve(path); validateEntry(resolved); assertMatches(written, resolved); }
@Test public void testPutGetContainerPersistenceServiceEntry() throws Throwable { String path = ENTRY_PATH; ServiceRecord written = buildExampleServiceEntry( PersistencePolicies.CONTAINER); operations.mknode(RegistryPathUtils.parentOf(path), true); operations.bind(path, written, BindFlags.CREATE); ServiceRecord resolved = operations.resolve(path); validateEntry(resolved); assertMatches(written, resolved); }
@Test public void testPutGetContainerPersistenceServiceEntry() throws Throwable { String path = ENTRY_PATH; ServiceRecord written = buildExampleServiceEntry( PersistencePolicies.CONTAINER); operations.mknode(RegistryPathUtils.parentOf(path), true); operations.bind(path, written, BindFlags.CREATE); ServiceRecord resolved = operations.resolve(path); validateEntry(resolved); assertMatches(written, resolved); }