Search in sources :

Example 1 with TInfo

use of org.apache.accumulo.core.trace.thrift.TInfo in project accumulo by apache.

the class ReplicationOperationsImplIT method getReplicationOperations.

/**
 * Spoof out the Master so we can call the implementation without starting a full instance.
 */
private ReplicationOperationsImpl getReplicationOperations() throws Exception {
    Master master = EasyMock.createMock(Master.class);
    EasyMock.expect(master.getConnector()).andReturn(conn).anyTimes();
    EasyMock.expect(master.getInstance()).andReturn(inst).anyTimes();
    EasyMock.replay(master);
    final MasterClientServiceHandler mcsh = new MasterClientServiceHandler(master) {

        @Override
        protected Table.ID getTableId(Instance inst, String tableName) throws ThriftTableOperationException {
            try {
                return Table.ID.of(conn.tableOperations().tableIdMap().get(tableName));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    };
    ClientContext context = new ClientContext(inst, new Credentials("root", new PasswordToken(ROOT_PASSWORD)), getClientConfig());
    return new ReplicationOperationsImpl(context) {

        @Override
        protected boolean getMasterDrain(final TInfo tinfo, final TCredentials rpcCreds, final String tableName, final Set<String> wals) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
            try {
                return mcsh.drainReplicationTable(tinfo, rpcCreds, tableName, wals);
            } catch (TException e) {
                throw new RuntimeException(e);
            }
        }
    };
}
Also used : TInfo(org.apache.accumulo.core.trace.thrift.TInfo) TException(org.apache.thrift.TException) MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) Table(org.apache.accumulo.core.client.impl.Table) ReplicationTable(org.apache.accumulo.core.replication.ReplicationTable) Set(java.util.Set) Instance(org.apache.accumulo.core.client.Instance) TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TException(org.apache.thrift.TException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) Master(org.apache.accumulo.master.Master) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) MasterClientServiceHandler(org.apache.accumulo.master.MasterClientServiceHandler) TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) Credentials(org.apache.accumulo.core.client.impl.Credentials) ReplicationOperationsImpl(org.apache.accumulo.core.client.impl.ReplicationOperationsImpl)

Example 2 with TInfo

use of org.apache.accumulo.core.trace.thrift.TInfo in project accumulo by apache.

the class ConditionalWriterImpl method sendToServer.

