use of com.palantir.common.time.Clock in project atlasdb by palantir.
the class AsyncPuncherTest method setup.
@Before
public void setup() {
PuncherStore puncherStore = InMemoryPuncherStore.create();
Clock clock = new SystemClock();
Puncher puncher = SimplePuncher.create(puncherStore, clock, Suppliers.ofInstance(TRANSACTION_TIMEOUT));
timestampService = new InMemoryTimestampService();
asyncPuncher = AsyncPuncher.create(puncher, ASYNC_PUNCHER_INTERVAL);
}
use of com.palantir.common.time.Clock in project atlasdb by palantir.
the class TestTimestampCommand method runAndVerifyCli.
private void runAndVerifyCli(Verifier verifier) throws Exception {
try (SingleBackendCliTestRunner runner = makeRunner(cliArgs.toArray(new String[0]))) {
TestAtlasDbServices services = runner.connect(moduleFactory);
LockService lockService = services.getLockService();
TimestampService tss = services.getTimestampService();
LockClient client = services.getTestLockClient();
Clock clock = GlobalClock.create(lockService);
long prePunch = clock.getTimeMillis();
punch(services, tss, clock);
long postPunch = clock.getTimeMillis();
long immutableTs = tss.getFreshTimestamp();
LockRequest request = LockRequest.builder(ImmutableSortedMap.of(lock, LockMode.WRITE)).withLockedInVersionId(immutableTs).doNotBlock().build();
LockRefreshToken token = lockService.lock(client.getClientId(), request);
long lastFreshTs = tss.getFreshTimestamps(1000).getUpperBound();
verifier.verify(runner, tss, immutableTs, prePunch, postPunch, lastFreshTs, true);
lockService.unlock(token);
lastFreshTs = tss.getFreshTimestamps(1000).getUpperBound();
// there are no locks so we now expect immutable to just be a fresh
runner.freshCommand();
verifier.verify(runner, tss, immutableTs, prePunch, postPunch, lastFreshTs, false);
}
}
use of com.palantir.common.time.Clock in project atlasdb by palantir.
the class DefaultCleanerBuilder method buildPuncher.
private Puncher buildPuncher() {
PuncherStore keyValuePuncherStore = KeyValueServicePuncherStore.create(keyValueService, initalizeAsync);
PuncherStore cachingPuncherStore = CachingPuncherStore.create(keyValuePuncherStore, punchIntervalMillis * 3);
Clock clock = GlobalClock.create(timelockService);
SimplePuncher simplePuncher = SimplePuncher.create(cachingPuncherStore, clock, Suppliers.ofInstance(transactionReadTimeout));
return AsyncPuncher.create(simplePuncher, punchIntervalMillis);
}
Aggregations