@Test public void testAcquireLockWithExtension() throws InterruptedException { boolean acquireResult = dynoLockClient.acquireLock(resource, 500, (rsc) -> {}); Assert.assertTrue("Failed to acquire lock on resource", acquireResult); Thread.sleep(3000); Assert.assertTrue(dynoLockClient.checkLock(resource) > 0); dynoLockClient.releaseLock(resource); Assert.assertTrue(dynoLockClient.checkLock(resource) == 0); }
private boolean acquireLockWithExtension(String resource, long ttlMS, Consumer<String> extensionFailedCallback) { long acquireResult = acquireLock(resource, ttlMS); if (acquireResult > 0) { Timer runJob = new Timer(resource, true); runJob.schedule(getExtensionTask(runJob, resource, ttlMS, extensionFailedCallback), acquireResult/2); return true; } return false; }
DynoLockClient { private boolean acquireLockWithExtension(String resource, long ttlMS, Consumer<String> extensionFailedCallback) { long acquireResult = acquireLock(resource, ttlMS); if (acquireResult > 0) { Timer runJob = new Timer(resource, true); runJob.schedule(getExtensionTask(runJob, resource, ttlMS, extensionFailedCallback), acquireResult/2); return true; } return false; } }
DynoLockClient { private boolean acquireLockWithExtension(String resource, long ttlMS, Consumer<String> extensionFailedCallback) { long acquireResult = acquireLock(resource, ttlMS); if (acquireResult > 0) { Timer runJob = new Timer(resource, true); runJob.schedule(getExtensionTask(runJob, resource, ttlMS, extensionFailedCallback), acquireResult/2); return true; } return false; } DynoLockClient(ConnectionPool pool, VotingHostsSelector votingHostsSelector, long timeout, TimeUnit unit); }
DynoLockClient { private boolean acquireLockWithExtension(String resource, long ttlMS, Consumer<String> extensionFailedCallback) { long acquireResult = acquireLock(resource, ttlMS); if (acquireResult > 0) { Timer runJob = new Timer(resource, true); runJob.schedule(getExtensionTask(runJob, resource, ttlMS, extensionFailedCallback), acquireResult/2); return true; } return false; } DynoLockClient(ConnectionPool pool, VotingHostsSelector votingHostsSelector, long timeout, TimeUnit unit); void setTimeoutUnit(TimeUnit timeoutUnit); void setTimeout(long timeout); List<String> getLockedResources(); void releaseLock(String resource); boolean acquireLock(String resource, long ttlMS, Consumer<String> failure); long acquireLock(String resource, long ttlMS); long checkLock(String resource); long extendLock(String resource, long ttlMS); void cleanup(); void logLocks(); }
DynoLockClient { private boolean acquireLockWithExtension(String resource, long ttlMS, Consumer<String> extensionFailedCallback) { long acquireResult = acquireLock(resource, ttlMS); if (acquireResult > 0) { Timer runJob = new Timer(resource, true); runJob.schedule(getExtensionTask(runJob, resource, ttlMS, extensionFailedCallback), acquireResult/2); return true; } return false; } DynoLockClient(ConnectionPool pool, VotingHostsSelector votingHostsSelector, long timeout, TimeUnit unit); void setTimeoutUnit(TimeUnit timeoutUnit); void setTimeout(long timeout); List<String> getLockedResources(); void releaseLock(String resource); boolean acquireLock(String resource, long ttlMS, Consumer<String> failure); long acquireLock(String resource, long ttlMS); long checkLock(String resource); long extendLock(String resource, long ttlMS); void cleanup(); void logLocks();  }