Search in sources :

Example 1 with RunningCompactionInfo

use of org.apache.accumulo.core.util.compaction.RunningCompactionInfo 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);
    }
}
Also used : CompactionCoordinatorService(org.apache.accumulo.core.compaction.thrift.CompactionCoordinatorService) TExternalCompactionList(org.apache.accumulo.core.compaction.thrift.TExternalCompactionList) RunningCompactionInfo(org.apache.accumulo.core.util.compaction.RunningCompactionInfo) RunningCompaction(org.apache.accumulo.core.util.compaction.RunningCompaction)

Example 2 with RunningCompactionInfo

use of org.apache.accumulo.core.util.compaction.RunningCompactionInfo in project accumulo by apache.

the class ExternalCompactionProgressIT method checkRunning.

/**
 * Check running compaction progress.
 */
private void checkRunning() throws TException {
    var ecList = getRunningCompactions(getCluster().getServerContext());
    var ecMap = ecList.getCompactions();
    if (ecMap != null) {
        ecMap.forEach((ecid, ec) -> {
            // returns null if it's a new mapping
            RunningCompactionInfo rci = new RunningCompactionInfo(ec);
            RunningCompactionInfo previousRci = runningMap.put(ecid, rci);
            if (previousRci == null) {
                log.debug("New ECID {} with inputFiles: {}", ecid, rci.numFiles);
            } else {
                if (rci.progress <= previousRci.progress) {
                    log.warn("{} did not progress. It went from {} to {}", ecid, previousRci.progress, rci.progress);
                } else {
                    log.debug("{} progressed from {} to {}", ecid, previousRci.progress, rci.progress);
                    if (rci.progress > 0 && rci.progress <= 25)
                        progressList.add(EC_PROGRESS.STARTED);
                    else if (rci.progress > 25 && rci.progress <= 50)
                        progressList.add(EC_PROGRESS.QUARTER);
                    else if (rci.progress > 50 && rci.progress <= 75)
                        progressList.add(EC_PROGRESS.HALF);
                    else if (rci.progress > 75 && rci.progress <= 100)
                        progressList.add(EC_PROGRESS.THREE_QUARTERS);
                }
                if (!rci.status.equals(TCompactionState.IN_PROGRESS.name())) {
                    log.debug("Saw status other than IN_PROGRESS: {}", rci.status);
                }
            }
        });
    }
}
Also used : RunningCompactionInfo(org.apache.accumulo.core.util.compaction.RunningCompactionInfo)

Aggregations

RunningCompactionInfo (org.apache.accumulo.core.util.compaction.RunningCompactionInfo)2 CompactionCoordinatorService (org.apache.accumulo.core.compaction.thrift.CompactionCoordinatorService)1 TExternalCompactionList (org.apache.accumulo.core.compaction.thrift.TExternalCompactionList)1 RunningCompaction (org.apache.accumulo.core.util.compaction.RunningCompaction)1