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);
}
}
};
}
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);
}
}
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);
}
}
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);
}
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);
}
Aggregations