Search in sources :

Example 1 with SweepStrategy

use of com.palantir.atlasdb.protos.generated.TableMetadataPersistence.SweepStrategy 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)

Example 2 with SweepStrategy

use of com.palantir.atlasdb.protos.generated.TableMetadataPersistence.SweepStrategy in project atlasdb by palantir.

the class TableMetadata method hydrateFromProto.

public static TableMetadata hydrateFromProto(TableMetadataPersistence.TableMetadata message) {
    CachePriority cachePriority = CachePriority.WARM;
    if (message.hasCachePriority()) {
        cachePriority = message.getCachePriority();
    }
    boolean rangeScanAllowed = false;
    if (message.hasRangeScanAllowed()) {
        rangeScanAllowed = message.getRangeScanAllowed();
    }
    int explicitCompressionBlockSizeKB = 0;
    if (message.hasExplicitCompressionBlockSizeKiloBytes()) {
        explicitCompressionBlockSizeKB = message.getExplicitCompressionBlockSizeKiloBytes();
    }
    boolean negativeLookups = false;
    if (message.hasNegativeLookups()) {
        negativeLookups = message.getNegativeLookups();
    }
    SweepStrategy sweepStrategy = SweepStrategy.CONSERVATIVE;
    if (message.hasSweepStrategy()) {
        sweepStrategy = message.getSweepStrategy();
    }
    boolean appendHeavyAndReadLight = false;
    if (message.hasAppendHeavyAndReadLight()) {
        appendHeavyAndReadLight = message.getAppendHeavyAndReadLight();
    }
    LogSafety nameLogSafety = LogSafety.UNSAFE;
    if (message.hasNameLogSafety()) {
        nameLogSafety = message.getNameLogSafety();
    }
    return new TableMetadata(NameMetadataDescription.hydrateFromProto(message.getRowName()), ColumnMetadataDescription.hydrateFromProto(message.getColumns()), ConflictHandlers.hydrateFromProto(message.getConflictHandler()), cachePriority, rangeScanAllowed, explicitCompressionBlockSizeKB, negativeLookups, sweepStrategy, appendHeavyAndReadLight, nameLogSafety);
}
Also used : CachePriority(com.palantir.atlasdb.protos.generated.TableMetadataPersistence.CachePriority) SweepStrategy(com.palantir.atlasdb.protos.generated.TableMetadataPersistence.SweepStrategy) LogSafety(com.palantir.atlasdb.protos.generated.TableMetadataPersistence.LogSafety)

Aggregations

SweepStrategy (com.palantir.atlasdb.protos.generated.TableMetadataPersistence.SweepStrategy)2 Preconditions (com.google.common.base.Preconditions)1 Stopwatch (com.google.common.base.Stopwatch)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 Iterators (com.google.common.collect.Iterators)1 Lists (com.google.common.collect.Lists)1 Multimap (com.google.common.collect.Multimap)1 AtlasDbConstants (com.palantir.atlasdb.AtlasDbConstants)1 PtBytes (com.palantir.atlasdb.encoding.PtBytes)1 CandidateCellForSweeping (com.palantir.atlasdb.keyvalue.api.CandidateCellForSweeping)1 CandidateCellForSweepingRequest (com.palantir.atlasdb.keyvalue.api.CandidateCellForSweepingRequest)1 Cell (com.palantir.atlasdb.keyvalue.api.Cell)1 ImmutableCandidateCellForSweepingRequest (com.palantir.atlasdb.keyvalue.api.ImmutableCandidateCellForSweepingRequest)1 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)1 SweepResults (com.palantir.atlasdb.keyvalue.api.SweepResults)1 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)1 LoggingArgs (com.palantir.atlasdb.logging.LoggingArgs)1 CachePriority (com.palantir.atlasdb.protos.generated.TableMetadataPersistence.CachePriority)1 LogSafety (com.palantir.atlasdb.protos.generated.TableMetadataPersistence.LogSafety)1 ExaminedCellLimit (com.palantir.atlasdb.sweep.CellsToSweepPartitioningIterator.ExaminedCellLimit)1