Search in sources :

Example 21 with RyaDetailsRepositoryException

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

the class AccumuloPcjStorage method createPcj.

@Override
public String createPcj(final String sparql) throws PCJStorageException {
    requireNonNull(sparql);
    // Create the variable orders that will be used within Accumulo to store the PCJ.
    final Set<VariableOrder> varOrders;
    try {
        varOrders = pcjVarOrderFactory.makeVarOrders(sparql);
    } catch (final MalformedQueryException e) {
        throw new PCJStorageException("Can not create the PCJ. The SPARQL is malformed.", e);
    }
    // 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 table that will hold the PCJ's results.
    final String pcjTableName = pcjTableNameFactory.makeTableName(ryaInstanceName, pcjId);
    pcjTables.createPcjTable(accumuloConn, pcjTableName, varOrders, sparql);
    // Add access to the PCJ table to all users who are authorized for this instance of Rya.
    try {
        for (final String user : ryaDetailsRepo.getRyaInstanceDetails().getUsers()) {
            TABLE_PERMISSIONS.grantAllPermissions(user, pcjTableName, accumuloConn);
        }
    } catch (final RyaDetailsRepositoryException | AccumuloException | AccumuloSecurityException e) {
        throw new PCJStorageException(String.format("Could not grant authorized users access to the " + "new PCJ index table '%s' for Rya instance '%s' because of a problem while granting " + "the permissions.", pcjTableName, ryaInstanceName), e);
    }
    return pcjId;
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaDetailsUpdater(org.apache.rya.api.instance.RyaDetailsUpdater) CouldNotApplyMutationException(org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator.CouldNotApplyMutationException) RyaDetails(org.apache.rya.api.instance.RyaDetails) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails) MalformedQueryException(org.openrdf.query.MalformedQueryException) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException)

Example 22 with RyaDetailsRepositoryException

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

the class SetRyaStreamsConfigurationBase method setRyaStreamsConfiguration.

@Override
public void setRyaStreamsConfiguration(final String ryaInstance, final RyaStreamsDetails streamsDetails) throws InstanceDoesNotExistException, RyaClientException {
    requireNonNull(ryaInstance);
    requireNonNull(streamsDetails);
    // Verify the Rya Instance exists.
    if (!instanceExists.exists(ryaInstance)) {
        throw new InstanceDoesNotExistException("There is no Rya instance named '" + ryaInstance + "' in this storage.");
    }
    // Update the old details object using the provided Rya Streams details.
    final RyaDetailsRepository repo = getRyaDetailsRepo(ryaInstance);
    try {
        new RyaDetailsUpdater(repo).update(oldDetails -> {
            final RyaDetails.Builder builder = RyaDetails.builder(oldDetails);
            builder.setRyaStreamsDetails(streamsDetails);
            return builder.build();
        });
    } catch (CouldNotApplyMutationException | RyaDetailsRepositoryException e) {
        throw new RyaClientException("Unable to update which Rya Streams subsystem is used by the '" + ryaInstance + "' Rya instance.", e);
    }
}
Also used : RyaDetailsUpdater(org.apache.rya.api.instance.RyaDetailsUpdater) CouldNotApplyMutationException(org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator.CouldNotApplyMutationException) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)

Example 23 with RyaDetailsRepositoryException

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

the class AccumuloGetInstanceDetails method getDetails.

@Override
public Optional<RyaDetails> getDetails(final String instanceName) throws InstanceDoesNotExistException, RyaClientException {
    requireNonNull(instanceName);
    // Ensure the Rya instance exists.
    if (!instanceExists.exists(instanceName)) {
        throw new InstanceDoesNotExistException(String.format("There is no Rya instance named '%s'.", instanceName));
    }
    // If the instance has details, then return them.
    final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(getConnector(), instanceName);
    try {
        return Optional.of(detailsRepo.getRyaInstanceDetails());
    } catch (final NotInitializedException e) {
        return Optional.absent();
    } catch (final RyaDetailsRepositoryException e) {
        throw new RyaClientException("Could not fetch the Rya instance's details.", e);
    }
}
Also used : NotInitializedException(org.apache.rya.api.instance.RyaDetailsRepository.NotInitializedException) RyaClientException(org.apache.rya.api.client.RyaClientException) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)

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