@Test public void releaseWithoutAcquireIsNoOp() { manager.releasePersistentLock(); verifyZeroInteractions(mockPls); }
public synchronized void releasePersistentLock() { if (lockId == null) { log.info("Called releasePersistentLock, but no lock has been taken! Returning."); return; } referenceCount--; if (referenceCount <= 0) { log.info("Releasing persistent lock {}", SafeArg.of("lockId", lockId)); try { persistentLockService.releaseBackupLock(lockId); lockId = null; } catch (CheckAndSetException e) { log.error("Failed to release persistent lock {}. The lock must have been released from under us. " + "Future sweeps should correctly be able to re-acquire the lock.", SafeArg.of("lockId", lockId), e); lockId = null; } } else { log.info("Not releasing the persistent lock, because {} threads still hold it.", SafeArg.of("numLockHolders", referenceCount)); } }
PersistentLockManager implements AutoCloseable { public synchronized void releasePersistentLock() { if (lockId == null) { log.info("Called releasePersistentLock, but no lock has been taken! Returning."); return; } referenceCount--; if (referenceCount <= 0) { log.info("Releasing persistent lock {}", SafeArg.of("lockId", lockId)); try { persistentLockService.releaseBackupLock(lockId); lockId = null; } catch (CheckAndSetException e) { log.error("Failed to release persistent lock {}. The lock must have been released from under us. " + "Future sweeps should correctly be able to re-acquire the lock.", SafeArg.of("lockId", lockId), e); lockId = null; } } else { log.info("Not releasing the persistent lock, because {} threads still hold it.", SafeArg.of("numLockHolders", referenceCount)); } } }
PersistentLockManager implements AutoCloseable { public synchronized void releasePersistentLock() { if (lockId == null) { log.info("Called releasePersistentLock, but no lock has been taken! Returning."); return; } referenceCount--; if (referenceCount <= 0) { log.info("Releasing persistent lock {}", SafeArg.of("lockId", lockId)); try { persistentLockService.releaseBackupLock(lockId); lockId = null; } catch (CheckAndSetException e) { log.error("Failed to release persistent lock {}. The lock must have been released from under us. " + "Future sweeps should correctly be able to re-acquire the lock.", SafeArg.of("lockId", lockId), e); lockId = null; } } else { log.info("Not releasing the persistent lock, because {} threads still hold it.", SafeArg.of("numLockHolders", referenceCount)); } } PersistentLockManager(MetricsManager metricsManager,
            PersistentLockService persistentLockService, long persistentLockRetryWaitMillis); }
PersistentLockManager implements AutoCloseable { public synchronized void releasePersistentLock() { if (lockId == null) { log.info("Called releasePersistentLock, but no lock has been taken! Returning."); return; } referenceCount--; if (referenceCount <= 0) { log.info("Releasing persistent lock {}", SafeArg.of("lockId", lockId)); try { persistentLockService.releaseBackupLock(lockId); lockId = null; } catch (CheckAndSetException e) { log.error("Failed to release persistent lock {}. The lock must have been released from under us. " + "Future sweeps should correctly be able to re-acquire the lock.", SafeArg.of("lockId", lockId), e); lockId = null; } } else { log.info("Not releasing the persistent lock, because {} threads still hold it.", SafeArg.of("numLockHolders", referenceCount)); } } PersistentLockManager(MetricsManager metricsManager,
            PersistentLockService persistentLockService, long persistentLockRetryWaitMillis); @Override void close(); synchronized void shutdown(); void acquirePersistentLockWithRetry(); synchronized void releasePersistentLock(); }
PersistentLockManager implements AutoCloseable { public synchronized void releasePersistentLock() { if (lockId == null) { log.info("Called releasePersistentLock, but no lock has been taken! Returning."); return; } referenceCount--; if (referenceCount <= 0) { log.info("Releasing persistent lock {}", SafeArg.of("lockId", lockId)); try { persistentLockService.releaseBackupLock(lockId); lockId = null; } catch (CheckAndSetException e) { log.error("Failed to release persistent lock {}. The lock must have been released from under us. " + "Future sweeps should correctly be able to re-acquire the lock.", SafeArg.of("lockId", lockId), e); lockId = null; } } else { log.info("Not releasing the persistent lock, because {} threads still hold it.", SafeArg.of("numLockHolders", referenceCount)); } } PersistentLockManager(MetricsManager metricsManager,
            PersistentLockService persistentLockService, long persistentLockRetryWaitMillis); @Override void close(); synchronized void shutdown(); void acquirePersistentLockWithRetry(); synchronized void releasePersistentLock();  }