use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class RegistryUtils method extractServiceRecords.
/**
* Extract all service records under a list of stat operations...this
* skips entries that are too short or simply not matching
* @param operations operation support for fetches
* @param parentpath path of the parent of all the entries
* @param stats Collection of stat results
* @return a possibly empty map of fullpath:record.
* @throws IOException for any IO Operation that wasn't ignored.
*/
public static Map<String, ServiceRecord> extractServiceRecords(RegistryOperations operations, String parentpath, Collection<RegistryPathStatus> stats) throws IOException {
Map<String, ServiceRecord> results = new HashMap<String, ServiceRecord>(stats.size());
for (RegistryPathStatus stat : stats) {
if (stat.size > ServiceRecord.RECORD_TYPE.length()) {
// maybe has data
String path = join(parentpath, stat.path);
try {
ServiceRecord serviceRecord = operations.resolve(path);
results.put(path, serviceRecord);
} catch (EOFException ignored) {
if (LOG.isDebugEnabled()) {
LOG.debug("data too short for {}", path);
}
} catch (InvalidRecordException record) {
if (LOG.isDebugEnabled()) {
LOG.debug("Invalid record at {}", path);
}
} catch (NoRecordException record) {
if (LOG.isDebugEnabled()) {
LOG.debug("No record at {}", path);
}
}
}
}
return results;
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class RegistryOperationsService method resolve.
@Override
public ServiceRecord resolve(String path) throws IOException {
byte[] bytes = zkRead(path);
ServiceRecord record = serviceRecordMarshal.fromBytes(path, bytes, ServiceRecord.RECORD_TYPE);
RegistryTypeUtils.validateServiceRecord(path, record);
return record;
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class AbstractRegistryTest method putExampleServiceEntry.
/**
* Create a service entry with the sample endpoints, and put it
* at the destination
* @param path path
* @param createFlags flags
* @return the record
* @throws IOException on a failure
*/
protected ServiceRecord putExampleServiceEntry(String path, int createFlags, String persistence) throws IOException, URISyntaxException {
ServiceRecord record = buildExampleServiceEntry(persistence);
registry.mknode(RegistryPathUtils.parentOf(path), true);
operations.bind(path, record, createFlags);
return record;
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.
the class RegistryTestHelper method buildExampleServiceEntry.
/**
* Create a service entry with the sample endpoints
* @param persistence persistence policy
* @return the record
* @throws IOException on a failure
*/
public static ServiceRecord buildExampleServiceEntry(String persistence) throws IOException, URISyntaxException {
ServiceRecord record = new ServiceRecord();
record.set(YarnRegistryAttributes.YARN_ID, "example-0001");
record.set(YarnRegistryAttributes.YARN_PERSISTENCE, persistence);
addSampleEndpoints(record, "namenode");
return record;
}
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;
}
Aggregations