use of org.apache.cassandra.io.sstable.IndexSummaryRedistribution in project cassandra by apache.
the class ActiveCompactionsTest method testIndexSummaryRedistributionTracking.
@Test
public void testIndexSummaryRedistributionTracking() throws Throwable {
createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY KEY (pk, ck))");
getCurrentColumnFamilyStore().disableAutoCompaction();
for (int i = 0; i < 5; i++) {
execute("INSERT INTO %s (pk, ck, a, b) VALUES (" + i + ", 2, 3, 4)");
getCurrentColumnFamilyStore().forceBlockingFlush();
}
Set<SSTableReader> sstables = getCurrentColumnFamilyStore().getLiveSSTables();
try (LifecycleTransaction txn = getCurrentColumnFamilyStore().getTracker().tryModify(sstables, OperationType.INDEX_SUMMARY)) {
Map<TableId, LifecycleTransaction> transactions = ImmutableMap.<TableId, LifecycleTransaction>builder().put(getCurrentColumnFamilyStore().metadata().id, txn).build();
IndexSummaryRedistribution isr = new IndexSummaryRedistribution(transactions, 0, 1000);
MockActiveCompactions mockActiveCompactions = new MockActiveCompactions();
CompactionManager.instance.runIndexSummaryRedistribution(isr, mockActiveCompactions);
assertTrue(mockActiveCompactions.finished);
assertNotNull(mockActiveCompactions.holder);
// index redistribution operates over all keyspaces/tables, we always cancel them
assertTrue(mockActiveCompactions.holder.getCompactionInfo().getSSTables().isEmpty());
assertTrue(mockActiveCompactions.holder.getCompactionInfo().shouldStop((sstable) -> false));
}
}
use of org.apache.cassandra.io.sstable.IndexSummaryRedistribution in project cassandra by apache.
the class DiskSpaceMetricsTest method indexDownsampleCancelLastSSTable.
private static void indexDownsampleCancelLastSSTable(ColumnFamilyStore cfs) {
List<SSTableReader> sstables = Lists.newArrayList(cfs.getSSTables(SSTableSet.CANONICAL));
LifecycleTransaction txn = cfs.getTracker().tryModify(sstables, OperationType.UNKNOWN);
Map<TableId, LifecycleTransaction> txns = ImmutableMap.of(cfs.metadata.id, txn);
// fail on the last file (* 3 because we call isStopRequested 3 times for each sstable, and we should fail on the last)
AtomicInteger countdown = new AtomicInteger(3 * sstables.size() - 1);
IndexSummaryRedistribution redistribution = new IndexSummaryRedistribution(txns, 0, 0) {
public boolean isStopRequested() {
return countdown.decrementAndGet() == 0;
}
};
try {
IndexSummaryManager.redistributeSummaries(redistribution);
Assert.fail("Should throw CompactionInterruptedException");
} catch (CompactionInterruptedException e) {
// trying to get this to happen
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
FBUtilities.closeAll(txns.values());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
use of org.apache.cassandra.io.sstable.IndexSummaryRedistribution in project cassandra by apache.
the class EntireSSTableStreamConcurrentComponentMutationTest method indexSummaryRedistribution.
private boolean indexSummaryRedistribution() throws IOException {
long nonRedistributingOffHeapSize = 0;
long memoryPoolBytes = 1024 * 1024;
// rewrite index summary file with new min/max index interval
TableMetadata origin = store.metadata();
MigrationManager.announceTableUpdate(origin.unbuild().minIndexInterval(1).maxIndexInterval(2).build(), true);
try (LifecycleTransaction txn = store.getTracker().tryModify(sstable, OperationType.INDEX_SUMMARY)) {
IndexSummaryManager.redistributeSummaries(new IndexSummaryRedistribution(ImmutableMap.of(store.metadata().id, txn), nonRedistributingOffHeapSize, memoryPoolBytes));
}
// reset min/max index interval
MigrationManager.announceTableUpdate(origin, true);
return true;
}
Aggregations