Search in sources :

Example 36 with MutationsRejectedException

use of org.apache.accumulo.core.client.MutationsRejectedException in project incubator-rya by apache.

the class PcjTables method purgePcjTable.

/**
 * Deletes all of the rows that are in a PCJ index and sets its cardinality back to 0.
 *
 * @param accumuloConn - Connects to the Accumulo that hosts the PCJ indices. (not null)
 * @param pcjTableName - The name of the PCJ table that will be purged. (not null)
 * @throws PCJStorageException Either the rows could not be dropped from the
 *   PCJ table or the metadata could not be written back to the table.
 */
public void purgePcjTable(final Connector accumuloConn, final String pcjTableName) throws PCJStorageException {
    checkNotNull(accumuloConn);
    checkNotNull(pcjTableName);
    // Fetch the metadaata from the PCJ table.
    final PcjMetadata oldMetadata = getPcjMetadata(accumuloConn, pcjTableName);
    // Delete all of the rows
    try {
        accumuloConn.tableOperations().deleteRows(pcjTableName, null, null);
    } catch (AccumuloException | AccumuloSecurityException | TableNotFoundException e) {
        throw new PCJStorageException("Could not delete the rows of data from PCJ table named: " + pcjTableName, e);
    }
    // Store the new metadata.
    final PcjMetadata newMetadata = new PcjMetadata(oldMetadata.getSparql(), 0L, oldMetadata.getVarOrders());
    final List<Mutation> mutations = makeWriteMetadataMutations(newMetadata);
    BatchWriter writer = null;
    try {
        writer = accumuloConn.createBatchWriter(pcjTableName, new BatchWriterConfig());
        writer.addMutations(mutations);
        writer.flush();
    } catch (final TableNotFoundException | MutationsRejectedException e) {
        throw new PCJStorageException("Could not rewrite the PCJ cardinality for table named '" + pcjTableName + "'. This table will not work anymore.", e);
    } finally {
        if (writer != null) {
            try {
                writer.close();
            } catch (final MutationsRejectedException e) {
                throw new PCJStorageException("Could not close the batch writer.", e);
            }
        }
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) PcjMetadata(org.apache.rya.indexing.pcj.storage.PcjMetadata) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) PCJStorageException(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException) Mutation(org.apache.accumulo.core.data.Mutation) ConditionalMutation(org.apache.accumulo.core.data.ConditionalMutation) BatchWriter(org.apache.accumulo.core.client.BatchWriter) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 37 with MutationsRejectedException

use of org.apache.accumulo.core.client.MutationsRejectedException in project incubator-rya by apache.

the class AccumuloRyaDAO method flush.

