use of org.apache.accumulo.core.compaction.thrift.TExternalCompactionList in project accumulo by apache.
the class MiniAccumuloClusterControl method startCoordinator.
@Override
public synchronized void startCoordinator(Class<? extends CompactionCoordinator> coordinator) throws IOException {
if (coordinatorProcess == null) {
coordinatorProcess = cluster._exec(coordinator, ServerType.COMPACTION_COORDINATOR, new HashMap<>()).getProcess();
// Wait for coordinator to start
TExternalCompactionList metrics = null;
while (metrics == null) {
try {
metrics = getRunningCompactions(cluster.getServerContext());
} catch (TException e) {
log.debug("Error getting running compactions from coordinator, message: " + e.getMessage());
UtilWaitThread.sleep(250);
}
}
}
}
use of org.apache.accumulo.core.compaction.thrift.TExternalCompactionList in project accumulo by apache.
the class ECAdmin method runningCompactions.
private void runningCompactions(ServerContext context, boolean details) {
CompactionCoordinatorService.Client coordinatorClient = null;
TExternalCompactionList running;
try {
coordinatorClient = getCoordinatorClient(context);
running = coordinatorClient.getRunningCompactions(TraceUtil.traceInfo(), context.rpcCreds());
if (running == null) {
System.out.println("No running compactions found.");
return;
}
var ecidMap = running.getCompactions();
if (ecidMap == null) {
System.out.println("No running compactions found.");
return;
}
ecidMap.forEach((ecid, ec) -> {
if (ec != null) {
var runningCompaction = new RunningCompaction(ec);
var addr = runningCompaction.getCompactorAddress();
var kind = runningCompaction.getJob().kind;
var queue = runningCompaction.getQueueName();
var ke = KeyExtent.fromThrift(runningCompaction.getJob().extent);
System.out.format("%s %s %s %s TableId: %s\n", ecid, addr, kind, queue, ke.tableId());
if (details) {
var runningCompactionInfo = new RunningCompactionInfo(ec);
var status = runningCompactionInfo.status;
var last = runningCompactionInfo.lastUpdate;
var duration = runningCompactionInfo.duration;
var numFiles = runningCompactionInfo.numFiles;
var progress = runningCompactionInfo.progress;
System.out.format(" %s Last Update: %dms Duration: %dms Files: %d Progress: %.2f%%\n", status, last, duration, numFiles, progress);
}
}
});
} catch (Exception e) {
throw new RuntimeException("Unable to get running compactions.", e);
} finally {
ThriftUtil.returnClient(coordinatorClient, context);
}
}
use of org.apache.accumulo.core.compaction.thrift.TExternalCompactionList in project accumulo by apache.
the class CompactionCoordinator method getCompletedCompactions.
/**
* Return information about recently completed compactions
*
* @param tinfo
* trace info
* @param credentials
* tcredentials object
* @return map of ECID to TExternalCompaction objects
* @throws ThriftSecurityException
* permission error
*/
@Override
public TExternalCompactionList getCompletedCompactions(TInfo tinfo, TCredentials credentials) throws ThriftSecurityException {
// do not expect users to call this directly, expect other tservers to call this method
if (!security.canPerformSystemActions(credentials)) {
throw new AccumuloSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED).asThriftException();
}
final TExternalCompactionList result = new TExternalCompactionList();
COMPLETED.asMap().forEach((ecid, rc) -> {
TExternalCompaction trc = new TExternalCompaction();
trc.setQueueName(rc.getQueueName());
trc.setCompactor(rc.getCompactorAddress());
trc.setJob(rc.getJob());
trc.setUpdates(rc.getUpdates());
result.putToCompactions(ecid.canonical(), trc);
});
return result;
}
use of org.apache.accumulo.core.compaction.thrift.TExternalCompactionList in project accumulo by apache.
the class ExternalCompactionTestUtils method getRunningCompactions.
public static TExternalCompactionList getRunningCompactions(ClientContext context) throws TException {
Optional<HostAndPort> coordinatorHost = ExternalCompactionUtil.findCompactionCoordinator(context);
if (coordinatorHost.isEmpty()) {
throw new TTransportException("Unable to get CompactionCoordinator address from ZooKeeper");
}
CompactionCoordinatorService.Client client = ThriftUtil.getClient(new CompactionCoordinatorService.Client.Factory(), coordinatorHost.get(), context);
try {
TExternalCompactionList running = client.getRunningCompactions(TraceUtil.traceInfo(), context.rpcCreds());
return running;
} finally {
ThriftUtil.returnClient(client, context);
}
}
use of org.apache.accumulo.core.compaction.thrift.TExternalCompactionList in project accumulo by apache.
the class ExternalCompactionTestUtils method confirmCompactionRunning.
public static int confirmCompactionRunning(ServerContext ctx, Set<ExternalCompactionId> ecids) throws Exception {
int matches = 0;
while (matches == 0) {
TExternalCompactionList running = ExternalCompactionTestUtils.getRunningCompactions(ctx);
if (running.getCompactions() != null) {
for (ExternalCompactionId ecid : ecids) {
TExternalCompaction tec = running.getCompactions().get(ecid.canonical());
if (tec != null && tec.getUpdates() != null && !tec.getUpdates().isEmpty()) {
matches++;
assertEquals(TCompactionState.STARTED, ExternalCompactionTestUtils.getLastState(tec));
}
}
}
if (matches == 0) {
UtilWaitThread.sleep(50);
}
}
return matches;
}
Aggregations