private void sendToServer(HostAndPort location, TabletServerMutations<QCMutation> mutations) {
    TabletClientService.Iface client = null;
    TInfo tinfo = Tracer.traceInfo();
    Map<Long, CMK> cmidToCm = new HashMap<>();
    MutableLong cmid = new MutableLong(0);
    SessionID sessionId = null;
    try {
        Map<TKeyExtent, List<TConditionalMutation>> tmutations = new HashMap<>();
        CompressedIterators compressedIters = new CompressedIterators();
        convertMutations(mutations, cmidToCm, cmid, tmutations, compressedIters);
        // getClient() call must come after converMutations in case it throws a TException
        client = getClient(location);
        List<TCMResult> tresults = null;
        while (tresults == null) {
            try {
                sessionId = reserveSessionID(location, client, tinfo);
                tresults = client.conditionalUpdate(tinfo, sessionId.sessionID, tmutations, compressedIters.getSymbolTable());
            } catch (NoSuchScanIDException nssie) {
                sessionId = null;
                invalidateSessionID(location);
            }
        }
        HashSet<KeyExtent> extentsToInvalidate = new HashSet<>();
        ArrayList<QCMutation> ignored = new ArrayList<>();
        for (TCMResult tcmResult : tresults) {
            if (tcmResult.status == TCMStatus.IGNORED) {
                CMK cmk = cmidToCm.get(tcmResult.cmid);
                ignored.add(cmk.cm);
                extentsToInvalidate.add(cmk.ke);
            } else {
                QCMutation qcm = cmidToCm.get(tcmResult.cmid).cm;
                qcm.queueResult(new Result(fromThrift(tcmResult.status), qcm, location.toString()));
            }
        }
        for (KeyExtent ke : extentsToInvalidate) {
            locator.invalidateCache(ke);
        }
        queueRetry(ignored, location);
    } catch (ThriftSecurityException tse) {
        AccumuloSecurityException ase = new AccumuloSecurityException(context.getCredentials().getPrincipal(), tse.getCode(), Tables.getPrintableTableInfoFromId(context.getInstance(), tableId), tse);
        queueException(location, cmidToCm, ase);
    } catch (TTransportException e) {
        locator.invalidateCache(context.getInstance(), location.toString());
        invalidateSession(location, mutations, cmidToCm, sessionId);
    } catch (TApplicationException tae) {
        queueException(location, cmidToCm, new AccumuloServerException(location.toString(), tae));
    } catch (TException e) {
        locator.invalidateCache(context.getInstance(), location.toString());
        invalidateSession(location, mutations, cmidToCm, sessionId);
    } catch (Exception e) {
        queueException(location, cmidToCm, e);
    } finally {
        if (sessionId != null)
            unreserveSessionID(location);
        ThriftUtil.returnClient((TServiceClient) client);
    }
}
Also used : TException(org.apache.thrift.TException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TTransportException(org.apache.thrift.transport.TTransportException) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) TCMResult(org.apache.accumulo.core.data.thrift.TCMResult) List(java.util.List) ArrayList(java.util.ArrayList) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) HashSet(java.util.HashSet) TInfo(org.apache.accumulo.core.trace.thrift.TInfo) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) TCMResult(org.apache.accumulo.core.data.thrift.TCMResult) NoSuchScanIDException(org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException) TableOfflineException(org.apache.accumulo.core.client.TableOfflineException) TTransportException(org.apache.thrift.transport.TTransportException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NoSuchScanIDException(org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException) VisibilityParseException(org.apache.accumulo.core.security.VisibilityParseException) BadArgumentException(org.apache.accumulo.core.util.BadArgumentException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) TimedOutException(org.apache.accumulo.core.client.TimedOutException) TableDeletedException(org.apache.accumulo.core.client.TableDeletedException) 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) TApplicationException(org.apache.thrift.TApplicationException) MutableLong(org.apache.commons.lang.mutable.MutableLong) MutableLong(org.apache.commons.lang.mutable.MutableLong) TabletClientService(org.apache.accumulo.core.tabletserver.thrift.TabletClientService)

Example 3 with TInfo

use of org.apache.accumulo.core.trace.thrift.TInfo in project accumulo by apache.

the class ConditionalWriterImpl method invalidateSession.

private void invalidateSession(long sessionId, HostAndPort location) throws TException {
    TabletClientService.Iface client = null;
    TInfo tinfo = Tracer.traceInfo();
    try {
        client = getClient(location);
        client.invalidateConditionalUpdate(tinfo, sessionId);
    } finally {
        ThriftUtil.returnClient((TServiceClient) client);
    }
}
Also used : TInfo(org.apache.accumulo.core.trace.thrift.TInfo) TabletClientService(org.apache.accumulo.core.tabletserver.thrift.TabletClientService)

Example 4 with TInfo

use of org.apache.accumulo.core.trace.thrift.TInfo in project accumulo by apache.

the class Gatherer method gather.

public Future<SummaryCollection> gather(ExecutorService es) {
    int numFiles;
    try {
        numFiles = countFiles();
    } catch (TableNotFoundException | AccumuloException | AccumuloSecurityException e) {
        throw new RuntimeException(e);
    }
    log.debug("Gathering summaries from {} files", numFiles);
    if (numFiles == 0) {
        return CompletableFuture.completedFuture(new SummaryCollection());
    }
    // have each tablet server process ~100K files
    int numRequest = Math.max(numFiles / 100_000, 1);
    List<CompletableFuture<SummaryCollection>> futures = new ArrayList<>();
    AtomicBoolean cancelFlag = new AtomicBoolean(false);
    TInfo tinfo = Tracer.traceInfo();
    for (int i = 0; i < numRequest; i++) {
        futures.add(CompletableFuture.supplyAsync(new GatherRequest(tinfo, i, numRequest, cancelFlag), es));
    }
    Future<SummaryCollection> future = CompletableFutureUtil.merge(futures, (sc1, sc2) -> SummaryCollection.merge(sc1, sc2, factory), SummaryCollection::new);
    return new CancelFlagFuture<>(future, cancelFlag);
}
Also used : TInfo(org.apache.accumulo.core.trace.thrift.TInfo) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ArrayList(java.util.ArrayList) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) CancelFlagFuture(org.apache.accumulo.core.util.CancelFlagFuture) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException)

