Search in sources :

Example 1 with TabletServerMutations

use of org.apache.accumulo.core.clientImpl.TabletLocator.TabletServerMutations in project accumulo by apache.

the class ConditionalWriterImpl method queue.

private void queue(List<QCMutation> mutations) {
    List<QCMutation> failures = new ArrayList<>();
    Map<String, TabletServerMutations<QCMutation>> binnedMutations = new HashMap<>();
    try {
        locator.binMutations(context, mutations, binnedMutations, failures);
        if (failures.size() == mutations.size()) {
            context.requireNotDeleted(tableId);
            context.requireNotOffline(tableId, tableName);
        }
    } catch (Exception e) {
        mutations.forEach(qcm -> qcm.queueResult(new Result(e, qcm, null)));
        // do not want to queue anything that was put in before binMutations() failed
        failures.clear();
        binnedMutations.clear();
    }
    if (!failures.isEmpty())
        queueRetry(failures, null);
    binnedMutations.forEach(this::queue);
}
Also used : TableId(org.apache.accumulo.core.data.TableId) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ThriftUtil(org.apache.accumulo.core.rpc.ThriftUtil) Arrays(java.util.Arrays) TTransportException(org.apache.thrift.transport.TTransportException) LRUMap(org.apache.commons.collections4.map.LRUMap) Text(org.apache.hadoop.io.Text) ByteBuffer(java.nio.ByteBuffer) VisibilityEvaluator(org.apache.accumulo.core.security.VisibilityEvaluator) TInfo(org.apache.accumulo.core.trace.thrift.TInfo) ConditionalMutation(org.apache.accumulo.core.data.ConditionalMutation) MutableLong(org.apache.commons.lang3.mutable.MutableLong) Map(java.util.Map) TCMResult(org.apache.accumulo.core.dataImpl.thrift.TCMResult) TabletClientService(org.apache.accumulo.core.tabletserver.thrift.TabletClientService) Delayed(java.util.concurrent.Delayed) TCondition(org.apache.accumulo.core.dataImpl.thrift.TCondition) NoSuchScanIDException(org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException) TServiceClient(org.apache.thrift.TServiceClient) VisibilityParseException(org.apache.accumulo.core.security.VisibilityParseException) TConditionalSession(org.apache.accumulo.core.dataImpl.thrift.TConditionalSession) ConditionalWriter(org.apache.accumulo.core.client.ConditionalWriter) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) BlockingQueue(java.util.concurrent.BlockingQueue) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Durability(org.apache.accumulo.core.client.Durability) TCMStatus(org.apache.accumulo.core.dataImpl.thrift.TCMStatus) ThreadPools(org.apache.accumulo.core.util.threads.ThreadPools) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Condition(org.apache.accumulo.core.data.Condition) BadArgumentException(org.apache.accumulo.core.util.BadArgumentException) List(java.util.List) ServiceLock(org.apache.accumulo.fate.zookeeper.ServiceLock) UtilWaitThread.sleepUninterruptibly(org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly) TraceUtil(org.apache.accumulo.core.trace.TraceUtil) ByteBufferUtil(org.apache.accumulo.core.util.ByteBufferUtil) TimedOutException(org.apache.accumulo.core.client.TimedOutException) HostAndPort(org.apache.accumulo.core.util.HostAndPort) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) HashMap(java.util.HashMap) Threads(org.apache.accumulo.core.util.threads.Threads) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LockID(org.apache.accumulo.fate.zookeeper.ZooUtil.LockID) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) DelayQueue(java.util.concurrent.DelayQueue) NoSuchElementException(java.util.NoSuchElementException) TApplicationException(org.apache.thrift.TApplicationException) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) TMutation(org.apache.accumulo.core.dataImpl.thrift.TMutation) TConditionalMutation(org.apache.accumulo.core.dataImpl.thrift.TConditionalMutation) Iterator(java.util.Iterator) UTF_8(java.nio.charset.StandardCharsets.UTF_8) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) TabletServerMutations(org.apache.accumulo.core.clientImpl.TabletLocator.TabletServerMutations) TException(org.apache.thrift.TException) Constants(org.apache.accumulo.core.Constants) Authorizations(org.apache.accumulo.core.security.Authorizations) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ConditionalWriterConfig(org.apache.accumulo.core.client.ConditionalWriterConfig) TimeUnit(java.util.concurrent.TimeUnit) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) Comparator(java.util.Comparator) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TTransportException(org.apache.thrift.transport.TTransportException) NoSuchScanIDException(org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException) VisibilityParseException(org.apache.accumulo.core.security.VisibilityParseException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) BadArgumentException(org.apache.accumulo.core.util.BadArgumentException) TimedOutException(org.apache.accumulo.core.client.TimedOutException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) NoSuchElementException(java.util.NoSuchElementException) TApplicationException(org.apache.thrift.TApplicationException) TException(org.apache.thrift.TException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) TabletServerMutations(org.apache.accumulo.core.clientImpl.TabletLocator.TabletServerMutations) TCMResult(org.apache.accumulo.core.dataImpl.thrift.TCMResult)

Example 2 with TabletServerMutations

use of org.apache.accumulo.core.clientImpl.TabletLocator.TabletServerMutations in project accumulo by apache.

the class TabletLocatorImplTest method runTest.

private void runTest(TabletLocatorImpl metaCache, List<Mutation> ml, Map<String, Map<KeyExtent, List<String>>> emb, String... efailures) throws Exception {
    Map<String, TabletServerMutations<Mutation>> binnedMutations = new HashMap<>();
    List<Mutation> afailures = new ArrayList<>();
    metaCache.binMutations(context, ml, binnedMutations, afailures);
    verify(emb, binnedMutations);
    ArrayList<String> afs = new ArrayList<>();
    ArrayList<String> efs = new ArrayList<>(Arrays.asList(efailures));
    for (Mutation mutation : afailures) {
        afs.add(new String(mutation.getRow()));
    }
    Collections.sort(afs);
    Collections.sort(efs);
    assertEquals(efs, afs);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Mutation(org.apache.accumulo.core.data.Mutation) TabletServerMutations(org.apache.accumulo.core.clientImpl.TabletLocator.TabletServerMutations)

Aggregations

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 TabletServerMutations (org.apache.accumulo.core.clientImpl.TabletLocator.TabletServerMutations)2 ByteBuffer (java.nio.ByteBuffer)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 DelayQueue (java.util.concurrent.DelayQueue)1 Delayed (java.util.concurrent.Delayed)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 TimeUnit (java.util.concurrent.TimeUnit)1