com.hazelcast.concurrent.lock

## Class LockStoreProxy

- java.lang.Object
- - com.hazelcast.concurrent.lock.LockStoreProxy

- All Implemented Interfaces:
    LockStore

      public final class LockStoreProxy
      extends Object
      implements LockStore

  Proxy to a `LockStoreImpl`. Since a `LockStoreImpl` may be destroyed upon service reset (eg. after a split-brain is healed), some of this proxy's methods employ get-or-create to locate the `LockStoreImpl` or get-or-null when creation of the `LockStoreImpl` is not required and its absence is interpreted as "no lock exists".

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LockStoreProxy(LockStoreContainer container, ObjectNamespace namespace)`

  - ### Method Summary

    All Methods Instance Methods Concrete 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 key)` 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 `LockStore.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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LockStoreProxy

          public LockStoreProxy(LockStoreContainer container,
                                ObjectNamespace namespace)

  - ### Method Detail

    - #### lock

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

      Description copied from interface: `LockStore`
      Lock a specific key.
      Specified by:
        `lock` in interface `LockStore`
      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

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

      Description copied from interface: `LockStore`
      Lock a specific key on a local partition only. Does not observe LOCK_MAX_LEASE_TIME_SECONDS
      Specified by:
        `localLock` in interface `LockStore`
      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

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

      Description copied from interface: `LockStore`
      Lock a specific key for use inside a transaction.
      Specified by:
        `txnLock` in interface `LockStore`
      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

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

      Description copied from interface: `LockStore`
      Extend the lease time for an already locked key.
      Specified by:
        `extendLeaseTime` in interface `LockStore`
      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

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

      Description copied from interface: `LockStore`
      Unlock a specific key.
      Specified by:
        `unlock` in interface `LockStore`
      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

          public boolean isLocked(Data key)

      Description copied from interface: `LockStore`
      Check if a key is locked by any caller and thread ID.
      Specified by:
        `isLocked` in interface `LockStore`
      Parameters:
        `key` - the key
      Returns:
        if the key is locked

    - #### isLockedBy

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

      Description copied from interface: `LockStore`
      Check if a key is locked by a specific caller and thread ID.
      Specified by:
        `isLockedBy` in interface `LockStore`
      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

          public int getLockCount(Data key)

      Description copied from interface: `LockStore`
      Return the number of times a key was locked by the same owner (re-entered).
      Specified by:
        `getLockCount` in interface `LockStore`
      Parameters:
        `key` - the key
      Returns:
        the reentry count

    - #### getLockedEntryCount

          public int getLockedEntryCount()

      Description copied from interface: `LockStore`
      Return the number of locks this store holds.
      Specified by:
        `getLockedEntryCount` in interface `LockStore`
      Returns:
        the lock count

    - #### getRemainingLeaseTime

          public long getRemainingLeaseTime(Data key)

      Description copied from interface: `LockStore`
      Return the remaining lease time for a specific key.
      Specified by:
        `getRemainingLeaseTime` in interface `LockStore`
      Parameters:
        `key` - the key
      Returns:
        the lease time in milliseconds, -1 if there is no lock, if the key is locked indefinitely

    - #### canAcquireLock

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

      Description copied from interface: `LockStore`
      Return if the key can be locked by the caller and thread ID.
      Specified by:
        `canAcquireLock` in interface `LockStore`
      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

          public boolean shouldBlockReads(Data key)

      Description copied from interface: `LockStore`
      Return whether the reads for the specific key should be blocked (see `LockStore.txnLock(Data, String, long, long, long, boolean)`).
      Specified by:
        `shouldBlockReads` in interface `LockStore`
      Parameters:
        `key` - the lock key
      Returns:
        if the reads should be blocked

    - #### getLockedKeys

          public Set<Data> getLockedKeys()

      Description copied from interface: `LockStore`
      Return all locked keys for this store. A lock may be expired when this method returns.
      Specified by:
        `getLockedKeys` in interface `LockStore`
      Returns:
        all locked keys

    - #### forceUnlock

          public boolean forceUnlock(Data key)

      Description copied from interface: `LockStore`
      Unlock the key regardless of the owner. May return `true` if the key is already unlocked but has waiters/signals/expired operations.
      Specified by:
        `forceUnlock` in interface `LockStore`
      Parameters:
        `key` - the lock key
      Returns:
        `false` if there is no lock for the given `key` and `true` otherwise

    - #### getOwnerInfo

          public String getOwnerInfo(Data dataKey)

      Description copied from interface: `LockStore`
      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.
      Specified by:
        `getOwnerInfo` in interface `LockStore`
      Parameters:
        `dataKey` - the key
      Returns:
        a string description/representation of the owner

Copyright © 2019. All rights reserved.