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;
}
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);
}
}
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);
}
}
Aggregations