com.hazelcast.concurrent.lock

## Interface LockStore

- All Known Implementing Classes:
    LockStoreImpl, LockStoreProxy

      public interface LockStore

  A container for multiple locks. Each lock is differentiated by a different `key`.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canAcquireLock(Data key, String caller, long threadId)` Return if the key can be locked by the caller and thread ID.
    `boolean` | `extendLeaseTime(Data key, String caller, long threadId, long leaseTime)` Extend the lease time for an already locked key.
    `boolean` | `forceUnlock(Data dataKey)` Unlock the key regardless of the owner.
    `int` | `getLockCount(Data key)` Return the number of times a key was locked by the same owner (re-entered).
    `int` | `getLockedEntryCount()` Return the number of locks this store holds.
    `Set<Data>` | `getLockedKeys()` Return all locked keys for this store.
    `String` | `getOwnerInfo(Data dataKey)` Return a string representation of the owner of the lock for a specific key.
    `long` | `getRemainingLeaseTime(Data key)` Return the remaining lease time for a specific key.
    `boolean` | `isLocked(Data key)` Check if a key is locked by any caller and thread ID.
    `boolean` | `isLockedBy(Data key, String caller, long threadId)` Check if a key is locked by a specific caller and thread ID.
    `boolean` | `localLock(Data key, String caller, long threadId, long referenceId, long leaseTime)` Lock a specific key on a local partition only.
    `boolean` | `lock(Data key, String caller, long threadId, long referenceId, long leaseTime)` Lock a specific key.
    `boolean` | `shouldBlockReads(Data key)` Return whether the reads for the specific key should be blocked (see `txnLock(Data, String, long, long, long, boolean)`).
    `boolean` | `txnLock(Data key, String caller, long threadId, long referenceId, long leaseTime, boolean blockReads)` Lock a specific key for use inside a transaction.
    `boolean` | `unlock(Data key, String caller, long threadId, long referenceId)` Unlock a specific key.

- - ### Method Detail

    - #### lock

          boolean lock(Data key,
                       String caller,
                       long threadId,
                       long referenceId,
                       long leaseTime)

      Lock a specific key.
      Parameters:
        `key` - the key to lock
        `caller` - the identifier for the caller
        `threadId` - the identifier for the thread on the caller
        `referenceId` - the identifier for the invocation of the caller (e.g. operation call ID)
        `leaseTime` - the lease duration in milliseconds
      Returns:
        if the lock was successfully acquired

    - #### localLock

          boolean localLock(Data key,
                            String caller,
                            long threadId,
                            long referenceId,
                            long leaseTime)

      Lock a specific key on a local partition only. Does not observe LOCK_MAX_LEASE_TIME_SECONDS
      Parameters:
        `key` - the key to lock
        `caller` - the identifier for the caller
        `threadId` - the identifier for the thread on the caller
        `referenceId` - the identifier for the invocation of the caller (e.g. operation call ID)
        `leaseTime` - the lease duration in milliseconds
      Returns:
        if the lock was successfully acquired
      See Also:
        `GroupProperty.LOCK_MAX_LEASE_TIME_SECONDS`

    - #### txnLock

          boolean txnLock(Data key,
                          String caller,
                          long threadId,
                          long referenceId,
                          long leaseTime,
                          boolean blockReads)

      Lock a specific key for use inside a transaction.
      Parameters:
        `key` - the key to lock
        `caller` - the identifier for the caller
        `threadId` - the identifier for the thread on the caller
        `referenceId` - the identifier for the invocation of the caller (e.g. operation call ID)
        `leaseTime` - the lease duration in milliseconds
        `blockReads` - whether reads for the key should be blocked (e.g. for map and multimap)
      Returns:
        if the lock was successfully acquired

    - #### extendLeaseTime

          boolean extendLeaseTime(Data key,
                                  String caller,
                                  long threadId,
                                  long leaseTime)

      Extend the lease time for an already locked key.
      Parameters:
        `key` - the locked key
        `caller` - the identifier for the caller
        `threadId` - the identifier for the thread on the caller
        `leaseTime` - time in milliseconds for the lease to be extended
      Returns:
        if the lease was extended

    - #### unlock

          boolean unlock(Data key,
                         String caller,
                         long threadId,
                         long referenceId)

      Unlock a specific key.
      Parameters:
        `key` - the locked key
        `caller` - the identifier for the caller
        `threadId` - the identifier for the thread on the caller
        `referenceId` - the identifier for the invocation of the caller (e.g. operation call ID)
      Returns:
        if the key was unlocked

    - #### isLocked

          boolean isLocked(Data key)

      Check if a key is locked by any caller and thread ID.
      Parameters:
        `key` - the key
      Returns:
        if the key is locked

    - #### isLockedBy

          boolean isLockedBy(Data key,
                             String caller,
                             long threadId)

      Check if a key is locked by a specific caller and thread ID.
      Parameters:
        `key` - the locked key
        `caller` - the identifier for the caller
        `threadId` - the identifier for the thread on the caller
      Returns:
        if the key is locked

    - #### getLockCount

          int getLockCount(Data key)

      Return the number of times a key was locked by the same owner (re-entered).
      Parameters:
        `key` - the key
      Returns:
        the reentry count

    - #### getLockedEntryCount

          int getLockedEntryCount()

      Return the number of locks this store holds.
      Returns:
        the lock count

    - #### getRemainingLeaseTime

          long getRemainingLeaseTime(Data key)

      Return the remaining lease time for a specific key.
      Parameters:
        `key` - the key
      Returns:
        the lease time in milliseconds, -1 if there is no lock, if the key is locked indefinitely

    - #### canAcquireLock

          boolean canAcquireLock(Data key,
                                 String caller,
                                 long threadId)

      Return if the key can be locked by the caller and thread ID.
      Parameters:
        `key` - the locked key
        `caller` - the identifier for the caller
        `threadId` - the identifier for the thread on the caller
      Returns:
        if the key can be locked. Returns false if the key is already locked by a different caller or thread ID

    - #### shouldBlockReads

          boolean shouldBlockReads(Data key)

      Return whether the reads for the specific key should be blocked (see `txnLock(Data, String, long, long, long, boolean)`).
      Parameters:
        `key` - the lock key
      Returns:
        if the reads should be blocked

    - #### getLockedKeys

          Set<Data> getLockedKeys()

      Return all locked keys for this store. A lock may be expired when this method returns.
      Returns:
        all locked keys

    - #### forceUnlock

          boolean forceUnlock(Data dataKey)

      Unlock the key regardless of the owner. May return `true` if the key is already unlocked but has waiters/signals/expired operations.
      Parameters:
        `dataKey` - the lock key
      Returns:
        `false` if there is no lock for the given `key` and `true` otherwise

    - #### getOwnerInfo

          String getOwnerInfo(Data dataKey)

      Return a string representation of the owner of the lock for a specific key. If the key is not locked returns a default string depicting no owner.
      Parameters:
        `dataKey` - the key
      Returns:
        a string description/representation of the owner

Copyright © 2019. All rights reserved.