Search in sources :

Example 16 with RyaDetailsRepositoryException

use of org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException in project incubator-rya by apache.

the class AccumuloUninstall method uninstall.

@Override
public void uninstall(final String ryaInstanceName) throws InstanceDoesNotExistException, RyaClientException {
    requireNonNull(ryaInstanceName);
    // Ensure the Rya Instance exists.
    if (!instanceExists.exists(ryaInstanceName)) {
        throw new InstanceDoesNotExistException(String.format("There is no Rya instance named '%s'.", ryaInstanceName));
    }
    try {
        // Build the list of tables that are present within the Rya instance.
        final List<String> tables = new RyaTableNames().getTableNames(ryaInstanceName, getConnector());
        // Delete them.
        final TableOperations tableOps = getConnector().tableOperations();
        for (final String table : tables) {
            try {
                tableOps.delete(table);
            } catch (final TableNotFoundException e) {
                log.warn("Uninstall could not delete table named '" + LogUtils.clean(table) + "' because it does not exist. " + "Something else is also deleting tables.");
            }
        }
    } catch (PCJStorageException | RyaDetailsRepositoryException e) {
        throw new RyaClientException("Could not uninstall the Rya instance named '" + ryaInstanceName + "' because we could not determine which tables are associated with it.", e);
    } catch (AccumuloException | AccumuloSecurityException e) {
        throw new RyaClientException("Could not uninstall the Rya instance named '" + ryaInstanceName + "' because of a problem interacting with Accumulo..", e);
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaClientException(org.apache.rya.api.client.RyaClientException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) RyaTableNames(org.apache.rya.accumulo.utils.RyaTableNames) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) TableOperations(org.apache.accumulo.core.client.admin.TableOperations) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) PCJStorageException(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException)

Example 17 with RyaDetailsRepositoryException

use of org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException in project incubator-rya by apache.

the class MongoBatchUpdatePCJ method verifyPCJState.

private void verifyPCJState(final String ryaInstanceName, final String pcjId, final MongoClient client) throws RyaClientException {
    try {
        // Fetch the Rya instance's details.
        final RyaDetailsRepository detailsRepo = new MongoRyaInstanceDetailsRepository(client, 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 + "'.");
        }
    } 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 : 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) MongoRyaInstanceDetailsRepository(org.apache.rya.mongodb.instance.MongoRyaInstanceDetailsRepository) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException)

Example 18 with RyaDetailsRepositoryException

use of org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException in project incubator-rya by apache.

the class MongoPcjStorage method listPcjs.

@Override
public List<String> listPcjs() throws PCJStorageException {
    try {
        final RyaDetails details = ryaDetailsRepo.getRyaInstanceDetails();
        final PCJIndexDetails pcjIndexDetails = details.getPCJIndexDetails();
        final List<String> pcjIds = new ArrayList<>(pcjIndexDetails.getPCJDetails().keySet());
        return pcjIds;
    } catch (final RyaDetailsRepositoryException e) {
        throw new PCJStorageException("Could not check to see if RyaDetails exist for the instance.", e);
    }
}
Also used : ArrayList(java.util.ArrayList) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) PCJIndexDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)

Example 19 with RyaDetailsRepositoryException

use of org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException in project incubator-rya by apache.

the class MongoPcjStorage method createPcj.

@Override
public String createPcj(final String sparql) throws PCJStorageException {
    requireNonNull(sparql);
    // Update the Rya Details for this instance to include the new PCJ
    // table.
    final String pcjId = pcjIdFactory.nextId();
    try {
        new RyaDetailsUpdater(ryaDetailsRepo).update(originalDetails -> {
            // Create the new PCJ's details.
            final PCJDetails.Builder newPcjDetails = PCJDetails.builder().setId(pcjId);
            // Add them to the instance's details.
            final RyaDetails.Builder mutated = RyaDetails.builder(originalDetails);
            mutated.getPCJIndexDetails().addPCJDetails(newPcjDetails);
            return mutated.build();
        });
    } catch (final RyaDetailsRepositoryException | CouldNotApplyMutationException e) {
        throw new PCJStorageException(String.format("Could not create a new PCJ for Rya instance '%s' " + "because of a problem while updating the instance's details.", ryaInstanceName), e);
    }
    // Create the objectID of the document to house the PCJ results.
    pcjDocs.createPcj(pcjId, sparql);
    // instance of Rya.
    return pcjId;
}
Also used : RyaDetailsUpdater(org.apache.rya.api.instance.RyaDetailsUpdater) CouldNotApplyMutationException(org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator.CouldNotApplyMutationException) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)

Example 20 with RyaDetailsRepositoryException

use of org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException in project incubator-rya by apache.

the class AccumuloPcjStorage method listPcjs.

@Override
public List<String> listPcjs() throws PCJStorageException {
    try {
        final RyaDetails details = ryaDetailsRepo.getRyaInstanceDetails();
        final PCJIndexDetails pcjIndexDetails = details.getPCJIndexDetails();
        final List<String> pcjIds = new ArrayList<>(pcjIndexDetails.getPCJDetails().keySet());
        return pcjIds;
    } catch (final RyaDetailsRepositoryException e) {
        throw new PCJStorageException("Could not check to see if RyaDetails exist for the instance.", e);
    }
}
Also used : ArrayList(java.util.ArrayList) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) PCJIndexDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)

Aggregations

RyaDetailsRepositoryException (org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)23 RyaDetails (org.apache.rya.api.instance.RyaDetails)15 RyaClientException (org.apache.rya.api.client.RyaClientException)12 RyaDetailsUpdater (org.apache.rya.api.instance.RyaDetailsUpdater)10 CouldNotApplyMutationException (org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator.CouldNotApplyMutationException)10 RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)9 AccumuloRyaInstanceDetailsRepository (org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)7 AccumuloException (org.apache.accumulo.core.client.AccumuloException)6 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)6 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)6 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)6 MongoRyaInstanceDetailsRepository (org.apache.rya.mongodb.instance.MongoRyaInstanceDetailsRepository)6 NotInitializedException (org.apache.rya.api.instance.RyaDetailsRepository.NotInitializedException)4 PCJStorageException (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException)4 RyaTableNames (org.apache.rya.accumulo.utils.RyaTableNames)3 PCJIndexDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)3 RyaDetailsMutator (org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator)3 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)3 StatefulMongoDBRdfConfiguration (org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration)3 SailException (org.openrdf.sail.SailException)3