Example 5 with TInfo

use of org.apache.accumulo.core.trace.thrift.TInfo in project accumulo by apache.

the class VerifyTabletAssignments method checkTabletServer.

private static void checkTabletServer(ClientContext context, Entry<HostAndPort, List<KeyExtent>> entry, HashSet<KeyExtent> failures) throws ThriftSecurityException, TException, NoSuchScanIDException {
    TabletClientService.Iface client = ThriftUtil.getTServerClient(entry.getKey(), context);
    Map<TKeyExtent, List<TRange>> batch = new TreeMap<>();
    for (KeyExtent keyExtent : entry.getValue()) {
        Text row = keyExtent.getEndRow();
        Text row2 = null;
        if (row == null) {
            row = keyExtent.getPrevEndRow();
            if (row != null) {
                row = new Text(row);
                row.append(new byte[] { 'a' }, 0, 1);
            } else {
                row = new Text("1234567890");
            }
            row2 = new Text(row);
            row2.append(new byte[] { '!' }, 0, 1);
        } else {
            row = new Text(row);
            row2 = new Text(row);
            row.getBytes()[row.getLength() - 1] = (byte) (row.getBytes()[row.getLength() - 1] - 1);
        }
        Range r = new Range(row, true, row2, false);
        batch.put(keyExtent.toThrift(), Collections.singletonList(r.toThrift()));
    }
    TInfo tinfo = Tracer.traceInfo();
    Map<String, Map<String, String>> emptyMapSMapSS = Collections.emptyMap();
    List<IterInfo> emptyListIterInfo = Collections.emptyList();
    List<TColumn> emptyListColumn = Collections.emptyList();
    InitialMultiScan is = client.startMultiScan(tinfo, context.rpcCreds(), batch, emptyListColumn, emptyListIterInfo, emptyMapSMapSS, Authorizations.EMPTY.getAuthorizationsBB(), false, null, 0L, null);
    if (is.result.more) {
        MultiScanResult result = client.continueMultiScan(tinfo, is.scanID);
        checkFailures(entry.getKey(), failures, result);
        while (result.more) {
            result = client.continueMultiScan(tinfo, is.scanID);
            checkFailures(entry.getKey(), failures, result);
        }
    }
    client.closeMultiScan(tinfo, is.scanID);
    ThriftUtil.returnClient((TServiceClient) client);
}
Also used : TInfo(org.apache.accumulo.core.trace.thrift.TInfo) TColumn(org.apache.accumulo.core.data.thrift.TColumn) InitialMultiScan(org.apache.accumulo.core.data.thrift.InitialMultiScan) Text(org.apache.hadoop.io.Text) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) TreeMap(java.util.TreeMap) TRange(org.apache.accumulo.core.data.thrift.TRange) Range(org.apache.accumulo.core.data.Range) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) MultiScanResult(org.apache.accumulo.core.data.thrift.MultiScanResult) ArrayList(java.util.ArrayList) List(java.util.List) TabletClientService(org.apache.accumulo.core.tabletserver.thrift.TabletClientService) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

TInfo (org.apache.accumulo.core.trace.thrift.TInfo)8 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)5 TabletClientService (org.apache.accumulo.core.tabletserver.thrift.TabletClientService)5 ArrayList (java.util.ArrayList)4 AccumuloException (org.apache.accumulo.core.client.AccumuloException)4 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)3 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)3 TException (org.apache.thrift.TException)3 List (java.util.List)2 Key (org.apache.accumulo.core.data.Key)2 KeyValue (org.apache.accumulo.core.data.KeyValue)2 PartialKey (org.apache.accumulo.core.data.PartialKey)2 Range (org.apache.accumulo.core.data.Range)2 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)2 InitialScan (org.apache.accumulo.core.data.thrift.InitialScan)2 TKeyExtent (org.apache.accumulo.core.data.thrift.TKeyExtent)2 TKeyValue (org.apache.accumulo.core.data.thrift.TKeyValue)2 TCredentials (org.apache.accumulo.core.security.thrift.TCredentials)2 HostAndPort (org.apache.accumulo.core.util.HostAndPort)2 TApplicationException (org.apache.thrift.TApplicationException)2