use of org.apache.rya.export.api.metadata.ParentMetadataDoesNotExistException in project incubator-rya by apache.
the class AccumuloParentMetadataRepository method getMetadataFromTable.
private MergeParentMetadata getMetadataFromTable() throws ParentMetadataDoesNotExistException {
try {
// Create an Accumulo scanner that iterates through the metadata entries.
final Scanner scanner = connector.createScanner(mergeParentMetadataTableName, new Authorizations());
final Iterator<Entry<Key, Value>> entries = scanner.iterator();
// No metadata has been stored in the table yet.
if (!entries.hasNext()) {
throw new ParentMetadataDoesNotExistException("Could not find any MergeParentMetadata metadata in the table named: " + mergeParentMetadataTableName);
}
// Fetch the metadata from the entries.
String ryaInstanceName = null;
Date timestamp = null;
Date filterTimestamp = null;
Long parentTimeOffset = null;
while (entries.hasNext()) {
final Entry<Key, Value> entry = entries.next();
final Text columnQualifier = entry.getKey().getColumnQualifier();
final byte[] value = entry.getValue().get();
if (columnQualifier.equals(MERGE_PARENT_METADATA_RYA_INSTANCE_NAME)) {
ryaInstanceName = STRING_LEXICODER.decode(value);
} else if (columnQualifier.equals(MERGE_PARENT_METADATA_TIMESTAMP)) {
timestamp = DATE_LEXICODER.decode(value);
} else if (columnQualifier.equals(MERGE_PARENT_METADATA_FILTER_TIMESTAMP)) {
filterTimestamp = DATE_LEXICODER.decode(value);
} else if (columnQualifier.equals(MERGE_PARENT_METADATA_PARENT_TIME_OFFSET)) {
parentTimeOffset = LONG_LEXICODER.decode(value);
}
}
return new MergeParentMetadata(ryaInstanceName, timestamp, filterTimestamp, parentTimeOffset);
} catch (final TableNotFoundException e) {
throw new ParentMetadataDoesNotExistException("Could not add results to a MergeParentMetadata because the MergeParentMetadata table does not exist.", e);
} catch (final Exception e) {
throw new ParentMetadataDoesNotExistException("Error occurred while getting merge parent metadata.", e);
}
}
Aggregations