use of org.apache.accumulo.core.metadata.schema.ExternalCompactionId in project accumulo by apache.
the class ServerAmpleImpl method deleteExternalCompactionFinalStates.
@Override
public void deleteExternalCompactionFinalStates(Collection<ExternalCompactionId> statusesToDelete) {
try (BatchWriter writer = context.createBatchWriter(DataLevel.USER.metaTable())) {
String prefix = ExternalCompactionSection.getRowPrefix();
for (ExternalCompactionId ecid : statusesToDelete) {
Mutation m = new Mutation(prefix + ecid.canonical());
m.putDelete(EMPTY_TEXT, EMPTY_TEXT);
writer.addMutation(m);
}
log.debug("Deleted external compaction final state entries for external compactions: {}", statusesToDelete);
} catch (MutationsRejectedException | TableNotFoundException e) {
throw new RuntimeException(e);
}
}
use of org.apache.accumulo.core.metadata.schema.ExternalCompactionId in project accumulo by apache.
the class CompactorTest method testCompactionSucceeds.
@Test
public void testCompactionSucceeds() throws Exception {
UUID uuid = UUID.randomUUID();
Supplier<UUID> supplier = () -> uuid;
ExternalCompactionId eci = ExternalCompactionId.generate(supplier.get());
PowerMock.resetAll();
PowerMock.suppress(PowerMock.methods(Halt.class, "halt"));
PowerMock.suppress(PowerMock.constructor(AbstractServer.class));
ServerAddress client = PowerMock.createNiceMock(ServerAddress.class);
HostAndPort address = HostAndPort.fromString("localhost:10240");
EasyMock.expect(client.getAddress()).andReturn(address);
TExternalCompactionJob job = PowerMock.createNiceMock(TExternalCompactionJob.class);
TKeyExtent extent = PowerMock.createNiceMock(TKeyExtent.class);
EasyMock.expect(job.isSetExternalCompactionId()).andReturn(true).anyTimes();
EasyMock.expect(job.getExternalCompactionId()).andReturn(eci.toString()).anyTimes();
EasyMock.expect(job.getExtent()).andReturn(extent).anyTimes();
EasyMock.expect(extent.getTable()).andReturn("testTable".getBytes()).anyTimes();
AccumuloConfiguration conf = PowerMock.createNiceMock(AccumuloConfiguration.class);
EasyMock.expect(conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT)).andReturn(86400000L);
ServerContext context = PowerMock.createNiceMock(ServerContext.class);
EasyMock.expect(context.getConfiguration()).andReturn(conf);
ZooReaderWriter zrw = PowerMock.createNiceMock(ZooReaderWriter.class);
ZooKeeper zk = PowerMock.createNiceMock(ZooKeeper.class);
EasyMock.expect(context.getZooReaderWriter()).andReturn(zrw).anyTimes();
EasyMock.expect(zrw.getZooKeeper()).andReturn(zk).anyTimes();
VolumeManagerImpl vm = PowerMock.createNiceMock(VolumeManagerImpl.class);
EasyMock.expect(context.getVolumeManager()).andReturn(vm);
vm.close();
PowerMock.replayAll();
SuccessfulCompactor c = new SuccessfulCompactor(supplier, client, job, conf, context, eci);
c.run();
PowerMock.verifyAll();
c.close();
assertTrue(c.isCompletedCalled());
assertFalse(c.isFailedCalled());
}
use of org.apache.accumulo.core.metadata.schema.ExternalCompactionId 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));
}
}
use of org.apache.accumulo.core.metadata.schema.ExternalCompactionId 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);
}
}
use of org.apache.accumulo.core.metadata.schema.ExternalCompactionId in project accumulo by apache.
the class ExternalCompaction_2_IT method testUserCompactionCancellation.
@Test
public void testUserCompactionCancellation() throws Exception {
getCluster().getClusterControl().startCoordinator(CompactionCoordinator.class);
getCluster().getClusterControl().startCompactors(ExternalDoNothingCompactor.class, 1, QUEUE3);
String table1 = this.getUniqueNames(1)[0];
try (AccumuloClient client = Accumulo.newClient().from(getCluster().getClientProperties()).build()) {
createTable(client, table1, "cs3");
TableId tid = getCluster().getServerContext().getTableId(table1);
writeData(client, table1);
compact(client, table1, 2, QUEUE3, 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);
client.tableOperations().cancelCompaction(table1);
confirmCompactionCompleted(getCluster().getServerContext(), ecids, TCompactionState.CANCELLED);
// 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