summaryrefslogtreecommitdiffstats
path: root/zkfacade
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2022-04-07 12:38:08 +0200
committerHarald Musum <musum@yahooinc.com>2022-04-07 12:38:08 +0200
commit9df474ac3e157f618fd2451ea46e11b7a1d071d5 (patch)
tree38b079a3d30ceb11871ea5e20fdcda00f39bbd4b /zkfacade
parenta4a4fadd9a2da2d0a3dfbec9a08ab33167089e0c (diff)
Acquire locks in constructor and add some logging
Diffstat (limited to 'zkfacade')
-rw-r--r--zkfacade/src/main/java/com/yahoo/vespa/curator/MultiplePathsLock.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/MultiplePathsLock.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/MultiplePathsLock.java
index 65ae77c8ffa..9576f5c0385 100644
--- a/zkfacade/src/main/java/com/yahoo/vespa/curator/MultiplePathsLock.java
+++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/MultiplePathsLock.java
@@ -1,39 +1,39 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.curator;
-import com.yahoo.concurrent.UncheckedTimeoutException;
import com.yahoo.path.Path;
import java.time.Duration;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* Class that holds two locks, originally used for transitioning from one lock to
* another, where you need to hold both the old lock and the new lock in the
- * transition period.
+ * transition period. Locks are acquired in constructor.
*
* @author hmusum
*/
public class MultiplePathsLock extends Lock {
+ private static final Logger log = Logger.getLogger(MultiplePathsLock.class.getName());
+
private final Lock oldLock;
- private final Lock newLock;
public MultiplePathsLock(Path newLockPath, Path oldLockPath, Duration timeout, Curator curator) {
super(newLockPath.getAbsolute(), curator);
- this.newLock = curator.lock(newLockPath, timeout);
+ log.log(Level.INFO, "Acquiring lock " + oldLockPath);
this.oldLock = curator.lock(oldLockPath, timeout);;
- }
-
- @Override
- public void acquire(Duration timeout) throws UncheckedTimeoutException {
- oldLock.acquire(timeout);
- newLock.acquire(timeout);
+ log.log(Level.INFO, "Acquiring lock " + lockPath());
+ super.acquire(timeout);
}
@Override
public void close() {
+ log.log(Level.INFO, "Closing lock " + oldLock.lockPath());
oldLock.close();
- newLock.close();
+ log.log(Level.INFO, "Closing lock " + lockPath());
+ super.close();
}
}