Search in sources :

Example 6 with TExternalCompactionList

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);
            }
        }
    }
}
Also used : TException(org.apache.thrift.TException) TExternalCompactionList(org.apache.accumulo.core.compaction.thrift.TExternalCompactionList)

Example 7 with TExternalCompactionList

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);
    }
}
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 8 with TExternalCompactionList

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;
}
Also used : TExternalCompactionList(org.apache.accumulo.core.compaction.thrift.TExternalCompactionList) TExternalCompaction(org.apache.accumulo.core.compaction.thrift.TExternalCompaction) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException)

Example 9 with TExternalCompactionList

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);
    }
}
Also used : HostAndPort(org.apache.accumulo.core.util.HostAndPort) CompactionCoordinatorService(org.apache.accumulo.core.compaction.thrift.CompactionCoordinatorService) TExternalCompactionList(org.apache.accumulo.core.compaction.thrift.TExternalCompactionList) TTransportException(org.apache.thrift.transport.TTransportException) AccumuloClient(org.apache.accumulo.core.client.AccumuloClient)

Example 10 with TExternalCompactionList

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;
}
Also used : TExternalCompactionList(org.apache.accumulo.core.compaction.thrift.TExternalCompactionList) ExternalCompactionId(org.apache.accumulo.core.metadata.schema.ExternalCompactionId) TExternalCompaction(org.apache.accumulo.core.compaction.thrift.TExternalCompaction)

Aggregations

TExternalCompactionList (org.apache.accumulo.core.compaction.thrift.TExternalCompactionList)11 TExternalCompaction (org.apache.accumulo.core.compaction.thrift.TExternalCompaction)5 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)4 ExternalCompactionId (org.apache.accumulo.core.metadata.schema.ExternalCompactionId)4 CompactionCoordinatorService (org.apache.accumulo.core.compaction.thrift.CompactionCoordinatorService)3 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)2 TableId (org.apache.accumulo.core.data.TableId)2 HostAndPort (org.apache.accumulo.core.util.HostAndPort)2 TTransportException (org.apache.thrift.transport.TTransportException)2 Test (org.junit.Test)2 UnknownHostException (java.net.UnknownHostException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 RunningCompaction (org.apache.accumulo.core.util.compaction.RunningCompaction)1 RunningCompactionInfo (org.apache.accumulo.core.util.compaction.RunningCompactionInfo)1 UtilWaitThread (org.apache.accumulo.fate.util.UtilWaitThread)1 TException (org.apache.thrift.TException)1 KeeperException (org.apache.zookeeper.KeeperException)1