Search in sources :

Example 11 with KeyValueService

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

the class KeyValueServiceModule method provideWrappedKeyValueService.

@Provides
@Singleton
@Named("kvs")
public KeyValueService provideWrappedKeyValueService(@Named("rawKvs") KeyValueService rawKvs, TimestampService tss, ServicesConfig config) {
    KvsProfilingLogger.setSlowLogThresholdMillis(config.atlasDbConfig().getKvsSlowLogThresholdMillis());
    KeyValueService kvs = ProfilingKeyValueService.create(rawKvs);
    kvs = TracingKeyValueService.create(kvs);
    kvs = AtlasDbMetrics.instrument(KeyValueService.class, kvs);
    kvs = ValidatingQueryRewritingKeyValueService.create(kvs);
    SweepConfig sweepConfig = config.atlasDbRuntimeConfig().sweep();
    kvs = SweepStatsKeyValueService.create(kvs, tss, sweepConfig::writeThreshold, sweepConfig::writeSizeThreshold);
    TransactionTables.createTables(kvs);
    ImmutableSet<Schema> schemas = ImmutableSet.<Schema>builder().add(SweepSchema.INSTANCE.getLatestSchema()).add(CompactSchema.INSTANCE.getLatestSchema()).addAll(config.schemas()).build();
    for (Schema schema : schemas) {
        Schemas.createTablesAndIndexes(schema, kvs);
    }
    return kvs;
}
Also used : SweepConfig(com.palantir.atlasdb.config.SweepConfig) ValidatingQueryRewritingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ValidatingQueryRewritingKeyValueService) TracingKeyValueService(com.palantir.atlasdb.keyvalue.impl.TracingKeyValueService) ProfilingKeyValueService(com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) SweepStatsKeyValueService(com.palantir.atlasdb.keyvalue.impl.SweepStatsKeyValueService) SweepSchema(com.palantir.atlasdb.schema.SweepSchema) CompactSchema(com.palantir.atlasdb.schema.CompactSchema) Schema(com.palantir.atlasdb.table.description.Schema) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Example 12 with KeyValueService

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

the class InMemoryAtlasDbFactory method createInMemoryTransactionManagerInternal.

private static SerializableTransactionManager createInMemoryTransactionManagerInternal(Set<Schema> schemas) {
    TimestampService ts = new InMemoryTimestampService();
    KeyValueService keyValueService = new InMemoryKeyValueService(false);
    schemas.forEach(s -> Schemas.createTablesAndIndexes(s, keyValueService));
    TransactionTables.createTables(keyValueService);
    TransactionService transactionService = TransactionServices.createTransactionService(keyValueService);
    LockService lock = LockRefreshingLockService.create(LockServiceImpl.create(LockServerOptions.builder().isStandaloneServer(false).build()));
    LockClient client = LockClient.of("in memory atlasdb instance");
    ConflictDetectionManager conflictManager = ConflictDetectionManagers.createWithoutWarmingCache(keyValueService);
    SweepStrategyManager sweepStrategyManager = SweepStrategyManagers.createDefault(keyValueService);
    CleanupFollower follower = CleanupFollower.create(schemas);
    Cleaner cleaner = new DefaultCleanerBuilder(keyValueService, lock, ts, client, ImmutableList.of(follower), transactionService).buildCleaner();
    SerializableTransactionManager ret = SerializableTransactionManager.createForTest(keyValueService, ts, client, lock, transactionService, Suppliers.ofInstance(AtlasDbConstraintCheckingMode.FULL_CONSTRAINT_CHECKING_THROWS_EXCEPTIONS), conflictManager, sweepStrategyManager, cleaner, DEFAULT_MAX_CONCURRENT_RANGES, DEFAULT_GET_RANGES_CONCURRENCY, () -> DEFAULT_TIMESTAMP_CACHE_SIZE, MultiTableSweepQueueWriter.NO_OP);
    cleaner.start(ret);
    return ret;
}
Also used : SweepStrategyManager(com.palantir.atlasdb.transaction.impl.SweepStrategyManager) InMemoryKeyValueService(com.palantir.atlasdb.keyvalue.impl.InMemoryKeyValueService) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) TransactionService(com.palantir.atlasdb.transaction.service.TransactionService) LockRefreshingLockService(com.palantir.lock.client.LockRefreshingLockService) LockService(com.palantir.lock.LockService) InMemoryKeyValueService(com.palantir.atlasdb.keyvalue.impl.InMemoryKeyValueService) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) LockClient(com.palantir.lock.LockClient) DefaultCleanerBuilder(com.palantir.atlasdb.cleaner.DefaultCleanerBuilder) ConflictDetectionManager(com.palantir.atlasdb.transaction.impl.ConflictDetectionManager) InMemoryTimestampService(com.palantir.timestamp.InMemoryTimestampService) InMemoryTimestampService(com.palantir.timestamp.InMemoryTimestampService) TimestampService(com.palantir.timestamp.TimestampService) CleanupFollower(com.palantir.atlasdb.cleaner.CleanupFollower) Cleaner(com.palantir.atlasdb.cleaner.Cleaner)

Example 13 with KeyValueService

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

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

the class TableSplittingKeyValueService method create.

public static TableSplittingKeyValueService create(List<KeyValueService> delegates, Map<TableReference, KeyValueService> delegateByTable, Map<Namespace, KeyValueService> delegateByNamespace) {
    // See comment in get all table names for why we do this.
    Map<KeyValueService, Void> map = new IdentityHashMap<KeyValueService, Void>(delegates.size());
    for (KeyValueService delegate : delegates) {
        map.put(delegate, null);
    }
    Preconditions.checkArgument(map.keySet().containsAll(delegateByTable.values()), "delegateByTable must only have delegates from the delegate list");
    return new TableSplittingKeyValueService(delegates, delegateByTable, delegateByNamespace);
}
Also used : KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) IdentityHashMap(java.util.IdentityHashMap)

Example 15 with KeyValueService

use of com.palantir.atlasdb.keyvalue.api.KeyValueService 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)

Aggregations

KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)30 Test (org.junit.Test)16 InMemoryKeyValueService (com.palantir.atlasdb.keyvalue.impl.InMemoryKeyValueService)12 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)7 SerializableTransactionManager (com.palantir.atlasdb.transaction.impl.SerializableTransactionManager)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 Cell (com.palantir.atlasdb.keyvalue.api.Cell)5 TrackingKeyValueService (com.palantir.atlasdb.keyvalue.impl.TrackingKeyValueService)5 TimestampService (com.palantir.timestamp.TimestampService)5 Map (java.util.Map)5 SingleBackendCliTestRunner (com.palantir.atlasdb.cli.runner.SingleBackendCliTestRunner)4 ForwardingKeyValueService (com.palantir.atlasdb.keyvalue.impl.ForwardingKeyValueService)4 TracingKeyValueService (com.palantir.atlasdb.keyvalue.impl.TracingKeyValueService)4 DaggerTestAtlasDbServices (com.palantir.atlasdb.services.test.DaggerTestAtlasDbServices)4 TestAtlasDbServices (com.palantir.atlasdb.services.test.TestAtlasDbServices)4 Before (org.junit.Before)4 RowResult (com.palantir.atlasdb.keyvalue.api.RowResult)3 LockService (com.palantir.lock.LockService)3 LegacyTimelockService (com.palantir.lock.impl.LegacyTimelockService)3 IdentityHashMap (java.util.IdentityHashMap)3