Search in sources :

Example 6 with SweepResults

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

the class BackgroundSweeperFastTest method testMetricsRecordedAfterIncompleteRunForOneIterationOnly.

@Test
public void testMetricsRecordedAfterIncompleteRunForOneIterationOnly() {
    setNoProgress();
    setNextTableToSweep(TABLE_REF);
    SweepResults intermediateResults = ImmutableSweepResults.builder().staleValuesDeleted(2).cellTsPairsExamined(10).minSweptTimestamp(12345L).nextStartRow(Optional.of(new byte[] { 1, 2, 3 })).timeInMillis(10L).timeSweepStarted(20L).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 7 with SweepResults

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

the class SweepBenchmarks method runSingleSweep.

private Object runSingleSweep(RegeneratingTable table, int uniqueCellsToSweep) {
    SweepTaskRunner sweepTaskRunner = table.getSweepTaskRunner();
    SweepBatchConfig batchConfig = ImmutableSweepBatchConfig.builder().deleteBatchSize(DELETED_COUNT * uniqueCellsToSweep).candidateBatchSize(RegeneratingTable.SWEEP_DUPLICATES * uniqueCellsToSweep + 1).maxCellTsPairsToExamine(RegeneratingTable.SWEEP_DUPLICATES * uniqueCellsToSweep).build();
    SweepResults sweepResults = sweepTaskRunner.run(table.getTableRef(), batchConfig, PtBytes.EMPTY_BYTE_ARRAY);
    assertThat(sweepResults.getStaleValuesDeleted(), is((long) DELETED_COUNT * uniqueCellsToSweep));
    return sweepResults;
}
Also used : SweepBatchConfig(com.palantir.atlasdb.sweep.SweepBatchConfig) ImmutableSweepBatchConfig(com.palantir.atlasdb.sweep.ImmutableSweepBatchConfig) SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults) SweepTaskRunner(com.palantir.atlasdb.sweep.SweepTaskRunner)

Example 8 with SweepResults

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

the class SweepBenchmarks method runMultiSweep.

private Object runMultiSweep(RegeneratingTable table) {
    SweepTaskRunner sweepTaskRunner = table.getSweepTaskRunner();
    SweepResults sweepResults = null;
    byte[] nextStartRow = PtBytes.EMPTY_BYTE_ARRAY;
    for (int i = 0; i < BATCH_SIZE; i++) {
        SweepBatchConfig batchConfig = ImmutableSweepBatchConfig.builder().deleteBatchSize(DELETED_COUNT).candidateBatchSize(1).maxCellTsPairsToExamine(RegeneratingTable.SWEEP_DUPLICATES).build();
        sweepResults = sweepTaskRunner.run(table.getTableRef(), batchConfig, nextStartRow);
        nextStartRow = sweepResults.getNextStartRow().get();
        assertThat(sweepResults.getStaleValuesDeleted(), is((long) DELETED_COUNT));
    }
    return sweepResults;
}
Also used : SweepBatchConfig(com.palantir.atlasdb.sweep.SweepBatchConfig) ImmutableSweepBatchConfig(com.palantir.atlasdb.sweep.ImmutableSweepBatchConfig) SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults) SweepTaskRunner(com.palantir.atlasdb.sweep.SweepTaskRunner)

Example 9 with SweepResults

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

the class SpecificTableSweeper method runOnceAndSaveResults.

void runOnceAndSaveResults(TableToSweep tableToSweep, SweepBatchConfig batchConfig) {
    TableReference tableRef = tableToSweep.getTableRef();
    byte[] startRow = tableToSweep.getStartRow();
    SweepResults results = runOneIteration(tableRef, startRow, batchConfig);
    processSweepResults(tableToSweep, results);
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults)

Example 10 with SweepResults

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

the class SweepTaskRunner method runInternal.

private SweepResults runInternal(TableReference tableRef, SweepBatchConfig batchConfig, byte[] startRow, RunType runType) {
    Preconditions.checkNotNull(tableRef, "tableRef cannot be null");
    Preconditions.checkState(!AtlasDbConstants.hiddenTables.contains(tableRef));
    if (tableRef.getQualifiedName().startsWith(AtlasDbConstants.NAMESPACE_PREFIX)) {
        // this happens sometimes; I think it's because some places in the code can
        // start this sweeper without doing the full normally ordered KVSModule startup.
        // I did check and sweep.stats did contain the FQ table name for all of the tables,
        // so it is at least broken in some way that still allows namespaced tables to eventually be swept.
        log.warn("The sweeper should not be run on tables passed through namespace mapping.");
        return SweepResults.createEmptySweepResultWithNoMoreToSweep();
    }
    if (keyValueService.getMetadataForTable(tableRef).length == 0) {
        log.warn("The sweeper tried to sweep table '{}', but the table does not exist. Skipping table.", LoggingArgs.tableRef("tableRef", tableRef));
        return SweepResults.createEmptySweepResultWithNoMoreToSweep();
    }
    SweepStrategy sweepStrategy = sweepStrategyManager.get().getOrDefault(tableRef, SweepStrategy.CONSERVATIVE);
    Optional<Sweeper> maybeSweeper = Sweeper.of(sweepStrategy);
    return maybeSweeper.map(sweeper -> doRun(tableRef, batchConfig, startRow, runType, sweeper)).orElseGet(SweepResults::createEmptySweepResultWithNoMoreToSweep);
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) Arrays(java.util.Arrays) LongSupplier(java.util.function.LongSupplier) Stopwatch(com.google.common.base.Stopwatch) ClosableIterator(com.palantir.common.base.ClosableIterator) LoggerFactory(org.slf4j.LoggerFactory) SweepStrategyManager(com.palantir.atlasdb.transaction.impl.SweepStrategyManager) Multimap(com.google.common.collect.Multimap) Iterators(com.google.common.collect.Iterators) PtBytes(com.palantir.atlasdb.encoding.PtBytes) Lists(com.google.common.collect.Lists) LoggingArgs(com.palantir.atlasdb.logging.LoggingArgs) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) CandidateCellForSweeping(com.palantir.atlasdb.keyvalue.api.CandidateCellForSweeping) ImmutableCandidateCellForSweepingRequest(com.palantir.atlasdb.keyvalue.api.ImmutableCandidateCellForSweepingRequest) AtlasDbConstants(com.palantir.atlasdb.AtlasDbConstants) Logger(org.slf4j.Logger) TDecorators(gnu.trove.TDecorators) Iterator(java.util.Iterator) ExaminedCellLimit(com.palantir.atlasdb.sweep.CellsToSweepPartitioningIterator.ExaminedCellLimit) Cell(com.palantir.atlasdb.keyvalue.api.Cell) SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults) SweepStrategy(com.palantir.atlasdb.protos.generated.TableMetadataPersistence.SweepStrategy) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) CandidateCellForSweepingRequest(com.palantir.atlasdb.keyvalue.api.CandidateCellForSweepingRequest) UnsafeArg(com.palantir.logsafe.UnsafeArg) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) SweepMetricsManager(com.palantir.atlasdb.sweep.metrics.SweepMetricsManager) SweepStrategy(com.palantir.atlasdb.protos.generated.TableMetadataPersistence.SweepStrategy) SweepResults(com.palantir.atlasdb.keyvalue.api.SweepResults)

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