summaryrefslogtreecommitdiffstats
path: root/zkfacade
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2022-10-14 20:14:56 +0200
committerGitHub <noreply@github.com>2022-10-14 20:14:56 +0200
commitf39215c119637a22eead1e7395bb48554828f5e4 (patch)
treea6745f268d1719aa40b3106985c3e41a1af53c64 /zkfacade
parent87161b06492619bb2dc7b89177445873bdf0c8c5 (diff)
parent296dc08b1b213b42c379f547325b923159afa07a (diff)
Merge pull request #24458 from vespa-engine/bjorncs/zk-lock-with-ttl
Support locks with TTL in ZK curator
Diffstat (limited to 'zkfacade')
-rw-r--r--zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java
index ab35ccf545e..ab0c77746fc 100644
--- a/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java
+++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/Curator.java
@@ -354,14 +354,17 @@ public class Curator extends AbstractComponent implements AutoCloseable {
}
}
- /** Create and acquire a re-entrant lock in given path */
- public Lock lock(Path path, Duration timeout) {
- create(path);
+ /** Create and acquire a re-entrant lock in given path with a TTL */
+ public Lock lock(Path path, Duration timeout, Duration ttl) {
+ create(path, ttl);
Lock lock = locks.computeIfAbsent(path, (pathArg) -> new Lock(pathArg.getAbsolute(), this));
lock.acquire(timeout);
return lock;
}
+ /** Create and acquire a re-entrant lock in given path */
+ public Lock lock(Path path, Duration timeout) { return lock(path, timeout, null); }
+
/** Returns the curator framework API */
public CuratorFramework framework() {
return curatorFramework;