use of org.apache.rya.indexing.pcj.fluo.api.GetPcjMetadata.NotInAccumuloException in project incubator-rya by apache.
the class ListQueriesCommand method execute.
@Override
public void execute(final Connector accumulo, final String ryaTablePrefix, final RyaSailRepository rya, final FluoClient fluo, final String[] args) throws ArgumentsException, ExecutionException {
checkNotNull(accumulo);
checkNotNull(fluo);
checkNotNull(args);
log.trace("Executing the List Queries Command...");
// Parse the command line arguments.
final Parameters params = new Parameters();
try {
new JCommander(params, args);
} catch (final ParameterException e) {
throw new ArgumentsException("Could not list the queries because of invalid command line parameters.", e);
}
// Fetch the PCJ metadata that will be included in the report.
final GetPcjMetadata getPcjMetadata = new GetPcjMetadata();
final Map<String, PcjMetadata> metadata = new HashMap<String, PcjMetadata>();
try {
final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumulo, ryaTablePrefix);
if (params.queryId != null) {
log.trace("Fetch the PCJ Metadata from Accumulo for Query ID '" + params.queryId + "'.");
metadata.put(params.queryId, getPcjMetadata.getMetadata(pcjStorage, fluo, params.queryId));
} else {
log.trace("Fetch the PCJ Metadata from Accumulo for all queries that are being updated by Fluo.");
metadata.putAll(getPcjMetadata.getMetadata(pcjStorage, fluo));
}
} catch (NotInFluoException | NotInAccumuloException e) {
throw new ExecutionException("Could not fetch some of the metadata required to build the report.", e);
}
// Write the metadata to the console.
log.trace("Rendering the queries report...");
if (metadata.isEmpty()) {
System.out.println("No queries are being tracked by Fluo.");
} else {
final PcjMetadataRenderer renderer = new PcjMetadataRenderer();
try {
final String report = renderer.render(metadata);
System.out.println("The number of Queries that are being tracked by Fluo: " + metadata.size());
System.out.println(report);
} catch (final Exception e) {
throw new ExecutionException("Unable to render the query metadata report for output.", e);
}
}
log.trace("Finished executing the List Queries Command.");
}
Aggregations