Search in sources :

Example 1 with DeleteCompletionCallback

use of org.apache.hadoop.registry.server.services.DeleteCompletionCallback in project hadoop by apache.

the class TestRegistryRMOperations method testAsyncPurgeEntry.

@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
}
Also used : ZKPathDumper(org.apache.hadoop.registry.client.impl.zk.ZKPathDumper) DeleteCompletionCallback(org.apache.hadoop.registry.server.services.DeleteCompletionCallback) 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) 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 ZKPathDumper (org.apache.hadoop.registry.client.impl.zk.ZKPathDumper)1 ServiceRecord (org.apache.hadoop.registry.client.types.ServiceRecord)1 DeleteCompletionCallback (org.apache.hadoop.registry.server.services.DeleteCompletionCallback)1 Test (org.junit.Test)1