use of com.palantir.atlasdb.keyvalue.api.KeyValueService in project atlasdb by palantir.
the class DbkvsPostgresKeyValueServiceTest method getKeyValueService.
@Override
protected KeyValueService getKeyValueService() {
KeyValueService kvs = ConnectionManagerAwareDbKvs.create(DbkvsPostgresTestSuite.getKvsConfig());
kvs.getAllTableNames().stream().filter(table -> !table.getQualifiedName().equals("_metadata")).forEach(kvs::dropTable);
return kvs;
}
use of com.palantir.atlasdb.keyvalue.api.KeyValueService in project atlasdb by palantir.
the class TableSplittingKeyValueService method dropTables.
@Override
public void dropTables(Set<TableReference> tableRefs) {
Map<KeyValueService, Set<TableReference>> tablesByKvs = Maps.newHashMap();
for (TableReference tableRef : tableRefs) {
KeyValueService delegate = getDelegate(tableRef);
if (tablesByKvs.containsKey(delegate)) {
tablesByKvs.get(delegate).add(tableRef);
} else {
Set<TableReference> tablesBelongingToThisDelegate = Sets.newHashSet(tableRef);
tablesByKvs.put(delegate, tablesBelongingToThisDelegate);
}
}
for (Entry<KeyValueService, Set<TableReference>> kvsEntry : tablesByKvs.entrySet()) {
kvsEntry.getKey().dropTables(kvsEntry.getValue());
}
}
use of com.palantir.atlasdb.keyvalue.api.KeyValueService in project atlasdb by palantir.
the class SnapshotTransactionTest method testPutCleanup.
@Ignore("Until we know what we want to do with GC this will be ignored.")
// This tests that uncommitted values are deleted and cleaned up
@SuppressWarnings("unchecked")
@Test
public void testPutCleanup() throws Exception {
byte[] rowName = PtBytes.toBytes("1");
Mockery m = new Mockery();
final KeyValueService kvMock = m.mock(KeyValueService.class);
KeyValueService kv = MultiDelegateProxy.newProxyInstance(KeyValueService.class, keyValueService, kvMock);
final Cell cell = Cell.create(rowName, rowName);
timestampService.getFreshTimestamp();
final long startTs = timestampService.getFreshTimestamp();
final long transactionTs = timestampService.getFreshTimestamp();
keyValueService.put(TABLE, ImmutableMap.of(cell, PtBytes.EMPTY_BYTE_ARRAY), startTs);
final Sequence seq = m.sequence("seq");
m.checking(new Expectations() {
{
oneOf(kvMock).getLatestTimestamps(TABLE, ImmutableMap.of(cell, Long.MAX_VALUE));
inSequence(seq);
oneOf(kvMock).get(with(TransactionConstants.TRANSACTION_TABLE), with(any(Map.class)));
inSequence(seq);
oneOf(kvMock).putUnlessExists(with(TransactionConstants.TRANSACTION_TABLE), with(any(Map.class)));
inSequence(seq);
oneOf(kvMock).delete(TABLE, Multimaps.forMap(ImmutableMap.of(cell, startTs)));
inSequence(seq);
oneOf(kvMock).getLatestTimestamps(TABLE, ImmutableMap.of(cell, startTs));
inSequence(seq);
oneOf(kvMock).multiPut(with(any(Map.class)), with(transactionTs));
inSequence(seq);
oneOf(kvMock).putUnlessExists(with(TransactionConstants.TRANSACTION_TABLE), with(any(Map.class)));
inSequence(seq);
}
});
SnapshotTransaction snapshot = new SnapshotTransaction(kv, new LegacyTimelockService(timestampService, lockService, lockClient), transactionService, NoOpCleaner.INSTANCE, transactionTs, TestConflictDetectionManagers.createWithStaticConflictDetection(ImmutableMap.of(TABLE, ConflictHandler.RETRY_ON_WRITE_WRITE)), AtlasDbConstraintCheckingMode.NO_CONSTRAINT_CHECKING, TransactionReadSentinelBehavior.THROW_EXCEPTION, timestampCache, getRangesExecutor, defaultGetRangesConcurrency, sweepQueue);
snapshot.put(TABLE, ImmutableMap.of(cell, PtBytes.EMPTY_BYTE_ARRAY));
snapshot.commit();
m.assertIsSatisfied();
}
use of com.palantir.atlasdb.keyvalue.api.KeyValueService in project atlasdb by palantir.
the class SweepProgressStoreTest method setup.
@Before
public void setup() {
exec = PTExecutors.newCachedThreadPool();
KeyValueService kvs = new InMemoryKeyValueService(false, exec);
txManager = SweepTestUtils.setupTxManager(kvs);
progressStore = SweepProgressStoreImpl.create(kvs, false);
}
use of com.palantir.atlasdb.keyvalue.api.KeyValueService in project atlasdb by palantir.
the class ReadPunchTableCommand method execute.
@Override
public int execute(AtlasDbServices services) {
if (epochTime == null) {
throw new IllegalArgumentException("Required option '-e' is missing");
}
if (epochTime < 0) {
throw new IllegalArgumentException("Option '-e' should be a positive long, as epoch time" + " is never negative.");
}
Instant epochTimeInstant = Instant.ofEpochSecond(epochTime);
ZonedDateTime date = ZonedDateTime.ofInstant(epochTimeInstant, ZoneId.systemDefault());
printer.info("Input {} in epoch millis is {}", SafeArg.of("epochMillis", epochTime), SafeArg.of("date", date.toString()));
KeyValueService keyValueService = services.getKeyValueService();
PuncherStore puncherStore = KeyValueServicePuncherStore.create(keyValueService, false);
Long value = puncherStore.get(epochTime);
printer.info("The first timestamp before {} is {}", SafeArg.of("date", date.toString()), SafeArg.of("timestamp", value));
return 0;
}
Aggregations