@Override
public void flush() throws RyaDAOException {
    try {
        mt_bw.flush();
        flushIndexers();
    } catch (final MutationsRejectedException e) {
        throw new RyaDAOException(e);
    }
}
Also used : RyaDAOException(org.apache.rya.api.persist.RyaDAOException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 38 with MutationsRejectedException

use of org.apache.accumulo.core.client.MutationsRejectedException in project incubator-rya by apache.

the class AccumuloRyaDAO method purge.

@Override
public void purge(final RdfCloudTripleStoreConfiguration configuration) {
    for (final String tableName : getTables()) {
        try {
            purge(tableName, configuration.getAuths());
            compact(tableName);
        } catch (final TableNotFoundException e) {
            logger.error(e.getMessage());
        } catch (final MutationsRejectedException e) {
            logger.error(e.getMessage());
        }
    }
    for (final AccumuloIndexer indexer : this.secondaryIndexers) {
        try {
            indexer.purge(configuration);
        } catch (final Exception e) {
            logger.error("Failed to purge indexer", e);
        }
    }
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloIndexer(org.apache.rya.accumulo.experimental.AccumuloIndexer) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 39 with MutationsRejectedException

use of org.apache.accumulo.core.client.MutationsRejectedException in project incubator-rya by apache.

the class AccumuloRyaInstanceDetailsRepository method initialize.

@Override
public void initialize(final RyaDetails details) throws AlreadyInitializedException, RyaDetailsRepositoryException {
    // Preconditions.
    requireNonNull(details);
    if (!details.getRyaInstanceName().equals(instanceName)) {
        throw new RyaDetailsRepositoryException("The instance name that was in the provided 'details' does not match " + "the instance name that this repository is connected to. Make sure you're connected to the" + "correct Rya instance.");
    }
    if (isInitialized()) {
        throw new AlreadyInitializedException("The repository has already been initialized for the Rya instance named '" + instanceName + "'.");
    }
    // Create the table that hosts the details if it has not been created yet.
    final TableOperations tableOps = connector.tableOperations();
    if (!tableOps.exists(detailsTableName)) {
        try {
            tableOps.create(detailsTableName);
        } catch (AccumuloException | AccumuloSecurityException | TableExistsException e) {
            throw new RyaDetailsRepositoryException("Could not initialize the Rya instance details for the instance named '" + instanceName + "' because the the table that holds that information could not be created.");
        }
    }
    // Write the details to the table.
    BatchWriter writer = null;
    try {
        writer = connector.createBatchWriter(detailsTableName, new BatchWriterConfig());
        final byte[] bytes = serializer.serialize(details);
        final Mutation mutation = new Mutation(ROW_ID);
        mutation.put(COL_FAMILY, COL_QUALIFIER, new Value(bytes));
        writer.addMutation(mutation);
    } catch (final TableNotFoundException | MutationsRejectedException e) {
        throw new RyaDetailsRepositoryException("Could not initialize the Rya instance details for the instance named '" + instanceName + "'.", e);
    } finally {
        if (writer != null) {
            try {
                writer.close();
            } catch (final MutationsRejectedException e) {
                throw new RyaDetailsRepositoryException("Could not initialize the Rya instance details for the instance named '" + instanceName + "'.", e);
            }
        }
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) TableOperations(org.apache.accumulo.core.client.admin.TableOperations) TableExistsException(org.apache.accumulo.core.client.TableExistsException) Value(org.apache.accumulo.core.data.Value) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) ConditionalMutation(org.apache.accumulo.core.data.ConditionalMutation) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 40 with MutationsRejectedException

use of org.apache.accumulo.core.client.MutationsRejectedException in project accumulo by apache.

the class MetaDataStateStore method setLocations.

@Override
public void setLocations(Collection<Assignment> assignments) throws DistributedStoreException {
    BatchWriter writer = createBatchWriter();
    try {
        for (Assignment assignment : assignments) {
            Mutation m = new Mutation(assignment.tablet.getMetadataEntry());
            assignment.server.putLocation(m);
            assignment.server.clearFutureLocation(m);
            SuspendingTServer.clearSuspension(m);
            writer.addMutation(m);
        }
    } catch (Exception ex) {
        throw new DistributedStoreException(ex);
    } finally {
        try {
            writer.close();
        } catch (MutationsRejectedException e) {
            throw new DistributedStoreException(e);
        }
    }
}
Also used : BatchWriter(org.apache.accumulo.core.client.BatchWriter) Mutation(org.apache.accumulo.core.data.Mutation) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Aggregations

MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)68 Mutation (org.apache.accumulo.core.data.Mutation)48 BatchWriter (org.apache.accumulo.core.client.BatchWriter)40 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)23 Value (org.apache.accumulo.core.data.Value)23 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)21 Text (org.apache.hadoop.io.Text)20 Key (org.apache.accumulo.core.data.Key)13 IOException (java.io.IOException)12 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)12 AccumuloException (org.apache.accumulo.core.client.AccumuloException)11 HashMap (java.util.HashMap)10 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)9 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 Entry (java.util.Map.Entry)6 TableExistsException (org.apache.accumulo.core.client.TableExistsException)6 ConditionalMutation (org.apache.accumulo.core.data.ConditionalMutation)6 ConstraintViolationSummary (org.apache.accumulo.core.data.ConstraintViolationSummary)6 PrestoException (com.facebook.presto.spi.PrestoException)5