@Test void doesNotLockIfLockIsAlreadyObtained() { when(mockConsulClient.setKVValue(eq("naruto-leader"), any(), any(PutParams.class))) .thenReturn(new Response<>(false, null, null, null)); Optional<SimpleLock> lock = lockProvider.lock(lockConfig("naruto", SMALL_MIN_TTL, SMALL_MIN_TTL.dividedBy(2))); assertThat(lock).isEmpty(); }
@Override @NonNull public Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration) { String sessionId = createSession(lockConfiguration); return tryLock(sessionId, lockConfiguration); }
ConsulLockProvider implements LockProvider, AutoCloseable { @Override @NonNull public Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration) { String sessionId = createSession(lockConfiguration); return tryLock(sessionId, lockConfiguration); } }
ConsulLockProvider implements LockProvider, AutoCloseable { @Override @NonNull public Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration) { String sessionId = createSession(lockConfiguration); return tryLock(sessionId, lockConfiguration); } ConsulLockProvider(ConsulClient consulClient);  ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl);  ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl, String consulLockPostfix, Duration gracefulShutdownInterval); }
ConsulLockProvider implements LockProvider, AutoCloseable { @Override @NonNull public Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration) { String sessionId = createSession(lockConfiguration); return tryLock(sessionId, lockConfiguration); } ConsulLockProvider(ConsulClient consulClient);  ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl);  ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl, String consulLockPostfix, Duration gracefulShutdownInterval); @Override @NonNull Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration); @Override void close(); }
ConsulLockProvider implements LockProvider, AutoCloseable { @Override @NonNull public Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration) { String sessionId = createSession(lockConfiguration); return tryLock(sessionId, lockConfiguration); } ConsulLockProvider(ConsulClient consulClient);  ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl);  ConsulLockProvider(ConsulClient consulClient, Duration minSessionTtl, String consulLockPostfix, Duration gracefulShutdownInterval); @Override @NonNull Optional<SimpleLock> lock(@NonNull LockConfiguration lockConfiguration); @Override void close();  }