use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class TestRegistryOperations method testResolvePathThatHasNoEntry.
@Test
public void testResolvePathThatHasNoEntry() throws Throwable {
String empty = "/empty2";
operations.mknode(empty, false);
try {
ServiceRecord record = operations.resolve(empty);
fail("expected an exception, got " + record);
} catch (NoRecordException expected) {
// expected
}
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class TestRegistryOperations 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 TestRegistryOperations method testListListFully.
@Test
public void testListListFully() throws Throwable {
ServiceRecord r1 = new ServiceRecord();
ServiceRecord r2 = createRecord("i", PersistencePolicies.PERMANENT, "r2");
String path = USERPATH + SC_HADOOP + "/listing";
operations.mknode(path, true);
String r1path = path + "/r1";
operations.bind(r1path, r1, 0);
String r2path = path + "/r2";
operations.bind(r2path, r2, 0);
RegistryPathStatus r1stat = operations.stat(r1path);
assertEquals("r1", r1stat.path);
RegistryPathStatus r2stat = operations.stat(r2path);
assertEquals("r2", r2stat.path);
assertNotEquals(r1stat, r2stat);
// listings now
List<String> list = operations.list(path);
assertEquals("Wrong no. of children", 2, list.size());
// there's no order here, so create one
Map<String, String> names = new HashMap<String, String>();
String entries = "";
for (String child : list) {
names.put(child, child);
entries += child + " ";
}
assertTrue("No 'r1' in " + entries, names.containsKey("r1"));
assertTrue("No 'r2' in " + entries, names.containsKey("r2"));
Map<String, RegistryPathStatus> stats = RegistryUtils.statChildren(operations, path);
assertEquals("Wrong no. of children", 2, stats.size());
assertEquals(r1stat, stats.get("r1"));
assertEquals(r2stat, stats.get("r2"));
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class TestRegistryOperations method testPutNoParent.
@Test
public void testPutNoParent() throws Throwable {
ServiceRecord record = new ServiceRecord();
record.set(YarnRegistryAttributes.YARN_ID, "testPutNoParent");
String path = "/path/without/parent";
try {
operations.bind(path, record, 0);
// didn't get a failure
// trouble
RegistryPathStatus stat = operations.stat(path);
fail("Got a status " + stat);
} catch (PathNotFoundException expected) {
// expected
}
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class TestRegistryOperations method testPutMinimalRecord.
@Test
public void testPutMinimalRecord() throws Throwable {
String path = "/path/with/minimal";
operations.mknode(path, true);
ServiceRecord record = new ServiceRecord();
operations.bind(path, record, BindFlags.OVERWRITE);
ServiceRecord resolve = operations.resolve(path);
assertMatches(record, resolve);
}
Aggregations