Search in sources :

Example 1 with UpdateErrors

use of org.apache.accumulo.core.dataImpl.thrift.UpdateErrors in project accumulo by apache.

the class ThriftClientHandler method closeUpdate.

@Override
public UpdateErrors closeUpdate(TInfo tinfo, long updateID) throws NoSuchScanIDException {
    final UpdateSession us = (UpdateSession) server.sessionManager.removeSession(updateID);
    if (us == null) {
        throw new NoSuchScanIDException();
    }
    // clients may or may not see data from an update session while
    // it is in progress, however when the update session is closed
    // want to ensure that reads wait for the write to finish
    long opid = writeTracker.startWrite(us.queuedMutations.keySet());
    try {
        flush(us);
    } catch (HoldTimeoutException e) {
        // Assumption is that the client has timed out and is gone. If that's not the case throw an
        // exception that will cause it to retry.
        log.debug("HoldTimeoutException during closeUpdate, reporting no such session");
        throw new NoSuchScanIDException();
    } finally {
        writeTracker.finishWrite(opid);
    }
    if (log.isTraceEnabled()) {
        log.trace(String.format("UpSess %s %,d in %.3fs, at=[%s] ft=%.3fs(pt=%.3fs lt=%.3fs ct=%.3fs)", TServerUtils.clientAddress.get(), us.totalUpdates, (System.currentTimeMillis() - us.startTime) / 1000.0, us.authTimes, us.flushTime / 1000.0, us.prepareTimes.sum() / 1000.0, us.walogTimes.sum() / 1000.0, us.commitTimes.sum() / 1000.0));
    }
    if (!us.failures.isEmpty()) {
        Entry<KeyExtent, Long> first = us.failures.entrySet().iterator().next();
        log.debug(String.format("Failures: %d, first extent %s successful commits: %d", us.failures.size(), first.getKey().toString(), first.getValue()));
    }
    List<ConstraintViolationSummary> violations = us.violations.asList();
    if (!violations.isEmpty()) {
        ConstraintViolationSummary first = us.violations.asList().iterator().next();
        log.debug(String.format("Violations: %d, first %s occurs %d", violations.size(), first.violationDescription, first.numberOfViolatingMutations));
    }
    if (!us.authFailures.isEmpty()) {
        KeyExtent first = us.authFailures.keySet().iterator().next();
        log.debug(String.format("Authentication Failures: %d, first %s", us.authFailures.size(), first.toString()));
    }
    return new UpdateErrors(us.failures.entrySet().stream().collect(Collectors.toMap(e -> e.getKey().toThrift(), Entry::getValue)), violations.stream().map(ConstraintViolationSummary::toThrift).collect(Collectors.toList()), us.authFailures.entrySet().stream().collect(Collectors.toMap(e -> e.getKey().toThrift(), Entry::getValue)));
}
Also used : KVEntry(org.apache.accumulo.tserver.tablet.KVEntry) Entry(java.util.Map.Entry) UpdateErrors(org.apache.accumulo.core.dataImpl.thrift.UpdateErrors) UpdateSession(org.apache.accumulo.tserver.session.UpdateSession) ConstraintViolationSummary(org.apache.accumulo.core.data.ConstraintViolationSummary) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) NoSuchScanIDException(org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException)

Aggregations

Entry (java.util.Map.Entry)1 ConstraintViolationSummary (org.apache.accumulo.core.data.ConstraintViolationSummary)1 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)1 TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)1 UpdateErrors (org.apache.accumulo.core.dataImpl.thrift.UpdateErrors)1 NoSuchScanIDException (org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException)1 UpdateSession (org.apache.accumulo.tserver.session.UpdateSession)1 KVEntry (org.apache.accumulo.tserver.tablet.KVEntry)1