Search in sources :

Example 6 with UnsupportedQueryException

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.");
}
Also used : JCommander(com.beust.jcommander.JCommander) ParameterException(com.beust.jcommander.ParameterException) GetQueryReport(org.apache.rya.indexing.pcj.fluo.api.GetQueryReport) QueryReport(org.apache.rya.indexing.pcj.fluo.api.GetQueryReport.QueryReport) QueryReportRenderer(org.apache.rya.indexing.pcj.fluo.client.util.QueryReportRenderer) UnsupportedQueryException(org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException) ParameterException(com.beust.jcommander.ParameterException) GetQueryReport(org.apache.rya.indexing.pcj.fluo.api.GetQueryReport)

Example 7 with UnsupportedQueryException

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();
        }
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) FluoClient(org.apache.fluo.api.client.FluoClient) ArgumentsException(org.apache.rya.indexing.pcj.fluo.client.PcjAdminClientCommand.ArgumentsException) InputStream(java.io.InputStream) UnsupportedQueryException(org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) RepositoryException(org.openrdf.repository.RepositoryException) IOException(java.io.IOException) Properties(java.util.Properties) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ExecutionException(org.apache.rya.indexing.pcj.fluo.client.PcjAdminClientCommand.ExecutionException)

Example 8 with UnsupportedQueryException

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));
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) PcjException(org.apache.rya.indexing.pcj.storage.PcjException) UnsupportedQueryException(org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException) RyaDetails(org.apache.rya.api.instance.RyaDetails) RepositoryException(org.openrdf.repository.RepositoryException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) SailException(org.openrdf.sail.SailException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) MalformedQueryException(org.openrdf.query.MalformedQueryException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) PeriodicQueryCreationException(org.apache.rya.indexing.pcj.fluo.api.CreatePeriodicQuery.PeriodicQueryCreationException) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) PCJIndexDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)

Example 9 with UnsupportedQueryException

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));
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) UnsupportedQueryException(org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException) RyaDetails(org.apache.rya.api.instance.RyaDetails) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) QueryDeletionException(org.apache.rya.indexing.pcj.fluo.api.DeletePeriodicQuery.QueryDeletionException) MalformedQueryException(org.openrdf.query.MalformedQueryException) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) PCJIndexDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)

Aggregations

UnsupportedQueryException (org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException)9 MalformedQueryException (org.openrdf.query.MalformedQueryException)6 RepositoryException (org.openrdf.repository.RepositoryException)4 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)3 RyaClientException (org.apache.rya.api.client.RyaClientException)3 RyaDetails (org.apache.rya.api.instance.RyaDetails)3 PCJIndexDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)3 FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)3 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)3 FluoQuery (org.apache.rya.indexing.pcj.fluo.app.query.FluoQuery)3 PcjException (org.apache.rya.indexing.pcj.storage.PcjException)3 PeriodicQueryNode (org.apache.rya.indexing.pcj.fluo.app.query.PeriodicQueryNode)2 PeriodicQueryStorageException (org.apache.rya.indexing.pcj.storage.PeriodicQueryStorageException)2 PrecomputedJoinStorage (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage)2 AccumuloPcjStorage (org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage)2 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)2 SailException (org.openrdf.sail.SailException)2 JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 IOException (java.io.IOException)1