Search in sources :

Example 1 with CuratorEventCatcher

use of org.apache.hadoop.registry.client.impl.CuratorEventCatcher in project hadoop by apache.

the class TestRegistryRMOperations method testPurgeEntryCuratorCallback.

@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());
}
Also used : ZKPathDumper(org.apache.hadoop.registry.client.impl.zk.ZKPathDumper) RegistryTypeUtils.restEndpoint(org.apache.hadoop.registry.client.binding.RegistryTypeUtils.restEndpoint) RegistryTypeUtils.inetAddrEndpoint(org.apache.hadoop.registry.client.binding.RegistryTypeUtils.inetAddrEndpoint) ServiceRecord(org.apache.hadoop.registry.client.types.ServiceRecord) CuratorEventCatcher(org.apache.hadoop.registry.client.impl.CuratorEventCatcher) Test(org.junit.Test) AbstractRegistryTest(org.apache.hadoop.registry.AbstractRegistryTest)

Aggregations

AbstractRegistryTest (org.apache.hadoop.registry.AbstractRegistryTest)1 RegistryTypeUtils.inetAddrEndpoint (org.apache.hadoop.registry.client.binding.RegistryTypeUtils.inetAddrEndpoint)1 RegistryTypeUtils.restEndpoint (org.apache.hadoop.registry.client.binding.RegistryTypeUtils.restEndpoint)1 CuratorEventCatcher (org.apache.hadoop.registry.client.impl.CuratorEventCatcher)1 ZKPathDumper (org.apache.hadoop.registry.client.impl.zk.ZKPathDumper)1 ServiceRecord (org.apache.hadoop.registry.client.types.ServiceRecord)1 Test (org.junit.Test)1