Search in sources :

Example 1 with PCJUpdateStrategy

use of org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails.PCJUpdateStrategy in project incubator-rya by apache.

the class AccumuloBatchUpdatePCJ method verifyPCJState.

private void verifyPCJState(final String ryaInstanceName, final String pcjId) throws RyaClientException {
    try {
        // Fetch the Rya instance's details.
        final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(super.getConnector(), ryaInstanceName);
        final RyaDetails ryaDetails = detailsRepo.getRyaInstanceDetails();
        // Ensure PCJs are enabled.
        if (!ryaDetails.getPCJIndexDetails().isEnabled()) {
            throw new RyaClientException("PCJs are not enabled for the Rya instance named '" + ryaInstanceName + "'.");
        }
        // Ensure the PCJ exists.
        if (!ryaDetails.getPCJIndexDetails().getPCJDetails().containsKey(pcjId)) {
            throw new PCJDoesNotExistException("The PCJ with id '" + pcjId + "' does not exist within Rya instance '" + ryaInstanceName + "'.");
        }
        // Ensure the PCJ is not already being incrementally updated.
        final PCJDetails pcjDetails = ryaDetails.getPCJIndexDetails().getPCJDetails().get(pcjId);
        final Optional<PCJUpdateStrategy> updateStrategy = pcjDetails.getUpdateStrategy();
        if (updateStrategy.isPresent() && updateStrategy.get() == PCJUpdateStrategy.INCREMENTAL) {
            throw new RyaClientException("The PCJ with id '" + pcjId + "' is already being updated incrementally.");
        }
    } catch (final NotInitializedException e) {
        throw new InstanceDoesNotExistException("No RyaDetails are initialized for the Rya instance named '" + ryaInstanceName + "'.", e);
    } catch (final RyaDetailsRepositoryException e) {
        throw new RyaClientException("Could not fetch the RyaDetails for the Rya instance named '" + ryaInstanceName + "'.", e);
    }
}
Also used : PCJUpdateStrategy(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails.PCJUpdateStrategy) RyaClientException(org.apache.rya.api.client.RyaClientException) NotInitializedException(org.apache.rya.api.instance.RyaDetailsRepository.NotInitializedException) PCJDoesNotExistException(org.apache.rya.api.client.PCJDoesNotExistException) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)

Aggregations

AccumuloRyaInstanceDetailsRepository (org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)1 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)1 PCJDoesNotExistException (org.apache.rya.api.client.PCJDoesNotExistException)1 RyaClientException (org.apache.rya.api.client.RyaClientException)1 RyaDetails (org.apache.rya.api.instance.RyaDetails)1 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)1 PCJUpdateStrategy (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails.PCJUpdateStrategy)1 RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)1 NotInitializedException (org.apache.rya.api.instance.RyaDetailsRepository.NotInitializedException)1 RyaDetailsRepositoryException (org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)1