Class Lock

  • All Implemented Interfaces:
    com.yahoo.transaction.Mutex, AutoCloseable

    public class Lock
    extends 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 through Curator.lock(Path, Duration) instead of constructing this directly.
    Author:
    bratseth
    • Constructor Detail

      • Lock

        public Lock​(String lockPath,
                    org.apache.curator.framework.recipes.locks.InterProcessLock mutex)
        Public for testing only
    • Method Detail

      • acquire

        public void acquire​(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 interface AutoCloseable
        Specified by:
        close in interface com.yahoo.transaction.Mutex