@Test public void testGetLock() throws LockException { DistributedLock expectedLock = doReturnLockOnGetLock(); assertGetLockRetrievesExpectedLock(expectedLock); }
public DistributedLock getLock(String dataCenter, String resource, int priority, Map<String, String> metadata) throws LockException { LockKey lockKey = new LockKey(dataCenter, resource); Optional<LockException> cachedFailure = getCachedFailure(lockKey); if (cachedFailure.isPresent()) { throwCachedLockException(cachedFailure.get()); } try { return myLockSupplier.getLock(dataCenter, resource, priority, metadata); } catch (LockException e) { myFailureCache.put(lockKey, e); throw e; } }
LockCache { public DistributedLock getLock(String dataCenter, String resource, int priority, Map<String, String> metadata) throws LockException { LockKey lockKey = new LockKey(dataCenter, resource); Optional<LockException> cachedFailure = getCachedFailure(lockKey); if (cachedFailure.isPresent()) { throwCachedLockException(cachedFailure.get()); } try { return myLockSupplier.getLock(dataCenter, resource, priority, metadata); } catch (LockException e) { myFailureCache.put(lockKey, e); throw e; } } }
LockCache { public DistributedLock getLock(String dataCenter, String resource, int priority, Map<String, String> metadata) throws LockException { LockKey lockKey = new LockKey(dataCenter, resource); Optional<LockException> cachedFailure = getCachedFailure(lockKey); if (cachedFailure.isPresent()) { throwCachedLockException(cachedFailure.get()); } try { return myLockSupplier.getLock(dataCenter, resource, priority, metadata); } catch (LockException e) { myFailureCache.put(lockKey, e); throw e; } } LockCache(LockSupplier lockSupplier);   LockCache(LockSupplier lockSupplier, long expireTime, TimeUnit expireTimeUnit); }
LockCache { public DistributedLock getLock(String dataCenter, String resource, int priority, Map<String, String> metadata) throws LockException { LockKey lockKey = new LockKey(dataCenter, resource); Optional<LockException> cachedFailure = getCachedFailure(lockKey); if (cachedFailure.isPresent()) { throwCachedLockException(cachedFailure.get()); } try { return myLockSupplier.getLock(dataCenter, resource, priority, metadata); } catch (LockException e) { myFailureCache.put(lockKey, e); throw e; } } LockCache(LockSupplier lockSupplier);   LockCache(LockSupplier lockSupplier, long expireTime, TimeUnit expireTimeUnit); Optional<LockException> getCachedFailure(String dataCenter, String resource); DistributedLock getLock(String dataCenter, String resource, int priority, Map<String, String> metadata); }
LockCache { public DistributedLock getLock(String dataCenter, String resource, int priority, Map<String, String> metadata) throws LockException { LockKey lockKey = new LockKey(dataCenter, resource); Optional<LockException> cachedFailure = getCachedFailure(lockKey); if (cachedFailure.isPresent()) { throwCachedLockException(cachedFailure.get()); } try { return myLockSupplier.getLock(dataCenter, resource, priority, metadata); } catch (LockException e) { myFailureCache.put(lockKey, e); throw e; } } LockCache(LockSupplier lockSupplier);   LockCache(LockSupplier lockSupplier, long expireTime, TimeUnit expireTimeUnit); Optional<LockException> getCachedFailure(String dataCenter, String resource); DistributedLock getLock(String dataCenter, String resource, int priority, Map<String, String> metadata);  }