Class Lock

java.lang.Object
com.yahoo.vespa.curator.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 Details

    • Lock

      public Lock(String lockPath, Curator curator)
    • Lock

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

    • acquire

      public void acquire(Duration timeout) throws com.yahoo.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.yahoo.concurrent.UncheckedTimeoutException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface com.yahoo.transaction.Mutex
    • lockPath

      protected String lockPath()
    • toString

      public String toString()
      Overrides:
      toString in class Object