Search in sources :

Example 1 with PuncherStore

use of com.palantir.atlasdb.cleaner.PuncherStore in project atlasdb by palantir.

the class TestTimestampCommand method punch.

private void punch(TestAtlasDbServices services, TimestampService tss, Clock clock) {
    // this is a really hacky way of forcing a punch to test the datetime output
    Uninterruptibles.sleepUninterruptibly(2, TimeUnit.MILLISECONDS);
    long punchTs = tss.getFreshTimestamps(1000).getUpperBound();
    PuncherStore puncherStore = KeyValueServicePuncherStore.create(services.getKeyValueService());
    Puncher puncher = SimplePuncher.create(puncherStore, clock, Suppliers.ofInstance(AtlasDbConstants.DEFAULT_TRANSACTION_READ_TIMEOUT));
    puncher.punch(punchTs);
    Uninterruptibles.sleepUninterruptibly(2, TimeUnit.MILLISECONDS);
}
Also used : KeyValueServicePuncherStore(com.palantir.atlasdb.cleaner.KeyValueServicePuncherStore) PuncherStore(com.palantir.atlasdb.cleaner.PuncherStore) Puncher(com.palantir.atlasdb.cleaner.Puncher) SimplePuncher(com.palantir.atlasdb.cleaner.SimplePuncher)

Example 2 with PuncherStore

use of com.palantir.atlasdb.cleaner.PuncherStore 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;
}
Also used : KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) ZonedDateTime(java.time.ZonedDateTime) Instant(java.time.Instant) KeyValueServicePuncherStore(com.palantir.atlasdb.cleaner.KeyValueServicePuncherStore) PuncherStore(com.palantir.atlasdb.cleaner.PuncherStore)

Aggregations

KeyValueServicePuncherStore (com.palantir.atlasdb.cleaner.KeyValueServicePuncherStore)2 PuncherStore (com.palantir.atlasdb.cleaner.PuncherStore)2 Puncher (com.palantir.atlasdb.cleaner.Puncher)1 SimplePuncher (com.palantir.atlasdb.cleaner.SimplePuncher)1 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)1 Instant (java.time.Instant)1 ZonedDateTime (java.time.ZonedDateTime)1