use of org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException in project incubator-rya by apache.
the class QueryReportCommand method execute.
@Override
public void execute(final Connector accumulo, final String ryaTablePrefix, final RyaSailRepository rya, final FluoClient fluo, final String[] args) throws ArgumentsException, ExecutionException, UnsupportedQueryException {
checkNotNull(accumulo);
checkNotNull(ryaTablePrefix);
checkNotNull(rya);
checkNotNull(fluo);
checkNotNull(args);
log.trace("Executing the Get Query Report 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 create a new query because of invalid command line parameters.", e);
}
// Build the report using what is stored in Fluo.
log.trace("Building the report for Query ID: " + params.queryId);
final QueryReport queryReport = new GetQueryReport().getReport(fluo, params.queryId);
log.trace("Report built.");
// Format and print the report.
try {
final String reportString = new QueryReportRenderer().render(queryReport);
System.out.println(reportString);
} catch (final Exception e) {
throw new ExecutionException("Unable to render the query metadata report for output.", e);
}
log.trace("Finished executing the Get Query Report Command.");
}
use of org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException in project incubator-rya by apache.
the class PcjAdminClient method main.
public static void main(final String[] args) {
log.trace("Starting up the PCJ Admin Client.");
// If no command provided or the command isn't recognized, then print the usage.
if (args.length == 0 || !commands.containsKey(args[0])) {
System.out.println(usage);
System.exit(-1);
}
// Load the properties file.
final Properties props = new Properties();
try (InputStream pin = Files.newInputStream(PROPERTIES_FILE)) {
props.load(pin);
} catch (final IOException e) {
throw new RuntimeException("Could not load properties file: " + PROPERTIES_FILE, e);
}
// Fetch the command that will be executed.
final String command = args[0];
final String[] commandArgs = Arrays.copyOfRange(args, 1, args.length);
final PcjAdminClientCommand pcjCommand = commands.get(command);
RyaSailRepository rya = null;
FluoClient fluo = null;
try {
// Connect to Accumulo, Rya, and Fluo.
final PcjAdminClientProperties clientProps = new PcjAdminClientProperties(props);
final Connector accumulo = createAccumuloConnector(clientProps);
rya = makeRyaRepository(clientProps, accumulo);
fluo = createFluoClient(clientProps);
// Execute the command.
pcjCommand.execute(accumulo, clientProps.getRyaTablePrefix(), rya, fluo, commandArgs);
} catch (final AccumuloException | AccumuloSecurityException e) {
System.err.println("Could not connect to the Accumulo instance that hosts the export PCJ tables.");
e.printStackTrace();
System.exit(-1);
} catch (final RepositoryException e) {
System.err.println("Could not connect to the Rya instance that hosts the historic RDF statements.");
e.printStackTrace();
System.exit(-1);
} catch (final ArgumentsException e) {
System.err.println(pcjCommand.getUsage());
System.exit(-1);
} catch (final ExecutionException e) {
System.err.println("Could not execute the command.");
e.printStackTrace();
System.exit(-1);
} catch (UnsupportedQueryException e) {
System.err.println("Could not execute the command because the query is invalid.");
e.printStackTrace();
} finally {
log.trace("Shutting down the PCJ Admin Client.");
if (rya != null) {
try {
rya.shutDown();
} catch (final RepositoryException e) {
System.err.println("Problem while shutting down the Rya connection.");
e.printStackTrace();
}
}
if (fluo != null) {
fluo.close();
}
}
}
use of org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException in project incubator-rya by apache.
the class AccumuloCreatePeriodicPCJ method createPeriodicPCJ.
@Override
public String createPeriodicPCJ(String instanceName, String sparql, String periodicTopic, String bootStrapServers) throws RyaClientException {
requireNonNull(instanceName);
requireNonNull(sparql);
final Optional<RyaDetails> ryaDetailsHolder = getInstanceDetails.getDetails(instanceName);
final boolean ryaInstanceExists = ryaDetailsHolder.isPresent();
if (!ryaInstanceExists) {
throw new InstanceDoesNotExistException(String.format("The '%s' instance of Rya does not exist.", instanceName));
}
final PCJIndexDetails pcjIndexDetails = ryaDetailsHolder.get().getPCJIndexDetails();
final boolean pcjIndexingEnabeld = pcjIndexDetails.isEnabled();
if (!pcjIndexingEnabeld) {
throw new RyaClientException(String.format("The '%s' instance of Rya does not have PCJ Indexing enabled.", instanceName));
}
// If a Fluo application is being used, task it with updating the PCJ.
final Optional<FluoDetails> fluoDetailsHolder = pcjIndexDetails.getFluoDetails();
if (fluoDetailsHolder.isPresent()) {
final String fluoAppName = fluoDetailsHolder.get().getUpdateAppName();
try {
return updateFluoAppAndRegisterWithKafka(instanceName, fluoAppName, sparql, periodicTopic, bootStrapServers);
} catch (RepositoryException | MalformedQueryException | SailException | QueryEvaluationException | PcjException | RyaDAOException | PeriodicQueryCreationException e) {
throw new RyaClientException("Problem while initializing the Fluo application with the new PCJ.", e);
} catch (UnsupportedQueryException e) {
throw new RyaClientException("The new PCJ could not be initialized because it either contains an unsupported query node " + "or an invalid ExportStrategy for the given QueryType. Projection queries can be exported to either Rya or Kafka," + "unless they contain an aggregation, in which case they can only be exported to Kafka. Construct queries can be exported" + "to Rya and Kafka, and Periodic queries can only be exported to Rya.");
}
} else {
throw new RyaClientException(String.format("The '%s' instance of Rya does not have PCJ Indexing enabled.", instanceName));
}
}
use of org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException in project incubator-rya by apache.
the class AccumuloDeletePeriodicPCJ method deletePeriodicPCJ.
@Override
public void deletePeriodicPCJ(final String instanceName, final String pcjId, String topic, String brokers) throws InstanceDoesNotExistException, RyaClientException {
requireNonNull(instanceName);
requireNonNull(pcjId);
final Optional<RyaDetails> originalDetails = getInstanceDetails.getDetails(instanceName);
final boolean ryaInstanceExists = originalDetails.isPresent();
if (!ryaInstanceExists) {
throw new InstanceDoesNotExistException(String.format("The '%s' instance of Rya does not exist.", instanceName));
}
final boolean pcjIndexingEnabled = originalDetails.get().getPCJIndexDetails().isEnabled();
if (!pcjIndexingEnabled) {
throw new RyaClientException(String.format("The '%s' instance of Rya does not have PCJ Indexing enabled.", instanceName));
}
// If the PCJ was being maintained by a Fluo application, then stop that process.
final PCJIndexDetails pcjIndexDetails = originalDetails.get().getPCJIndexDetails();
final Optional<FluoDetails> fluoDetailsHolder = pcjIndexDetails.getFluoDetails();
if (fluoDetailsHolder.isPresent()) {
final String fluoAppName = pcjIndexDetails.getFluoDetails().get().getUpdateAppName();
try {
stopUpdatingPCJ(instanceName, fluoAppName, pcjId, topic, brokers);
} catch (MalformedQueryException | UnsupportedQueryException | QueryDeletionException e) {
throw new RyaClientException(String.format("Unable to delete Periodic Query with id: %s", pcjId), e);
}
} else {
log.error(String.format("Could not stop the Fluo application from updating the PCJ because the Fluo Details are " + "missing for the Rya instance named '%s'.", instanceName));
}
}
Aggregations