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