org.apache.hadoop.registry.client.binding.RegistryPathUtils Java Examples
The following examples show how to use
org.apache.hadoop.registry.client.binding.RegistryPathUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CuratorService.java From big-c with Apache License 2.0 | 5 votes |
/** * 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); }
Example #2
Source File: YarnRegistryViewForProviders.java From jstorm with Apache License 2.0 | 5 votes |
/** * 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; }
Example #3
Source File: YarnRegistryViewForProviders.java From jstorm with Apache License 2.0 | 5 votes |
/** * 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); }
Example #4
Source File: YarnRegistryViewForProviders.java From jstorm with Apache License 2.0 | 5 votes |
/** * Get the absolute path to where the service has registered itself. * This includes the base registry path * Null until the service is registered * @return the service registration path. */ public String getAbsoluteSelfRegistrationPath() { if (selfRegistrationPath == null) { return null; } String root = registryOperations.getConfig().getTrimmed( RegistryConstants.KEY_REGISTRY_ZK_ROOT, RegistryConstants.DEFAULT_ZK_REGISTRY_ROOT); return RegistryPathUtils.join(root, selfRegistrationPath); }
Example #5
Source File: AbstractRegistryTest.java From big-c with Apache License 2.0 | 5 votes |
/** * 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; }
Example #6
Source File: TestRegistryOperations.java From big-c with Apache License 2.0 | 5 votes |
@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); }
Example #7
Source File: TestRegistryRMOperations.java From big-c with Apache License 2.0 | 5 votes |
@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); }
Example #8
Source File: AbstractRegistryTest.java From hadoop with Apache License 2.0 | 5 votes |
/** * 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; }
Example #9
Source File: TestRegistryOperations.java From hadoop with Apache License 2.0 | 5 votes |
@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); }
Example #10
Source File: TestRegistryRMOperations.java From hadoop with Apache License 2.0 | 5 votes |
@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); }
Example #11
Source File: CuratorService.java From hadoop with Apache License 2.0 | 5 votes |
/** * 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); }
Example #12
Source File: TestRegistryRMOperations.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testPurgeEntryCuratorCallback() throws Throwable { String path = "/users/example/hbase/hbase1/"; ServiceRecord written = buildExampleServiceEntry( PersistencePolicies.APPLICATION_ATTEMPT); written.set(YarnRegistryAttributes.YARN_ID, "testAsyncPurgeEntry_attempt_001"); operations.mknode(RegistryPathUtils.parentOf(path), true); operations.bind(path, written, 0); ZKPathDumper dump = registry.dumpPath(false); CuratorEventCatcher events = new CuratorEventCatcher(); LOG.info("Initial state {}", dump); // container query String id = written.get(YarnRegistryAttributes.YARN_ID, ""); int opcount = purge("/", id, PersistencePolicies.CONTAINER, RegistryAdminService.PurgePolicy.PurgeAll, events); assertPathExists(path); assertEquals(0, opcount); assertEquals("Event counter", 0, events.getCount()); // now the application attempt opcount = purge("/", id, PersistencePolicies.APPLICATION_ATTEMPT, RegistryAdminService.PurgePolicy.PurgeAll, events); LOG.info("Final state {}", dump); assertPathNotFound(path); assertEquals("wrong no of delete operations in " + dump, 1, opcount); // and validate the callback event assertEquals("Event counter", 1, events.getCount()); }
Example #13
Source File: TestRegistryRMOperations.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testAsyncPurgeEntry() throws Throwable { String path = "/users/example/hbase/hbase1/"; ServiceRecord written = buildExampleServiceEntry( PersistencePolicies.APPLICATION_ATTEMPT); written.set(YarnRegistryAttributes.YARN_ID, "testAsyncPurgeEntry_attempt_001"); operations.mknode(RegistryPathUtils.parentOf(path), true); operations.bind(path, written, 0); ZKPathDumper dump = registry.dumpPath(false); LOG.info("Initial state {}", dump); DeleteCompletionCallback deletions = new DeleteCompletionCallback(); int opcount = purge("/", written.get(YarnRegistryAttributes.YARN_ID, ""), PersistencePolicies.CONTAINER, RegistryAdminService.PurgePolicy.PurgeAll, deletions); assertPathExists(path); dump = registry.dumpPath(false); assertEquals("wrong no of delete operations in " + dump, 0, deletions.getEventCount()); assertEquals("wrong no of delete operations in " + dump, 0, opcount); // now app attempt deletions = new DeleteCompletionCallback(); opcount = purge("/", written.get(YarnRegistryAttributes.YARN_ID, ""), PersistencePolicies.APPLICATION_ATTEMPT, RegistryAdminService.PurgePolicy.PurgeAll, deletions); dump = registry.dumpPath(false); LOG.info("Final state {}", dump); assertPathNotFound(path); assertEquals("wrong no of delete operations in " + dump, 1, deletions.getEventCount()); assertEquals("wrong no of delete operations in " + dump, 1, opcount); // and validate the callback event }
Example #14
Source File: TestRegistryRMOperations.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testAsyncPurgeEntry() throws Throwable { String path = "/users/example/hbase/hbase1/"; ServiceRecord written = buildExampleServiceEntry( PersistencePolicies.APPLICATION_ATTEMPT); written.set(YarnRegistryAttributes.YARN_ID, "testAsyncPurgeEntry_attempt_001"); operations.mknode(RegistryPathUtils.parentOf(path), true); operations.bind(path, written, 0); ZKPathDumper dump = registry.dumpPath(false); LOG.info("Initial state {}", dump); DeleteCompletionCallback deletions = new DeleteCompletionCallback(); int opcount = purge("/", written.get(YarnRegistryAttributes.YARN_ID, ""), PersistencePolicies.CONTAINER, RegistryAdminService.PurgePolicy.PurgeAll, deletions); assertPathExists(path); dump = registry.dumpPath(false); assertEquals("wrong no of delete operations in " + dump, 0, deletions.getEventCount()); assertEquals("wrong no of delete operations in " + dump, 0, opcount); // now app attempt deletions = new DeleteCompletionCallback(); opcount = purge("/", written.get(YarnRegistryAttributes.YARN_ID, ""), PersistencePolicies.APPLICATION_ATTEMPT, RegistryAdminService.PurgePolicy.PurgeAll, deletions); dump = registry.dumpPath(false); LOG.info("Final state {}", dump); assertPathNotFound(path); assertEquals("wrong no of delete operations in " + dump, 1, deletions.getEventCount()); assertEquals("wrong no of delete operations in " + dump, 1, opcount); // and validate the callback event }
Example #15
Source File: TestRegistryRMOperations.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testPurgeEntryCuratorCallback() throws Throwable { String path = "/users/example/hbase/hbase1/"; ServiceRecord written = buildExampleServiceEntry( PersistencePolicies.APPLICATION_ATTEMPT); written.set(YarnRegistryAttributes.YARN_ID, "testAsyncPurgeEntry_attempt_001"); operations.mknode(RegistryPathUtils.parentOf(path), true); operations.bind(path, written, 0); ZKPathDumper dump = registry.dumpPath(false); CuratorEventCatcher events = new CuratorEventCatcher(); LOG.info("Initial state {}", dump); // container query String id = written.get(YarnRegistryAttributes.YARN_ID, ""); int opcount = purge("/", id, PersistencePolicies.CONTAINER, RegistryAdminService.PurgePolicy.PurgeAll, events); assertPathExists(path); assertEquals(0, opcount); assertEquals("Event counter", 0, events.getCount()); // now the application attempt opcount = purge("/", id, PersistencePolicies.APPLICATION_ATTEMPT, RegistryAdminService.PurgePolicy.PurgeAll, events); LOG.info("Final state {}", dump); assertPathNotFound(path); assertEquals("wrong no of delete operations in " + dump, 1, opcount); // and validate the callback event assertEquals("Event counter", 1, events.getCount()); }
Example #16
Source File: CuratorService.java From big-c with Apache License 2.0 | 2 votes |
/** * Create a full path from the registry root and the supplied subdir * @param path path of operation * @return an absolute path * @throws IllegalArgumentException if the path is invalide */ protected String createFullPath(String path) throws IOException { return RegistryPathUtils.createFullPath(registryRoot, path); }
Example #17
Source File: CuratorService.java From hadoop with Apache License 2.0 | 2 votes |
/** * Create a full path from the registry root and the supplied subdir * @param path path of operation * @return an absolute path * @throws IllegalArgumentException if the path is invalide */ protected String createFullPath(String path) throws IOException { return RegistryPathUtils.createFullPath(registryRoot, path); }