Search in sources :

Example 91 with MutationsRejectedException

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

the class StatusMaker method deleteStatusRecord.

/**
 * Because there is only one active Manager, and thus one active StatusMaker, the only safe time
 * that we can issue the delete for a Status which is closed is immediately after writing it to
 * the replication table.
 * <p>
 * If we try to defer and delete these entries in another thread/process, we will have no
 * assurance that the Status message was propagated to the replication table. It is easiest, in
 * terms of concurrency, to do this all in one step.
 *
 * @param k
 *          The Key to delete
 */
protected void deleteStatusRecord(Key k) {
    log.debug("Deleting {} from metadata table as it's no longer needed", k.toStringNoTruncate());
    if (metadataWriter == null) {
        try {
            metadataWriter = client.createBatchWriter(sourceTableName);
        } catch (TableNotFoundException e) {
            throw new RuntimeException("Metadata table doesn't exist");
        }
    }
    try {
        Mutation m = new Mutation(k.getRow());
        m.putDelete(k.getColumnFamily(), k.getColumnQualifier());
        metadataWriter.addMutation(m);
        metadataWriter.flush();
    } catch (MutationsRejectedException e) {
        log.warn("Failed to delete status mutations for metadata table, will retry", e);
    }
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) Mutation(org.apache.accumulo.core.data.Mutation) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Aggregations

MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)91 Mutation (org.apache.accumulo.core.data.Mutation)62 BatchWriter (org.apache.accumulo.core.client.BatchWriter)52 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)31 Text (org.apache.hadoop.io.Text)31 Value (org.apache.accumulo.core.data.Value)30 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)23 Key (org.apache.accumulo.core.data.Key)21 IOException (java.io.IOException)20 HashMap (java.util.HashMap)15 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)13 AccumuloException (org.apache.accumulo.core.client.AccumuloException)12 ConstraintViolationSummary (org.apache.accumulo.core.data.ConstraintViolationSummary)10 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)10 ArrayList (java.util.ArrayList)9 Scanner (org.apache.accumulo.core.client.Scanner)9 Set (java.util.Set)8 Test (org.junit.Test)8 List (java.util.List)7 Entry (java.util.Map.Entry)7