Search in sources :

Example 1 with StandardLockCleanerService

use of org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerService in project janusgraph by JanusGraph.

the class LockCleanerServiceTest method testCleanCooldownBlocksRapidRequests.

@Test
public void testCleanCooldownBlocksRapidRequests() {
    final Instant cutoff = Instant.ofEpochMilli(1L);
    svc = new StandardLockCleanerService(store, codec, exec, Duration.ofSeconds(60L), TimestampProviders.MILLI);
    expect(exec.submit(eq(new StandardLockCleanerRunnable(store, kc, tx, codec, cutoff, TimestampProviders.MILLI)))).andReturn(null);
    ctrl.replay();
    for (int i = 0; i < 500; i++) {
        svc.clean(kc, cutoff, tx);
    }
}
Also used : StandardLockCleanerService(org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerService) StandardLockCleanerRunnable(org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerRunnable) Instant(java.time.Instant) Test(org.junit.Test)

Example 2 with StandardLockCleanerService

use of org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerService in project janusgraph by JanusGraph.

the class LockCleanerServiceTest method testCleanCooldownElapses.

@Test
public void testCleanCooldownElapses() throws InterruptedException {
    final Instant cutoff = Instant.ofEpochMilli(1L);
    Duration wait = Duration.ofMillis(500L);
    svc = new StandardLockCleanerService(store, codec, exec, wait, TimestampProviders.MILLI);
    expect(exec.submit(eq(new StandardLockCleanerRunnable(store, kc, tx, codec, cutoff, TimestampProviders.MILLI)))).andReturn(null);
    expect(exec.submit(eq(new StandardLockCleanerRunnable(store, kc, tx, codec, cutoff.plusMillis(1), TimestampProviders.MILLI)))).andReturn(null);
    ctrl.replay();
    for (int i = 0; i < 2; i++) {
        svc.clean(kc, cutoff, tx);
    }
    TimestampProviders.MILLI.sleepFor(wait.plusMillis(1));
    for (int i = 0; i < 2; i++) {
        svc.clean(kc, cutoff.plusMillis(1), tx);
    }
}
Also used : StandardLockCleanerService(org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerService) StandardLockCleanerRunnable(org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerRunnable) Instant(java.time.Instant) Duration(java.time.Duration) Test(org.junit.Test)

Aggregations

Instant (java.time.Instant)2 StandardLockCleanerRunnable (org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerRunnable)2 StandardLockCleanerService (org.janusgraph.diskstorage.locking.consistentkey.StandardLockCleanerService)2 Test (org.junit.Test)2 Duration (java.time.Duration)1