Class InMemoryLockManager.ElementLock

java.lang.Object
de.calamanari.pk.coarsegrainedlock.InMemoryLockManager.ElementLock
Enclosing class:
InMemoryLockManager

public static final class InMemoryLockManager.ElementLock
extends java.lang.Object
Implementation of an immutable element lock with metadata and option to wait for release
  • Method Summary

    Modifier and Type Method Description
    void await()
    Client's may use this method to wait until the related lock was released.
    Afterwards the client does not own any lock, a new attempt to acquire must follow.
    boolean await​(long timeout, java.util.concurrent.TimeUnit unit)
    Client's may use this method to wait until the related lock was released.
    Afterwards the client does not own any lock, a new attempt to acquire must follow.
    java.lang.String getElementId()
    Returns the id of the locked element
    InMemoryLockManager.LockType getLockType()
    Returns the lock's type
    java.util.List<java.lang.String> getOwnerIds()
    Returns the list of lock owners
    boolean isEngaged()
    Determines whether this lock is still engaged
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • await

      public void await() throws java.lang.InterruptedException
      Client's may use this method to wait until the related lock was released.
      Afterwards the client does not own any lock, a new attempt to acquire must follow.
      Throws:
      java.lang.InterruptedException - pass-through from waiting
    • await

      public boolean await​(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
      Client's may use this method to wait until the related lock was released.
      Afterwards the client does not own any lock, a new attempt to acquire must follow.
      Parameters:
      timeout - milliseconds
      unit - the unit of measurement
      Returns:
      true if the lock was released before timeout, otherwise false
      Throws:
      java.lang.InterruptedException - pass-through from waiting
    • isEngaged

      public boolean isEngaged()
      Determines whether this lock is still engaged
      Returns:
      true if lock is engaged otherwise false
    • getLockType

      Returns the lock's type
      Returns:
      type of the lock
    • getElementId

      public java.lang.String getElementId()
      Returns the id of the locked element
      Returns:
      elementId
    • getOwnerIds

      public java.util.List<java.lang.String> getOwnerIds()
      Returns the list of lock owners
      Returns:
      list of lock owners
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object