Search in sources :

Example 1 with CompressedIterators

use of org.apache.accumulo.core.clientImpl.CompressedIterators in project accumulo by apache.

the class ThriftClientHandler method checkConditions.

private void checkConditions(Map<KeyExtent, List<ServerConditionalMutation>> updates, ArrayList<TCMResult> results, ConditionalSession cs, List<String> symbols) throws IOException {
    Iterator<Entry<KeyExtent, List<ServerConditionalMutation>>> iter = updates.entrySet().iterator();
    final CompressedIterators compressedIters = new CompressedIterators(symbols);
    ConditionCheckerContext checkerContext = new ConditionCheckerContext(server.getContext(), compressedIters, context.getTableConfiguration(cs.tableId));
    while (iter.hasNext()) {
        final Entry<KeyExtent, List<ServerConditionalMutation>> entry = iter.next();
        final Tablet tablet = server.getOnlineTablet(entry.getKey());
        if (tablet == null || tablet.isClosed()) {
            for (ServerConditionalMutation scm : entry.getValue()) {
                results.add(new TCMResult(scm.getID(), TCMStatus.IGNORED));
            }
            iter.remove();
        } else {
            final List<ServerConditionalMutation> okMutations = new ArrayList<>(entry.getValue().size());
            final List<TCMResult> resultsSubList = results.subList(results.size(), results.size());
            ConditionChecker checker = checkerContext.newChecker(entry.getValue(), okMutations, resultsSubList);
            try {
                tablet.checkConditions(checker, cs.auths, cs.interruptFlag);
                if (okMutations.isEmpty()) {
                    iter.remove();
                } else {
                    entry.setValue(okMutations);
                }
            } catch (TabletClosedException | IterationInterruptedException | TooManyFilesException e) {
                // clear anything added while checking conditions.
                resultsSubList.clear();
                for (ServerConditionalMutation scm : entry.getValue()) {
                    results.add(new TCMResult(scm.getID(), TCMStatus.IGNORED));
                }
                iter.remove();
            }
        }
    }
}
Also used : ServerConditionalMutation(org.apache.accumulo.tserver.data.ServerConditionalMutation) TooManyFilesException(org.apache.accumulo.server.fs.TooManyFilesException) ArrayList(java.util.ArrayList) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) TCMResult(org.apache.accumulo.core.dataImpl.thrift.TCMResult) TabletClosedException(org.apache.accumulo.tserver.tablet.TabletClosedException) KVEntry(org.apache.accumulo.tserver.tablet.KVEntry) Entry(java.util.Map.Entry) ConditionChecker(org.apache.accumulo.tserver.ConditionCheckerContext.ConditionChecker) IterationInterruptedException(org.apache.accumulo.core.iteratorsImpl.system.IterationInterruptedException) CompressedIterators(org.apache.accumulo.core.clientImpl.CompressedIterators) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Tablet(org.apache.accumulo.tserver.tablet.Tablet)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Collectors.toList (java.util.stream.Collectors.toList)1 CompressedIterators (org.apache.accumulo.core.clientImpl.CompressedIterators)1 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)1 TCMResult (org.apache.accumulo.core.dataImpl.thrift.TCMResult)1 TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)1 IterationInterruptedException (org.apache.accumulo.core.iteratorsImpl.system.IterationInterruptedException)1 TooManyFilesException (org.apache.accumulo.server.fs.TooManyFilesException)1 ConditionChecker (org.apache.accumulo.tserver.ConditionCheckerContext.ConditionChecker)1 ServerConditionalMutation (org.apache.accumulo.tserver.data.ServerConditionalMutation)1 KVEntry (org.apache.accumulo.tserver.tablet.KVEntry)1 Tablet (org.apache.accumulo.tserver.tablet.Tablet)1 TabletClosedException (org.apache.accumulo.tserver.tablet.TabletClosedException)1