private void verifyExpectedArgument(long sweepTime, long totalTimeElapsed) { assertThat(RESULTS_NO_MORE_TO_SWEEP.getTimeInMillis()).isEqualTo(sweepTime); assertThat(totalTimeElapsed).isBetween( RESULTS_NO_MORE_TO_SWEEP.getTimeElapsedSinceStartedSweeping() - 1000L, RESULTS_NO_MORE_TO_SWEEP.getTimeElapsedSinceStartedSweeping()); }
private SweepResults runFullSweepWithoutSavingResults( TableReference tableRef, byte[] startRow, SweepBatchConfig sweepBatchConfig) { SweepResults cumulativeResults = SweepResults.createEmptySweepResult(Optional.of(startRow)); while (cumulativeResults.getNextStartRow().isPresent()) { SweepResults results = runOneBatchWithoutSavingResults( tableRef, cumulativeResults.getNextStartRow().get(), sweepBatchConfig); specificTableSweeper.updateTimeMetricsOneIteration(results.getTimeInMillis(), results.getTimeElapsedSinceStartedSweeping()); cumulativeResults = cumulativeResults.accumulateWith(results); } return cumulativeResults; }
private void processSweepResults(TableToSweep tableToSweep, SweepResults currentIteration) { updateTimeMetricsOneIteration(currentIteration.getTimeInMillis(), currentIteration.getTimeElapsedSinceStartedSweeping()); SweepResults cumulativeResults = getCumulativeSweepResults(tableToSweep, currentIteration); if (currentIteration.getNextStartRow().isPresent()) { saveIntermediateSweepResults(tableToSweep, cumulativeResults); } else { processFinishedSweep(tableToSweep, cumulativeResults); } }
@Test public void timeElapsedMeterIsSet() { sweepMetrics.updateSweepTime( SWEEP_RESULTS.getTimeInMillis(), SWEEP_RESULTS.getTimeElapsedSinceStartedSweeping()); assertSweepTimeElapsedCurrentValueWithinMarginOfError(START_TIME); sweepMetrics.updateSweepTime( OTHER_SWEEP_RESULTS.getTimeInMillis(), OTHER_SWEEP_RESULTS.getTimeElapsedSinceStartedSweeping()); assertSweepTimeElapsedCurrentValueWithinMarginOfError(OTHER_START_TIME); }
@Test public void allMetricsAreSet() { sweepMetrics.updateSweepTime( SWEEP_RESULTS.getTimeInMillis(), SWEEP_RESULTS.getTimeElapsedSinceStartedSweeping()); sweepMetrics.updateCellsExaminedDeleted(EXAMINED, DELETED); assertRecordedExaminedDeletedTime( ImmutableList.of(EXAMINED, DELETED, TIME_SWEEPING) ); sweepMetrics.updateSweepTime( OTHER_SWEEP_RESULTS.getTimeInMillis(), OTHER_SWEEP_RESULTS.getTimeElapsedSinceStartedSweeping()); sweepMetrics.updateCellsExaminedDeleted(OTHER_EXAMINED, OTHER_DELETED); assertRecordedExaminedDeletedTime( ImmutableList.of(EXAMINED + OTHER_EXAMINED, DELETED + OTHER_DELETED, TIME_SWEEPING + OTHER_TIME_SWEEPING) ); }
private void processFinishedSweep(TableToSweep tableToSweep, SweepResults cumulativeResults) { saveFinalSweepResults(tableToSweep, cumulativeResults); log.info("Finished sweeping table {}. Examined {} cell+timestamp pairs, deleted {} stale values. Time taken " + "sweeping: {} ms, time elapsed since sweep first started on this table: {} ms.", LoggingArgs.tableRef("tableRef", tableToSweep.getTableRef()), SafeArg.of("cellTs pairs examined", cumulativeResults.getCellTsPairsExamined()), SafeArg.of("cellTs pairs deleted", cumulativeResults.getStaleValuesDeleted()), SafeArg.of("time sweeping table", cumulativeResults.getTimeInMillis()), SafeArg.of("time elapsed", cumulativeResults.getTimeElapsedSinceStartedSweeping())); tableToSweep.getSweepLock().close(); sweepProgressStore.clearProgress(tableToSweep.getTableRef()); }
@Test public void testMetricsRecordedAfterIncompleteRunForOneIterationOnly() { setNoProgress(); setNextTableToSweep(TABLE_REF); SweepResults intermediateResults = SweepResults.builder() .staleValuesDeleted(2) .cellTsPairsExamined(10) .minSweptTimestamp(12345L) .nextStartRow(Optional.of(new byte[] {1, 2, 3})) .timeInMillis(10L) .timeSweepStarted(20L) .build(); setupTaskRunner(intermediateResults); backgroundSweeper.runOnce(); ArgumentCaptor<Long> sweepTime = ArgumentCaptor.forClass(Long.class); ArgumentCaptor<Long> totalTimeElapsed = ArgumentCaptor.forClass(Long.class); Mockito.verify(sweepMetrics).updateSweepTime( sweepTime.capture(), totalTimeElapsed.capture()); Assertions.assertThat(intermediateResults.getTimeInMillis()).isEqualTo(sweepTime.getValue()); Assertions.assertThat(intermediateResults.getTimeElapsedSinceStartedSweeping()) .isCloseTo(totalTimeElapsed.getValue(), Percentage.withPercentage(5d)); }
SafeArg.of("cellTs pairs examined", newResults.getCellTsPairsExamined()), SafeArg.of("cellTs pairs deleted", newResults.getStaleValuesDeleted()), SafeArg.of("time elapsed", accumulatedResults.getTimeElapsedSinceStartedSweeping()), SafeArg.of("time sweeping", accumulatedResults.getTimeInMillis()));
Assertions.assertThat(intermediateResults.getTimeElapsedSinceStartedSweeping()) .isCloseTo(totalTimeElapsed.getValue(), Percentage.withPercentage(5d));
private SweepResults runFullSweepWithoutSavingResults( TableReference tableRef, byte[] startRow, SweepBatchConfig sweepBatchConfig) { SweepResults cumulativeResults = SweepResults.createEmptySweepResult(Optional.of(startRow)); while (cumulativeResults.getNextStartRow().isPresent()) { SweepResults results = runOneBatchWithoutSavingResults( tableRef, cumulativeResults.getNextStartRow().get(), sweepBatchConfig); specificTableSweeper.updateTimeMetricsOneIteration(results.getTimeInMillis(), results.getTimeElapsedSinceStartedSweeping()); cumulativeResults = cumulativeResults.accumulateWith(results); } return cumulativeResults; }
private void processSweepResults(TableToSweep tableToSweep, SweepResults currentIteration) { updateTimeMetricsOneIteration(currentIteration.getTimeInMillis(), currentIteration.getTimeElapsedSinceStartedSweeping()); SweepResults cumulativeResults = getCumulativeSweepResults(tableToSweep, currentIteration); if (currentIteration.getNextStartRow().isPresent()) { saveIntermediateSweepResults(tableToSweep, cumulativeResults); } else { processFinishedSweep(tableToSweep, cumulativeResults); } }
private void processFinishedSweep(TableToSweep tableToSweep, SweepResults cumulativeResults) { saveFinalSweepResults(tableToSweep, cumulativeResults); log.info("Finished sweeping table {}. Examined {} cell+timestamp pairs, deleted {} stale values. Time taken " + "sweeping: {} ms, time elapsed since sweep first started on this table: {} ms.", LoggingArgs.tableRef("tableRef", tableToSweep.getTableRef()), SafeArg.of("cellTs pairs examined", cumulativeResults.getCellTsPairsExamined()), SafeArg.of("cellTs pairs deleted", cumulativeResults.getStaleValuesDeleted()), SafeArg.of("time sweeping table", cumulativeResults.getTimeInMillis()), SafeArg.of("time elapsed", cumulativeResults.getTimeElapsedSinceStartedSweeping())); tableToSweep.getSweepLock().close(); sweepProgressStore.clearProgress(tableToSweep.getTableRef()); }
SafeArg.of("cellTs pairs examined", newResults.getCellTsPairsExamined()), SafeArg.of("cellTs pairs deleted", newResults.getStaleValuesDeleted()), SafeArg.of("time elapsed", accumulatedResults.getTimeElapsedSinceStartedSweeping()), SafeArg.of("time sweeping", accumulatedResults.getTimeInMillis()));