Search in sources :

Example 86 with MutationsRejectedException

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

the class TabletServerBatchWriter method checkForFailures.

private void checkForFailures() throws MutationsRejectedException {
    if (somethingFailed) {
        List<ConstraintViolationSummary> cvsList = violations.asList();
        HashMap<TabletId, Set<org.apache.accumulo.core.client.security.SecurityErrorCode>> af = new HashMap<>();
        for (Entry<KeyExtent, Set<SecurityErrorCode>> entry : authorizationFailures.entrySet()) {
            HashSet<org.apache.accumulo.core.client.security.SecurityErrorCode> codes = new HashSet<>();
            for (SecurityErrorCode sce : entry.getValue()) {
                codes.add(org.apache.accumulo.core.client.security.SecurityErrorCode.valueOf(sce.name()));
            }
            af.put(new TabletIdImpl(entry.getKey()), codes);
        }
        throw new MutationsRejectedException(context, cvsList, af, serverSideErrors, unknownErrors, lastUnknownError);
    }
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) SecurityErrorCode(org.apache.accumulo.core.clientImpl.thrift.SecurityErrorCode) TabletIdImpl(org.apache.accumulo.core.dataImpl.TabletIdImpl) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) ConstraintViolationSummary(org.apache.accumulo.core.data.ConstraintViolationSummary) TabletId(org.apache.accumulo.core.data.TabletId) HashSet(java.util.HashSet) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 87 with MutationsRejectedException

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

the class TabletServerBatchWriter method close.

@Override
public synchronized void close() throws MutationsRejectedException {
    if (closed)
        return;
    Span span = TraceUtil.startSpan(this.getClass(), "close");
    try (Scope scope = span.makeCurrent()) {
        closed = true;
        startProcessing();
        waitRTE(() -> totalMemUsed > 0 && !somethingFailed);
        logStats();
        checkForFailures();
    } catch (Exception e) {
        TraceUtil.setException(span, e, true);
        throw e;
    } finally {
        span.end();
        // make a best effort to release these resources
        writer.binningThreadPool.shutdownNow();
        writer.sendThreadPool.shutdownNow();
        executor.shutdownNow();
    }
}
Also used : Scope(io.opentelemetry.context.Scope) Span(io.opentelemetry.api.trace.Span) TableOfflineException(org.apache.accumulo.core.client.TableOfflineException) TTransportException(org.apache.thrift.transport.TTransportException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TimedOutException(org.apache.accumulo.core.client.TimedOutException) TableDeletedException(org.apache.accumulo.core.client.TableDeletedException) NotServingTabletException(org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TApplicationException(org.apache.thrift.TApplicationException) ConstraintViolationException(org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException) TException(org.apache.thrift.TException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException)

Example 88 with MutationsRejectedException

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

the class AccumuloRecordWriter method write.

/**
 * Push a mutation into a table. If table is null, the defaultTable will be used. If
 * OutputFormatBuilder#createTables() is set, the table will be created if it does not exist. The
 * table name must only contain alphanumerics and underscore.
 */
@Override
public void write(Text table, Mutation mutation) throws IOException {
    if (table == null || table.toString().isEmpty())
        table = this.defaultTableName;
    if (!simulate && table == null)
        throw new IOException("No table or default table specified. Try simulation mode next time");
    ++mutCount;
    valCount += mutation.size();
    printMutation(table, mutation);
    if (simulate)
        return;
    if (!bws.containsKey(table))
        try {
            addTable(table);
        } catch (final AccumuloSecurityException | AccumuloException e) {
            log.error("Could not add table '" + table + "'", e);
            throw new IOException(e);
        }
    try {
        bws.get(table).addMutation(mutation);
    } catch (MutationsRejectedException e) {
        throw new IOException(e);
    }
}
Also used : IOException(java.io.IOException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 89 with MutationsRejectedException

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

the class RemoveCompleteReplicationRecords method run.

@Override
public void run() {
    BatchScanner bs;
    BatchWriter bw;
    try {
        bs = ReplicationTable.getBatchScanner(client, 4);
        bw = ReplicationTable.getBatchWriter(client);
        if (bs == null || bw == null)
            throw new AssertionError("Inconceivable; an exception should have been" + " thrown, but 'bs' or 'bw' was null instead");
    } catch (ReplicationTableOfflineException e) {
        log.trace("Not attempting to remove complete replication records as the" + " table ({}) isn't yet online", ReplicationTable.NAME);
        return;
    }
    bs.setRanges(Collections.singleton(new Range()));
    IteratorSetting cfg = new IteratorSetting(50, WholeRowIterator.class);
    StatusSection.limit(bs);
    WorkSection.limit(bs);
    bs.addScanIterator(cfg);
    long recordsRemoved = 0;
    long startTime = System.nanoTime();
    Duration duration;
    try {
        recordsRemoved = removeCompleteRecords(client, bs, bw);
    } finally {
        bs.close();
        try {
            bw.close();
        } catch (MutationsRejectedException e) {
            log.error("Error writing mutations to {}, will retry", ReplicationTable.NAME, e);
        }
        duration = Duration.ofNanos(System.nanoTime() - startTime);
    }
    log.info("Removed {} complete replication entries from the table {} in {}", recordsRemoved, ReplicationTable.NAME, duration);
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) BatchScanner(org.apache.accumulo.core.client.BatchScanner) Duration(java.time.Duration) BatchWriter(org.apache.accumulo.core.client.BatchWriter) ReplicationTableOfflineException(org.apache.accumulo.core.replication.ReplicationTableOfflineException) Range(org.apache.accumulo.core.data.Range) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 90 with MutationsRejectedException

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

the class WorkMaker method addWorkRecord.

protected void addWorkRecord(Text file, Value v, Map<String, String> targets, TableId sourceTableId) {
    log.info("Adding work records for {} to targets {}", file, targets);
    try {
        Mutation m = new Mutation(file);
        ReplicationTarget target = new ReplicationTarget();
        DataOutputBuffer buffer = new DataOutputBuffer();
        Text t = new Text();
        for (Entry<String, String> entry : targets.entrySet()) {
            buffer.reset();
            // Set up the writable
            target.setPeerName(entry.getKey());
            target.setRemoteIdentifier(entry.getValue());
            target.setSourceTableId(sourceTableId);
            target.write(buffer);
            // Throw it in a text for the mutation
            t.set(buffer.getData(), 0, buffer.getLength());
            // Add it to the work section
            WorkSection.add(m, t, v);
        }
        try {
            writer.addMutation(m);
        } catch (MutationsRejectedException e) {
            log.warn("Failed to write work mutations for replication, will retry", e);
        }
    } catch (IOException e) {
        log.warn("Failed to serialize data to Text, will retry", e);
    } finally {
        try {
            writer.flush();
        } catch (MutationsRejectedException e) {
            log.warn("Failed to write work mutations for replication, will retry", e);
        }
    }
}
Also used : ReplicationTarget(org.apache.accumulo.core.replication.ReplicationTarget) DataOutputBuffer(org.apache.hadoop.io.DataOutputBuffer) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) IOException(java.io.IOException) 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