Java Code Examples for org.apache.hadoop.registry.client.binding.RegistryPathUtils

The following examples show how to use org.apache.hadoop.registry.client.binding.RegistryPathUtils. These examples are extracted from open source projects. 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 Project: hadoop   Source File: CuratorService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 Project: hadoop   Source File: TestRegistryRMOperations.java    License: Apache License 2.0 5 votes vote down vote up
@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 3
Source Project: hadoop   Source File: TestRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@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 4
Source Project: hadoop   Source File: AbstractRegistryTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 5
Source Project: big-c   Source File: CuratorService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 6
Source Project: big-c   Source File: TestRegistryRMOperations.java    License: Apache License 2.0 5 votes vote down vote up
@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 Project: big-c   Source File: TestRegistryOperations.java    License: Apache License 2.0 5 votes vote down vote up
@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 Project: big-c   Source File: AbstractRegistryTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 Project: jstorm   Source File: YarnRegistryViewForProviders.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 10
Source Project: jstorm   Source File: YarnRegistryViewForProviders.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 11
Source Project: jstorm   Source File: YarnRegistryViewForProviders.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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 12
Source Project: hadoop   Source File: TestRegistryRMOperations.java    License: Apache License 2.0 4 votes vote down vote up
@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 Project: hadoop   Source File: TestRegistryRMOperations.java    License: Apache License 2.0 4 votes vote down vote up
@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 Project: big-c   Source File: TestRegistryRMOperations.java    License: Apache License 2.0 4 votes vote down vote up
@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 15
Source Project: big-c   Source File: TestRegistryRMOperations.java    License: Apache License 2.0 4 votes vote down vote up
@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 16
Source Project: hadoop   Source File: CuratorService.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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 Project: big-c   Source File: CuratorService.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}