use of org.apache.cassandra.db.view.ViewBuilderTask in project cassandra by apache.
the class ActiveCompactionsTest method testViewBuildTracking.
@Test
public void testViewBuildTracking() throws Throwable {
createTable("CREATE TABLE %s (k1 int, c1 int , val int, PRIMARY KEY (k1, c1))");
getCurrentColumnFamilyStore().disableAutoCompaction();
for (int i = 0; i < 5; i++) {
execute("INSERT INTO %s (k1, c1, val) VALUES (" + i + ", 2, 3)");
getCurrentColumnFamilyStore().forceBlockingFlush();
}
execute(String.format("CREATE MATERIALIZED VIEW %s.view1 AS SELECT k1, c1, val FROM %s.%s WHERE k1 IS NOT NULL AND c1 IS NOT NULL AND val IS NOT NULL PRIMARY KEY (val, k1, c1)", keyspace(), keyspace(), currentTable()));
View view = Iterables.getOnlyElement(getCurrentColumnFamilyStore().viewManager);
Token token = DatabaseDescriptor.getPartitioner().getMinimumToken();
ViewBuilderTask vbt = new ViewBuilderTask(getCurrentColumnFamilyStore(), view, new Range<>(token, token), token, 0);
MockActiveCompactions mockActiveCompactions = new MockActiveCompactions();
CompactionManager.instance.submitViewBuilder(vbt, mockActiveCompactions).get();
assertTrue(mockActiveCompactions.finished);
assertTrue(mockActiveCompactions.holder.getCompactionInfo().getSSTables().isEmpty());
// this should stop for all compactions, even if it doesn't pick any sstables;
assertTrue(mockActiveCompactions.holder.getCompactionInfo().shouldStop((sstable) -> false));
}
Aggregations