use of org.apache.accumulo.test.compaction.ExternalCompactionTestUtils.confirmCompactionRunning in project accumulo by apache.
the class ExternalCompaction_2_IT method testSplitCancelsExternalCompaction.
@Test
public void testSplitCancelsExternalCompaction() throws Exception {
getCluster().getClusterControl().startCoordinator(CompactionCoordinator.class);
getCluster().getClusterControl().startCompactors(ExternalDoNothingCompactor.class, 1, QUEUE1);
String table1 = this.getUniqueNames(1)[0];
try (AccumuloClient client = Accumulo.newClient().from(getCluster().getClientProperties()).build()) {
createTable(client, table1, "cs1");
TableId tid = getCluster().getServerContext().getTableId(table1);
writeData(client, table1);
compact(client, table1, 2, QUEUE1, false);
// Wait for the compaction to start by waiting for 1 external compaction column
Set<ExternalCompactionId> ecids = ExternalCompactionTestUtils.waitForCompactionStartAndReturnEcids(getCluster().getServerContext(), tid);
// Confirm that this ECID shows up in RUNNING set
int matches = ExternalCompactionTestUtils.confirmCompactionRunning(getCluster().getServerContext(), ecids);
assertTrue(matches > 0);
// ExternalDoNothingCompactor will not compact, it will wait, split the table.
SortedSet<Text> splits = new TreeSet<>();
int jump = MAX_DATA / 5;
for (int r = jump; r < MAX_DATA; r += jump) {
splits.add(new Text(row(r)));
}
client.tableOperations().addSplits(table1, splits);
confirmCompactionCompleted(getCluster().getServerContext(), ecids, TCompactionState.CANCELLED);
// ensure compaction ids were deleted by split operation from metadata table
try (TabletsMetadata tm = getCluster().getServerContext().getAmple().readTablets().forTable(tid).fetch(ColumnType.ECOMP).build()) {
Set<ExternalCompactionId> ecids2 = tm.stream().flatMap(t -> t.getExternalCompactions().keySet().stream()).collect(Collectors.toSet());
assertTrue(Collections.disjoint(ecids, ecids2));
}
// 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);
}
}
Aggregations