Search in sources :

Example 31 with ServiceRecord

use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.

the class TestMarshalling method testRecordValidationWrongType.

@Test(expected = InvalidRecordException.class)
public void testRecordValidationWrongType() throws Throwable {
    ServiceRecord record = new ServiceRecord();
    record.type = "NotAServiceRecordType";
    RegistryTypeUtils.validateServiceRecord("validating", record);
}
Also used : ServiceRecord(org.apache.hadoop.registry.client.types.ServiceRecord) Test(org.junit.Test)

Example 32 with ServiceRecord

use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.

the class TestMarshalling method testRoundTrip.

@Test
public void testRoundTrip() throws Throwable {
    String persistence = PersistencePolicies.PERMANENT;
    ServiceRecord record = createRecord(persistence);
    record.set("customkey", "customvalue");
    record.set("customkey2", "customvalue2");
    RegistryTypeUtils.validateServiceRecord("", record);
    LOG.info(marshal.toJson(record));
    byte[] bytes = marshal.toBytes(record);
    ServiceRecord r2 = marshal.fromBytes("", bytes);
    assertMatches(record, r2);
    RegistryTypeUtils.validateServiceRecord("", r2);
}
Also used : ServiceRecord(org.apache.hadoop.registry.client.types.ServiceRecord) Test(org.junit.Test)

Example 33 with ServiceRecord

use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.

the class TestMarshalling method testFieldPropagationInCopy.

@Test
public void testFieldPropagationInCopy() throws Throwable {
    ServiceRecord record = createRecord(PersistencePolicies.APPLICATION_ATTEMPT);
    record.set("key", "value");
    record.set("intval", "2");
    ServiceRecord that = new ServiceRecord(record);
    assertMatches(record, that);
}
Also used : ServiceRecord(org.apache.hadoop.registry.client.types.ServiceRecord) Test(org.junit.Test)

Example 34 with ServiceRecord

use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.

the class TestRegistryRMOperations method testPutGetContainerPersistenceServiceEntry.

@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);
}
Also used : ServiceRecord(org.apache.hadoop.registry.client.types.ServiceRecord) Test(org.junit.Test) AbstractRegistryTest(org.apache.hadoop.registry.AbstractRegistryTest)

Example 35 with ServiceRecord

use of org.apache.hadoop.registry.client.types.ServiceRecord 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

ServiceRecord (org.apache.hadoop.registry.client.types.ServiceRecord)42 Test (org.junit.Test)21 AbstractRegistryTest (org.apache.hadoop.registry.AbstractRegistryTest)14 IOException (java.io.IOException)10 RegistryPathStatus (org.apache.hadoop.registry.client.types.RegistryPathStatus)6 NoRecordException (org.apache.hadoop.registry.client.exceptions.NoRecordException)5 Endpoint (org.apache.hadoop.registry.client.types.Endpoint)5 HashMap (java.util.HashMap)4 ParseException (org.apache.commons.cli.ParseException)4 PathNotFoundException (org.apache.hadoop.fs.PathNotFoundException)4 RegistryTypeUtils.inetAddrEndpoint (org.apache.hadoop.registry.client.binding.RegistryTypeUtils.inetAddrEndpoint)4 RegistryTypeUtils.restEndpoint (org.apache.hadoop.registry.client.binding.RegistryTypeUtils.restEndpoint)4 InvalidRecordException (org.apache.hadoop.registry.client.exceptions.InvalidRecordException)4 URISyntaxException (java.net.URISyntaxException)3 Map (java.util.Map)3 PathIsNotEmptyDirectoryException (org.apache.hadoop.fs.PathIsNotEmptyDirectoryException)3 ZKPathDumper (org.apache.hadoop.registry.client.impl.zk.ZKPathDumper)3 EOFException (java.io.EOFException)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)2 URI (java.net.URI)2