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;
}
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;
}
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);
}
}
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);
}
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;
}
Aggregations