Search in sources :

Example 1 with QueryDeletionException

use of org.apache.rya.indexing.pcj.fluo.api.DeletePeriodicQuery.QueryDeletionException 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

InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)1 RyaClientException (org.apache.rya.api.client.RyaClientException)1 RyaDetails (org.apache.rya.api.instance.RyaDetails)1 PCJIndexDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)1 FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)1 QueryDeletionException (org.apache.rya.indexing.pcj.fluo.api.DeletePeriodicQuery.QueryDeletionException)1 UnsupportedQueryException (org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException)1 MalformedQueryException (org.openrdf.query.MalformedQueryException)1