Search in sources :

Example 61 with TableReference

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

the class TableRemappingKeyValueService method createTable.

@Override
public void createTable(TableReference tableRef, byte[] tableMetadata) {
    TableReference shortName = tableMapper.addTable(tableRef);
    delegate().createTable(shortName, tableMetadata);
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference)

Example 62 with TableReference

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

the class TableSplittingKeyValueService method multiPut.

@Override
public void multiPut(Map<TableReference, ? extends Map<Cell, byte[]>> valuesByTable, long timestamp) {
    Map<KeyValueService, Map<TableReference, Map<Cell, byte[]>>> mapByDelegate = Maps.newHashMap();
    for (Entry<TableReference, ? extends Map<Cell, byte[]>> e : valuesByTable.entrySet()) {
        KeyValueService delegate = getDelegate(e.getKey());
        Map<TableReference, Map<Cell, byte[]>> map = mapByDelegate.computeIfAbsent(delegate, table -> Maps.newHashMap());
        map.put(e.getKey(), e.getValue());
    }
    for (Entry<KeyValueService, Map<TableReference, Map<Cell, byte[]>>> e : mapByDelegate.entrySet()) {
        e.getKey().multiPut(e.getValue(), timestamp);
    }
}
Also used : KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) ImmutableMap(com.google.common.collect.ImmutableMap) Cell(com.palantir.atlasdb.keyvalue.api.Cell)

Example 63 with TableReference

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

the class TableSplittingKeyValueService method groupByDelegate.

private Map<KeyValueService, Map<TableReference, byte[]>> groupByDelegate(Map<TableReference, byte[]> tableRefsToTableMetadata) {
    Map<KeyValueService, Map<TableReference, byte[]>> splitTableNamesToTableMetadata = Maps.newHashMap();
    for (Entry<TableReference, byte[]> tableEntry : tableRefsToTableMetadata.entrySet()) {
        TableReference tableRef = tableEntry.getKey();
        byte[] tableMetadata = tableEntry.getValue();
        KeyValueService delegate = getDelegate(tableRef);
        if (splitTableNamesToTableMetadata.containsKey(delegate)) {
            splitTableNamesToTableMetadata.get(delegate).put(tableRef, tableMetadata);
        } else {
            Map<TableReference, byte[]> mapTableToMaxValue = Maps.newHashMap();
            mapTableToMaxValue.put(tableRef, tableMetadata);
            splitTableNamesToTableMetadata.put(delegate, mapTableToMaxValue);
        }
    }
    return splitTableNamesToTableMetadata;
}
Also used : KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 64 with TableReference

use of com.palantir.atlasdb.keyvalue.api.TableReference 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 65 with TableReference

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

the class SweeperServiceImpl method sweepTable.

@Override
public SweepTableResponse sweepTable(String tableName, Optional<String> startRow, Optional<Boolean> fullSweep, Optional<Integer> maxCellTsPairsToExamine, Optional<Integer> candidateBatchSize, Optional<Integer> deleteBatchSize) {
    TableReference tableRef = getTableRef(tableName);
    checkTableExists(tableName, tableRef);
    byte[] decodedStartRow = startRow.map(PtBytes::decodeHexString).orElse(PtBytes.EMPTY_BYTE_ARRAY);
    SweepBatchConfig config = buildConfigWithOverrides(maxCellTsPairsToExamine, candidateBatchSize, deleteBatchSize);
    return SweepTableResponse.from(runSweep(fullSweep, tableRef, decodedStartRow, config));
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference)

Aggregations

TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)112 Cell (com.palantir.atlasdb.keyvalue.api.Cell)41 Test (org.junit.Test)41 Map (java.util.Map)17 ImmutableMap (com.google.common.collect.ImmutableMap)13 Multimap (com.google.common.collect.Multimap)13 Entry (java.util.Map.Entry)13 Set (java.util.Set)13 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)12 Value (com.palantir.atlasdb.keyvalue.api.Value)12 Collection (java.util.Collection)12 List (java.util.List)12 ImmutableSet (com.google.common.collect.ImmutableSet)11 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)11 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)11 SortedMap (java.util.SortedMap)11 Lists (com.google.common.collect.Lists)10 AtlasDbConstants (com.palantir.atlasdb.AtlasDbConstants)10 Sets (com.google.common.collect.Sets)9 InsufficientConsistencyException (com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException)9