public static SweepTableFactory of(Namespace namespace) { return of(ImmutableList.<Function<? super Transaction, SharedTriggers>>of(), namespace); }
public static SweepTableFactory of() { return of(ImmutableList.<Function<? super Transaction, SharedTriggers>>of(), defaultNamespace); }
private static SpecificTableSweeper initializeSweepEndpoint( Consumer<Object> env, KeyValueService kvs, TransactionManager transactionManager, SweepTaskRunner sweepRunner, BackgroundSweeperPerformanceLogger sweepPerfLogger, LegacySweepMetrics sweepMetrics, boolean initializeAsync, AdjustableSweepBatchConfigSource sweepBatchConfigSource) { SpecificTableSweeper specificTableSweeper = SpecificTableSweeper.create( transactionManager, kvs, sweepRunner, SweepTableFactory.of(), sweepPerfLogger, sweepMetrics, initializeAsync); env.accept(new SweeperServiceImpl(specificTableSweeper, sweepBatchConfigSource)); return specificTableSweeper; }
Map<String, Long> getHistory(Transaction tx) { Map<String, Long> tableToLastTimeSwept = new HashMap<>(); SweepPriorityTable sweepPriorityTable = SweepTableFactory.of().getSweepPriorityTable(tx); sweepPriorityTable.getRange(RangeRequest.builder() .retainColumns(SweepPriorityTable.getColumnSelection(SweepPriorityNamedColumn.LAST_SWEEP_TIME)) .batchHint(READ_BATCH_SIZE) .build()) .forEach(row -> { Long lastSweepTime = row.getLastSweepTime(); String tableName = row.getRowName().getFullTableName(); tableToLastTimeSwept.put(tableName, lastSweepTime); }); return tableToLastTimeSwept; } }
@Before public void setup() { exec = PTExecutors.newCachedThreadPool(); KeyValueService kvs = new InMemoryKeyValueService(false, exec); txManager = SweepTestUtils.setupTxManager(kvs); priorityStore = SweepPriorityStoreImpl.create(kvs, SweepTableFactory.of(), false); }
@Test public void smokeTest() throws Exception { createTable(TABLE_1, SweepStrategy.CONSERVATIVE); createTable(TABLE_2, SweepStrategy.THOROUGH); createTable(TABLE_3, SweepStrategy.NOTHING); putManyCells(TABLE_1, 100, 110); putManyCells(TABLE_1, 103, 113); putManyCells(TABLE_1, 105, 115); putManyCells(TABLE_2, 101, 111); putManyCells(TABLE_2, 104, 114); putManyCells(TABLE_3, 120, 130); try (SingleLockService sweepLocks = backgroundSweeper.createSweepLocks()) { for (int i = 0; i < 50; ++i) { backgroundSweeper.checkConfigAndRunSweep(sweepLocks); } } verifyTableSwept(TABLE_1, 75, true); verifyTableSwept(TABLE_2, 58, false); List<SweepPriority> priorities = txManager.runTaskReadOnly( tx -> SweepPriorityStoreImpl.create(kvs, SweepTableFactory.of(), false).loadNewPriorities(tx)); Assert.assertTrue(priorities.stream().anyMatch(p -> p.tableRef().equals(TABLE_1))); Assert.assertTrue(priorities.stream().anyMatch(p -> p.tableRef().equals(TABLE_2))); }
SweepPriorityTable priorityTable = SweepTableFactory.of().getSweepPriorityTable(t); SweepPriorityTable.SweepPriorityRow row1 = SweepPriorityTable.SweepPriorityRow.of( tableToSweep.getQualifiedName());
public static SweepTableFactory of() { return of(ImmutableList.<Function<? super Transaction, SharedTriggers>>of(), defaultNamespace); }
public static SweepTableFactory of(Namespace namespace) { return of(ImmutableList.<Function<? super Transaction, SharedTriggers>>of(), namespace); }
kvs, sweepRunner, SweepTableFactory.of(), new NoOpBackgroundSweeperPerformanceLogger(), sweepMetrics,
private static SpecificTableSweeper initializeSweepEndpoint( Consumer<Object> env, KeyValueService kvs, TransactionManager transactionManager, SweepTaskRunner sweepRunner, BackgroundSweeperPerformanceLogger sweepPerfLogger, LegacySweepMetrics sweepMetrics, boolean initializeAsync, AdjustableSweepBatchConfigSource sweepBatchConfigSource) { SpecificTableSweeper specificTableSweeper = SpecificTableSweeper.create( transactionManager, kvs, sweepRunner, SweepTableFactory.of(), sweepPerfLogger, sweepMetrics, initializeAsync); env.accept(new SweeperServiceImpl(specificTableSweeper, sweepBatchConfigSource)); return specificTableSweeper; }
Map<String, Long> getHistory(Transaction tx) { Map<String, Long> tableToLastTimeSwept = new HashMap<>(); SweepPriorityTable sweepPriorityTable = SweepTableFactory.of().getSweepPriorityTable(tx); sweepPriorityTable.getRange(RangeRequest.builder() .retainColumns(SweepPriorityTable.getColumnSelection(SweepPriorityNamedColumn.LAST_SWEEP_TIME)) .batchHint(READ_BATCH_SIZE) .build()) .forEach(row -> { Long lastSweepTime = row.getLastSweepTime(); String tableName = row.getRowName().getFullTableName(); tableToLastTimeSwept.put(tableName, lastSweepTime); }); return tableToLastTimeSwept; } }
@Test public void smokeTest() throws Exception { createTable(TABLE_1, SweepStrategy.CONSERVATIVE); createTable(TABLE_2, SweepStrategy.THOROUGH); createTable(TABLE_3, SweepStrategy.NOTHING); putManyCells(TABLE_1, 100, 110); putManyCells(TABLE_1, 103, 113); putManyCells(TABLE_1, 105, 115); putManyCells(TABLE_2, 101, 111); putManyCells(TABLE_2, 104, 114); putManyCells(TABLE_3, 120, 130); try (SingleLockService sweepLocks = backgroundSweeper.createSweepLocks()) { for (int i = 0; i < 50; ++i) { backgroundSweeper.checkConfigAndRunSweep(sweepLocks); } } verifyTableSwept(TABLE_1, 75, true); verifyTableSwept(TABLE_2, 58, false); List<SweepPriority> priorities = txManager.runTaskReadOnly( tx -> SweepPriorityStoreImpl.create(kvs, SweepTableFactory.of(), false).loadNewPriorities(tx)); Assert.assertTrue(priorities.stream().anyMatch(p -> p.tableRef().equals(TABLE_1))); Assert.assertTrue(priorities.stream().anyMatch(p -> p.tableRef().equals(TABLE_2))); }
SweepPriorityTable priorityTable = SweepTableFactory.of().getSweepPriorityTable(t); SweepPriorityTable.SweepPriorityRow row1 = SweepPriorityTable.SweepPriorityRow.of( tableToSweep.getQualifiedName());
kvs, sweepRunner, SweepTableFactory.of(), new NoOpBackgroundSweeperPerformanceLogger(), sweepMetrics,