Search in sources :

Example 1 with TExternalCompaction

use of org.apache.accumulo.core.compaction.thrift.TExternalCompaction in project accumulo by apache.

the class ExternalCompactionTestUtils method confirmCompactionCompleted.

public static void confirmCompactionCompleted(ServerContext ctx, Set<ExternalCompactionId> ecids, TCompactionState expectedState) throws Exception {
    // The running compaction should be removed
    TExternalCompactionList running = ExternalCompactionTestUtils.getRunningCompactions(ctx);
    while (running.getCompactions() != null) {
        running = ExternalCompactionTestUtils.getRunningCompactions(ctx);
        if (running.getCompactions() == null) {
            UtilWaitThread.sleep(250);
        }
    }
    // The compaction should be in the completed list with the expected state
    TExternalCompactionList completed = ExternalCompactionTestUtils.getCompletedCompactions(ctx);
    while (completed.getCompactions() == null) {
        completed = ExternalCompactionTestUtils.getCompletedCompactions(ctx);
        if (completed.getCompactions() == null) {
            UtilWaitThread.sleep(50);
        }
    }
    for (ExternalCompactionId e : ecids) {
        TExternalCompaction tec = completed.getCompactions().get(e.canonical());
        assertNotNull(tec);
        assertEquals(expectedState, ExternalCompactionTestUtils.getLastState(tec));
    }
}
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)

Example 2 with TExternalCompaction

use of org.apache.accumulo.core.compaction.thrift.TExternalCompaction in project accumulo by apache.

the class ExternalCompaction_3_IT method testCoordinatorRestartsDuringCompaction.

@Test
public void testCoordinatorRestartsDuringCompaction() throws Exception {
    getCluster().getClusterControl().startCoordinator(CompactionCoordinator.class);
    getCluster().getClusterControl().startCompactors(ExternalDoNothingCompactor.class, 1, QUEUE2);
    String table1 = this.getUniqueNames(1)[0];
    try (AccumuloClient client = Accumulo.newClient().from(getCluster().getClientProperties()).build()) {
        createTable(client, table1, "cs2", 2);
        writeData(client, table1);
        compact(client, table1, 2, QUEUE2, false);
        TableId tid = getCluster().getServerContext().getTableId(table1);
        // Wait for the compaction to start by waiting for 1 external compaction column
        Set<ExternalCompactionId> ecids = waitForCompactionStartAndReturnEcids(getCluster().getServerContext(), tid);
        // Stop the Coordinator
        getCluster().getClusterControl().stop(ServerType.COMPACTION_COORDINATOR);
        // Restart the coordinator while the compaction is running
        getCluster().getClusterControl().startCoordinator(CompactionCoordinator.class);
        // Confirm compaction is still running
        int matches = 0;
        while (matches == 0) {
            TExternalCompactionList running = getRunningCompactions(getCluster().getServerContext());
            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.IN_PROGRESS, getLastState(tec));
                    }
                }
            }
            UtilWaitThread.sleep(250);
        }
        assertTrue(matches > 0);
        // We need to cancel the compaction or delete the table here because we initiate a user
        // compaction above in the test. Even though the external compaction was cancelled
        // because we split the table, FaTE will continue to queue up a compaction
        client.tableOperations().cancelCompaction(table1);
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) TableId(org.apache.accumulo.core.data.TableId) ExternalCompactionId(org.apache.accumulo.core.metadata.schema.ExternalCompactionId) TExternalCompactionList(org.apache.accumulo.core.compaction.thrift.TExternalCompactionList) TExternalCompaction(org.apache.accumulo.core.compaction.thrift.TExternalCompaction) Test(org.junit.Test)

Example 3 with TExternalCompaction

use of org.apache.accumulo.core.compaction.thrift.TExternalCompaction in project accumulo by apache.

the class CompactionCoordinator method getRunningCompactions.

/**
 * Return information about running compactions
 *
 * @param tinfo
 *          trace info
 * @param credentials
 *          tcredentials object
 * @return map of ECID to TExternalCompaction objects
 * @throws ThriftSecurityException
 *           permission error
 */
@Override
public TExternalCompactionList getRunningCompactions(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();
    RUNNING.forEach((ecid, rc) -> {
        TExternalCompaction trc = new TExternalCompaction();
        trc.setQueueName(rc.getQueueName());
        trc.setCompactor(rc.getCompactorAddress());
        trc.setUpdates(rc.getUpdates());
        trc.setJob(rc.getJob());
        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 4 with TExternalCompaction

use of org.apache.accumulo.core.compaction.thrift.TExternalCompaction 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 5 with TExternalCompaction

use of org.apache.accumulo.core.compaction.thrift.TExternalCompaction 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

TExternalCompaction (org.apache.accumulo.core.compaction.thrift.TExternalCompaction)5 TExternalCompactionList (org.apache.accumulo.core.compaction.thrift.TExternalCompactionList)5 ExternalCompactionId (org.apache.accumulo.core.metadata.schema.ExternalCompactionId)3 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)2 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)1 TableId (org.apache.accumulo.core.data.TableId)1 Test (org.junit.Test)1