Package com.yahoo.vespa.curator
Class Lock
- java.lang.Object
-
- com.yahoo.vespa.curator.Lock
-
- All Implemented Interfaces:
com.yahoo.transaction.Mutex
,java.lang.AutoCloseable
public class Lock extends java.lang.Object implements com.yahoo.transaction.Mutex
A cluster-wide re-entrant mutex which is released on (the last symmetric) close. Re-entrancy is limited to the instance of this. To ensure re-entrancy callers should access the lock throughCurator.lock(Path, Duration)
instead of constructing this directly.- Author:
- bratseth
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acquire(java.time.Duration timeout)
Take the lock with the given timeout.void
close()
-
-
-
Constructor Detail
-
Lock
public Lock(java.lang.String lockPath, Curator curator)
-
Lock
public Lock(java.lang.String lockPath, org.apache.curator.framework.recipes.locks.InterProcessLock mutex)
Public for testing only
-
-
Method Detail
-
acquire
public void acquire(java.time.Duration timeout) throws com.google.common.util.concurrent.UncheckedTimeoutException
Take the lock with the given timeout. This may be called multiple times from the same thread - each matched by a close- Throws:
com.google.common.util.concurrent.UncheckedTimeoutException
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacecom.yahoo.transaction.Mutex
-
-