Search in sources :

Example 1 with RowLock

use of org.apache.accumulo.tserver.RowLocks.RowLock in project accumulo by apache.

the class ThriftClientHandler method conditionalUpdate.

private Map<KeyExtent, List<ServerConditionalMutation>> conditionalUpdate(ConditionalSession cs, Map<KeyExtent, List<ServerConditionalMutation>> updates, ArrayList<TCMResult> results, List<String> symbols) throws IOException {
    // sort each list of mutations, this is done to avoid deadlock and doing seeks in order is
    // more efficient and detect duplicate rows.
    ConditionalMutationSet.sortConditionalMutations(updates);
    Map<KeyExtent, List<ServerConditionalMutation>> deferred = new HashMap<>();
    // can not process two mutations for the same row, because one will not see what the other
    // writes
    ConditionalMutationSet.deferDuplicatesRows(updates, deferred);
    // get as many locks as possible w/o blocking... defer any rows that are locked
    List<RowLock> locks = rowLocks.acquireRowlocks(updates, deferred);
    try {
        Span span = TraceUtil.startSpan(this.getClass(), "conditionalUpdate::Check conditions");
        try (Scope scope = span.makeCurrent()) {
            checkConditions(updates, results, cs, symbols);
        } catch (Exception e) {
            TraceUtil.setException(span, e, true);
            throw e;
        } finally {
            span.end();
        }
        Span span2 = TraceUtil.startSpan(this.getClass(), "conditionalUpdate::apply conditional mutations");
        try (Scope scope = span2.makeCurrent()) {
            writeConditionalMutations(updates, results, cs);
        } catch (Exception e) {
            TraceUtil.setException(span2, e, true);
            throw e;
        } finally {
            span2.end();
        }
    } finally {
        rowLocks.releaseRowLocks(locks);
    }
    return deferred;
}
Also used : Scope(io.opentelemetry.context.Scope) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Span(io.opentelemetry.api.trace.Span) TooManyFilesException(org.apache.accumulo.server.fs.TooManyFilesException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NoSuchScanIDException(org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException) CancellationException(java.util.concurrent.CancellationException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TSampleNotPresentException(org.apache.accumulo.core.tabletserver.thrift.TSampleNotPresentException) ConstraintViolationException(org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException) TException(org.apache.thrift.TException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) TimeoutException(java.util.concurrent.TimeoutException) TabletClosedException(org.apache.accumulo.tserver.tablet.TabletClosedException) IterationInterruptedException(org.apache.accumulo.core.iteratorsImpl.system.IterationInterruptedException) NotServingTabletException(org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) SampleNotPresentException(org.apache.accumulo.core.client.SampleNotPresentException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) RowLock(org.apache.accumulo.tserver.RowLocks.RowLock)

Aggregations

Span (io.opentelemetry.api.trace.Span)1 Scope (io.opentelemetry.context.Scope)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 CancellationException (java.util.concurrent.CancellationException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Collectors.toList (java.util.stream.Collectors.toList)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 SampleNotPresentException (org.apache.accumulo.core.client.SampleNotPresentException)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 ThriftSecurityException (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)1 ThriftTableOperationException (org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException)1 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)1 TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)1 IterationInterruptedException (org.apache.accumulo.core.iteratorsImpl.system.IterationInterruptedException)1 ConstraintViolationException (org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException)1 NoSuchScanIDException (org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException)1