Search in sources :

Example 1 with Clock

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);
}
Also used : SystemClock(com.palantir.common.time.SystemClock) InMemoryTimestampService(com.palantir.timestamp.InMemoryTimestampService) Clock(com.palantir.common.time.Clock) SystemClock(com.palantir.common.time.SystemClock) Before(org.junit.Before)

Example 2 with Clock

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);
    }
}
Also used : LockService(com.palantir.lock.LockService) LockClient(com.palantir.lock.LockClient) SingleBackendCliTestRunner(com.palantir.atlasdb.cli.runner.SingleBackendCliTestRunner) DaggerTestAtlasDbServices(com.palantir.atlasdb.services.test.DaggerTestAtlasDbServices) TestAtlasDbServices(com.palantir.atlasdb.services.test.TestAtlasDbServices) GlobalClock(com.palantir.atlasdb.cleaner.GlobalClock) Clock(com.palantir.common.time.Clock) LockRequest(com.palantir.lock.LockRequest) TimestampService(com.palantir.timestamp.TimestampService) LockRefreshToken(com.palantir.lock.LockRefreshToken)

Example 3 with Clock

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);
}
Also used : Clock(com.palantir.common.time.Clock)

Aggregations

Clock (com.palantir.common.time.Clock)3 GlobalClock (com.palantir.atlasdb.cleaner.GlobalClock)1 SingleBackendCliTestRunner (com.palantir.atlasdb.cli.runner.SingleBackendCliTestRunner)1 DaggerTestAtlasDbServices (com.palantir.atlasdb.services.test.DaggerTestAtlasDbServices)1 TestAtlasDbServices (com.palantir.atlasdb.services.test.TestAtlasDbServices)1 SystemClock (com.palantir.common.time.SystemClock)1 LockClient (com.palantir.lock.LockClient)1 LockRefreshToken (com.palantir.lock.LockRefreshToken)1 LockRequest (com.palantir.lock.LockRequest)1 LockService (com.palantir.lock.LockService)1 InMemoryTimestampService (com.palantir.timestamp.InMemoryTimestampService)1 TimestampService (com.palantir.timestamp.TimestampService)1 Before (org.junit.Before)1