Search in sources :

Example 11 with SweepResults

use of com.palantir.atlasdb.keyvalue.api.SweepResults in project atlasdb by palantir.

the class SweeperServiceImpl method runFullSweepWithoutSavingResults.

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.updateMetricsOneIteration(results, tableRef);
        cumulativeResults = cumulativeResults.accumulateWith(results);
    }
    return cumulativeResults;
}
Also used : SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults)

Example 12 with SweepResults

use of com.palantir.atlasdb.keyvalue.api.SweepResults in project atlasdb by palantir.

the class BackgroundSweeperFastTest method testMetricsUseIntermediateResultsPerIteration.

@Test
public void testMetricsUseIntermediateResultsPerIteration() {
    setProgress(ImmutableSweepProgress.builder().tableRef(TABLE_REF).staleValuesDeleted(3).cellTsPairsExamined(11).minimumSweptTimestamp(4567L).startRow(new byte[] { 1, 2, 3 }).startColumn(PtBytes.toBytes("unused")).timeInMillis(10L).startTimeInMillis(20L).build());
    SweepResults intermediateResults = ImmutableSweepResults.builder().staleValuesDeleted(2).cellTsPairsExamined(10).minSweptTimestamp(12345L).timeInMillis(20L).timeSweepStarted(50L).build();
    setupTaskRunner(intermediateResults);
    backgroundSweeper.runOnce();
    Mockito.verify(sweepMetricsManager).updateMetrics(intermediateResults, TABLE_REF);
}
Also used : SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults) ImmutableSweepResults(com.palantir.atlasdb.keyvalue.api.ImmutableSweepResults) Test(org.junit.Test)

Example 13 with SweepResults

use of com.palantir.atlasdb.keyvalue.api.SweepResults in project atlasdb by palantir.

the class SpecificTableSweeper method processSweepResults.

private void processSweepResults(TableToSweep tableToSweep, SweepResults currentIteration) {
    updateMetricsOneIteration(currentIteration, tableToSweep.getTableRef());
    SweepResults cumulativeResults = getCumulativeSweepResults(tableToSweep, currentIteration);
    if (currentIteration.getNextStartRow().isPresent()) {
        saveIntermediateSweepResults(tableToSweep, cumulativeResults);
    } else {
        processFinishedSweep(tableToSweep, cumulativeResults);
    }
}
Also used : SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults)

Example 14 with SweepResults

use of com.palantir.atlasdb.keyvalue.api.SweepResults in project atlasdb by palantir.

the class SpecificTableSweeper method runOneIteration.

SweepResults runOneIteration(TableReference tableRef, byte[] startRow, SweepBatchConfig batchConfig) {
    try {
        SweepResults results = sweepRunner.run(tableRef, batchConfig, startRow);
        logSweepPerformance(tableRef, startRow, results);
        return results;
    } catch (RuntimeException e) {
        // This error may be logged on some paths above, but I prefer to log defensively.
        logSweepError(tableRef, startRow, batchConfig, e);
        throw e;
    }
}
Also used : SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults)

Example 15 with SweepResults

use of com.palantir.atlasdb.keyvalue.api.SweepResults in project atlasdb by palantir.

the class SweeperServiceImplTest method sweepsEntireTableByDefault.

@Test
public void sweepsEntireTableByDefault() {
    List<byte[]> startRows = ImmutableList.of(PtBytes.EMPTY_BYTE_ARRAY, new byte[] { 0x10 }, new byte[] { 0x50 });
    for (int i = 0; i < startRows.size(); i++) {
        byte[] currentRow = startRows.get(i);
        Optional<byte[]> nextRow = (i + 1) == startRows.size() ? Optional.empty() : Optional.of(startRows.get(i + 1));
        SweepResults results = SweepResults.createEmptySweepResult(nextRow);
        when(sweepTaskRunner.run(any(), any(), eq(currentRow))).thenReturn(results);
    }
    sweeperService.sweepTableFully(TABLE_REF.getQualifiedName());
    startRows.forEach(row -> verify(sweepTaskRunner).run(any(), any(), eq(row)));
    verifyNoMoreInteractions(sweepTaskRunner);
}
Also used : SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults) Test(org.junit.Test)

Aggregations

SweepResults (com.palantir.atlasdb.keyvalue.api.SweepResults)27 Test (org.junit.Test)16 ImmutableSweepResults (com.palantir.atlasdb.keyvalue.api.ImmutableSweepResults)15 Cell (com.palantir.atlasdb.keyvalue.api.Cell)4 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)4 List (java.util.List)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableSweepBatchConfig (com.palantir.atlasdb.sweep.ImmutableSweepBatchConfig)3 SweepBatchConfig (com.palantir.atlasdb.sweep.SweepBatchConfig)3 SweepTaskRunner (com.palantir.atlasdb.sweep.SweepTaskRunner)3 ArrayList (java.util.ArrayList)3 Stopwatch (com.google.common.base.Stopwatch)2 AtlasDbConstants (com.palantir.atlasdb.AtlasDbConstants)2 PtBytes (com.palantir.atlasdb.encoding.PtBytes)2 LoggingArgs (com.palantir.atlasdb.logging.LoggingArgs)2 AbstractSweepTaskRunnerTest (com.palantir.atlasdb.sweep.AbstractSweepTaskRunnerTest)2 UnsafeArg (com.palantir.logsafe.UnsafeArg)2 Arrays (java.util.Arrays)2 Optional (java.util.Optional)2 TimeUnit (java.util.concurrent.TimeUnit)2