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);
}
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);
}
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);
}
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);
}
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
}
Aggregations