use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class RegistryTestHelper method createRecord.
public static ServiceRecord createRecord(String id, String persistence, String description) {
ServiceRecord serviceRecord = new ServiceRecord();
serviceRecord.set(YarnRegistryAttributes.YARN_ID, id);
serviceRecord.description = description;
serviceRecord.set(YarnRegistryAttributes.YARN_PERSISTENCE, persistence);
return serviceRecord;
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class TestMarshalling method testUnmarshallWrongType.
@Test(expected = InvalidRecordException.class)
public void testUnmarshallWrongType() throws Throwable {
byte[] bytes = "{'type':''}".getBytes();
ServiceRecord serviceRecord = marshal.fromBytes("marshalling", bytes);
RegistryTypeUtils.validateServiceRecord("validating", serviceRecord);
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class RegistryCli method resolve.
@SuppressWarnings("unchecked")
public int resolve(String[] args) {
Options resolveOption = new Options();
CommandLineParser parser = new GnuParser();
try {
CommandLine line = parser.parse(resolveOption, args);
List<String> argsList = line.getArgList();
if (argsList.size() != 2) {
return usageError("resolve requires exactly one path argument", RESOLVE_USAGE);
}
if (!validatePath(argsList.get(1))) {
return -1;
}
try {
ServiceRecord record = registry.resolve(argsList.get(1));
for (Endpoint endpoint : record.external) {
sysout.println(" Endpoint(ProtocolType=" + endpoint.protocolType + ", Api=" + endpoint.api + ");" + " Addresses(AddressType=" + endpoint.addressType + ") are: ");
for (Map<String, String> address : endpoint.addresses) {
sysout.println("[ ");
for (Map.Entry<String, String> entry : address.entrySet()) {
sysout.print("\t" + entry.getKey() + ":" + entry.getValue());
}
sysout.println("\n]");
}
sysout.println();
}
return 0;
} catch (Exception e) {
syserr.println(analyzeException("resolve", e, argsList));
}
return -1;
} catch (ParseException exp) {
return usageError("Invalid syntax " + exp, RESOLVE_USAGE);
}
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class TestRegistryOperations method testOverwrite.
@Test
public void testOverwrite() throws Throwable {
ServiceRecord written = putExampleServiceEntry(ENTRY_PATH, 0);
ServiceRecord resolved1 = operations.resolve(ENTRY_PATH);
resolved1.description = "resolved1";
try {
operations.bind(ENTRY_PATH, resolved1, 0);
fail("overwrite succeeded when it should have failed");
} catch (FileAlreadyExistsException expected) {
// expected
}
// verify there's no changed
ServiceRecord resolved2 = operations.resolve(ENTRY_PATH);
assertMatches(written, resolved2);
operations.bind(ENTRY_PATH, resolved1, BindFlags.OVERWRITE);
ServiceRecord resolved3 = operations.resolve(ENTRY_PATH);
assertMatches(resolved1, resolved3);
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class TestRegistryOperations method testLsParent.
@Test
public void testLsParent() throws Throwable {
ServiceRecord written = putExampleServiceEntry(ENTRY_PATH, 0);
RegistryPathStatus stat = operations.stat(ENTRY_PATH);
List<String> children = operations.list(PARENT_PATH);
assertEquals(1, children.size());
assertEquals(NAME, children.get(0));
Map<String, RegistryPathStatus> childStats = RegistryUtils.statChildren(operations, PARENT_PATH);
assertEquals(1, childStats.size());
assertEquals(stat, childStats.get(NAME));
Map<String, ServiceRecord> records = RegistryUtils.extractServiceRecords(operations, PARENT_PATH, childStats.values());
assertEquals(1, records.size());
ServiceRecord record = records.get(ENTRY_PATH);
RegistryTypeUtils.validateServiceRecord(ENTRY_PATH, record);
assertMatches(written, record);
}
Aggregations