Search in sources :

Example 6 with RyaDetailsUpdater

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

the class AccumuloPcjStorage method dropPcj.

@Override
public void dropPcj(final String pcjId) throws PCJStorageException {
    requireNonNull(pcjId);
    // Update the Rya Details for this instance to no longer include the PCJ.
    try {
        new RyaDetailsUpdater(ryaDetailsRepo).update(originalDetails -> {
            // Drop the PCJ's metadata from the instance's metadata.
            final RyaDetails.Builder mutated = RyaDetails.builder(originalDetails);
            mutated.getPCJIndexDetails().removePCJDetails(pcjId);
            return mutated.build();
        });
    } catch (final RyaDetailsRepositoryException | CouldNotApplyMutationException e) {
        throw new PCJStorageException(String.format("Could not drop an existing PCJ for Rya instance '%s' " + "because of a problem while updating the instance's details.", ryaInstanceName), e);
    }
    // Delete the table that hold's the PCJ's results.
    final String pcjTableName = pcjTableNameFactory.makeTableName(ryaInstanceName, pcjId);
    pcjTables.dropPcjTable(accumuloConn, pcjTableName);
}
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)

Example 7 with RyaDetailsUpdater

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

the class AccumuloRemoveUser method removeUser.

@Override
public void removeUser(final String instanceName, final String username) throws InstanceDoesNotExistException, RyaClientException {
    requireNonNull(instanceName);
    requireNonNull(username);
    // Update the instance details.
    final RyaDetailsUpdater updater = new RyaDetailsUpdater(new AccumuloRyaInstanceDetailsRepository(getConnector(), instanceName));
    try {
        updater.update(originalDetails -> RyaDetails.builder(originalDetails).removeUser(username).build());
    } catch (RyaDetailsRepositoryException | CouldNotApplyMutationException e) {
        throw new RyaClientException("Could not remove the user '" + username + "' from the Rya instance's details.", e);
    }
    // Revoke all access to all the instance's tables.
    try {
        // Build the list of tables that are present within the Rya instance.
        final List<String> tables = new RyaTableNames().getTableNames(instanceName, getConnector());
        // Update the user permissions for those tables.
        for (final String table : tables) {
            try {
                TABLE_PERMISSIONS.revokeAllPermissions(username, table, getConnector());
            } catch (AccumuloException | AccumuloSecurityException e) {
                throw new RyaClientException("Could not revoke access to table '" + table + "' from user '" + username + "'.", e);
            }
        }
    } catch (PCJStorageException | RyaDetailsRepositoryException e) {
        throw new RyaClientException("Could not determine which tables exist for the '" + instanceName + "' instance of Rya.", e);
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaClientException(org.apache.rya.api.client.RyaClientException) RyaDetailsUpdater(org.apache.rya.api.instance.RyaDetailsUpdater) CouldNotApplyMutationException(org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator.CouldNotApplyMutationException) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) RyaTableNames(org.apache.rya.accumulo.utils.RyaTableNames) 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 8 with RyaDetailsUpdater

use of org.apache.rya.api.instance.RyaDetailsUpdater 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 9 with RyaDetailsUpdater

use of org.apache.rya.api.instance.RyaDetailsUpdater 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 10 with RyaDetailsUpdater

use of org.apache.rya.api.instance.RyaDetailsUpdater 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)

Aggregations

RyaDetailsRepositoryException (org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)10 RyaDetailsUpdater (org.apache.rya.api.instance.RyaDetailsUpdater)10 CouldNotApplyMutationException (org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator.CouldNotApplyMutationException)10 RyaDetails (org.apache.rya.api.instance.RyaDetails)9 RyaClientException (org.apache.rya.api.client.RyaClientException)5 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)5 AccumuloRyaInstanceDetailsRepository (org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)4 RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)4 AccumuloException (org.apache.accumulo.core.client.AccumuloException)3 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)3 RyaDetailsMutator (org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator)3 PCJStorageException (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException)3 Date (java.util.Date)2 RyaTableNames (org.apache.rya.accumulo.utils.RyaTableNames)2 MalformedQueryException (org.openrdf.query.MalformedQueryException)2 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)1 PCJIndexDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)1 FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)1 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)1 UnsupportedQueryException (org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException)1