diff options
author | Harald Musum <musum@verizonmedia.com> | 2022-10-14 20:14:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-14 20:14:56 +0200 |
commit | f39215c119637a22eead1e7395bb48554828f5e4 (patch) | |
tree | a6745f268d1719aa40b3106985c3e41a1af53c64 /zkfacade | |
parent | 87161b06492619bb2dc7b89177445873bdf0c8c5 (diff) | |
parent | 296dc08b1b213b42c379f547325b923159afa07a (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.java | 9 |
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; |