@Test public void returnsTableWithBiggestSweepToCompactionPositiveTime() { when(sweepHistoryProvider.getHistory(mockTx)).thenReturn(ImmutableMap.of(TABLE_1, 5L, TABLE_2, 6L)); when(compactionHistoryProvider.getHistory(mockTx)).thenReturn(ImmutableMap.of(TABLE_1, 1L, TABLE_2, 4L)); Optional<String> table = calculator.selectTableToCompactInternal(mockTx); assertThat(table).isEqualTo(Optional.of(TABLE_1)); }
@VisibleForTesting Optional<String> selectTableToCompactInternal(Transaction tx) { Map<String, Long> tableToLastTimeSwept = sweepHistoryProvider.getHistory(tx); Map<String, Long> tableToLastTimeCompacted = compactionHistoryProvider.getHistory(tx); Optional<String> tableToCompact = maybeChooseUncompactedTable(tableToLastTimeSwept, tableToLastTimeCompacted); if (!tableToCompact.isPresent()) { tableToCompact = maybeChooseTableSweptAfterCompact(tableToLastTimeSwept, tableToLastTimeCompacted); } if (!tableToCompact.isPresent()) { tableToCompact = maybeChooseTableCompactedOver1HourAgo(tableToLastTimeCompacted); } if (!tableToCompact.isPresent()) { log.info("Not compacting, because it does not appear that any table has been swept" + " or they were compacted too recently (the past hour)."); } return tableToCompact; }
CompactPriorityCalculator { @VisibleForTesting Optional<String> selectTableToCompactInternal(Transaction tx) { Map<String, Long> tableToLastTimeSwept = sweepHistoryProvider.getHistory(tx); Map<String, Long> tableToLastTimeCompacted = compactionHistoryProvider.getHistory(tx); Optional<String> tableToCompact = maybeChooseUncompactedTable(tableToLastTimeSwept, tableToLastTimeCompacted); if (!tableToCompact.isPresent()) { tableToCompact = maybeChooseTableSweptAfterCompact(tableToLastTimeSwept, tableToLastTimeCompacted); } if (!tableToCompact.isPresent()) { tableToCompact = maybeChooseTableCompactedOver1HourAgo(tableToLastTimeCompacted); } if (!tableToCompact.isPresent()) { log.info("Not compacting, because it does not appear that any table has been swept" + " or they were compacted too recently (the past hour)."); } return tableToCompact; } }
CompactPriorityCalculator { @VisibleForTesting Optional<String> selectTableToCompactInternal(Transaction tx) { Map<String, Long> tableToLastTimeSwept = sweepHistoryProvider.getHistory(tx); Map<String, Long> tableToLastTimeCompacted = compactionHistoryProvider.getHistory(tx); Optional<String> tableToCompact = maybeChooseUncompactedTable(tableToLastTimeSwept, tableToLastTimeCompacted); if (!tableToCompact.isPresent()) { tableToCompact = maybeChooseTableSweptAfterCompact(tableToLastTimeSwept, tableToLastTimeCompacted); } if (!tableToCompact.isPresent()) { tableToCompact = maybeChooseTableCompactedOver1HourAgo(tableToLastTimeCompacted); } if (!tableToCompact.isPresent()) { log.info("Not compacting, because it does not appear that any table has been swept" + " or they were compacted too recently (the past hour)."); } return tableToCompact; } @VisibleForTesting  CompactPriorityCalculator(TransactionManager transactionManager,
            SweepHistoryProvider sweepHistoryProvider,
            CompactionHistoryProvider compactionHistoryProvider); }
CompactPriorityCalculator { @VisibleForTesting Optional<String> selectTableToCompactInternal(Transaction tx) { Map<String, Long> tableToLastTimeSwept = sweepHistoryProvider.getHistory(tx); Map<String, Long> tableToLastTimeCompacted = compactionHistoryProvider.getHistory(tx); Optional<String> tableToCompact = maybeChooseUncompactedTable(tableToLastTimeSwept, tableToLastTimeCompacted); if (!tableToCompact.isPresent()) { tableToCompact = maybeChooseTableSweptAfterCompact(tableToLastTimeSwept, tableToLastTimeCompacted); } if (!tableToCompact.isPresent()) { tableToCompact = maybeChooseTableCompactedOver1HourAgo(tableToLastTimeCompacted); } if (!tableToCompact.isPresent()) { log.info("Not compacting, because it does not appear that any table has been swept" + " or they were compacted too recently (the past hour)."); } return tableToCompact; } @VisibleForTesting  CompactPriorityCalculator(TransactionManager transactionManager,
            SweepHistoryProvider sweepHistoryProvider,
            CompactionHistoryProvider compactionHistoryProvider);  }
CompactPriorityCalculator { @VisibleForTesting Optional<String> selectTableToCompactInternal(Transaction tx) { Map<String, Long> tableToLastTimeSwept = sweepHistoryProvider.getHistory(tx); Map<String, Long> tableToLastTimeCompacted = compactionHistoryProvider.getHistory(tx); Optional<String> tableToCompact = maybeChooseUncompactedTable(tableToLastTimeSwept, tableToLastTimeCompacted); if (!tableToCompact.isPresent()) { tableToCompact = maybeChooseTableSweptAfterCompact(tableToLastTimeSwept, tableToLastTimeCompacted); } if (!tableToCompact.isPresent()) { tableToCompact = maybeChooseTableCompactedOver1HourAgo(tableToLastTimeCompacted); } if (!tableToCompact.isPresent()) { log.info("Not compacting, because it does not appear that any table has been swept" + " or they were compacted too recently (the past hour)."); } return tableToCompact; } @VisibleForTesting  CompactPriorityCalculator(TransactionManager transactionManager,
            SweepHistoryProvider sweepHistoryProvider,
            CompactionHistoryProvider compactionHistoryProvider);   }