com.hazelcast.concurrent.lock

## Class LockStoreImpl

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

- All Implemented Interfaces:
    LockStore, DataSerializable, IdentifiedDataSerializable, com.hazelcast.nio.serialization.impl.Versioned

      public final class LockStoreImpl
      extends Object
      implements IdentifiedDataSerializable, LockStore, com.hazelcast.nio.serialization.impl.Versioned

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LockStoreImpl()`
    `LockStoreImpl(LockService lockService, ObjectNamespace name, EntryTaskScheduler<Data,Integer> entryTaskScheduler, int backupCount, int asyncBackupCount)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAwait(Data key, String conditionId, String caller, long threadId)`
    `boolean` | `canAcquireLock(Data key, String caller, long threadId)` Return if the key can be locked by the caller and thread ID.
    `void` | `clear()`
    `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` | `getAsyncBackupCount()`
    `int` | `getBackupCount()`
    `int` | `getFactoryId()` Returns DataSerializableFactory factory ID for this class.
    `int` | `getId()` Returns type identifier for this class.
    `com.hazelcast.concurrent.lock.LockResourceImpl` | `getLock(Data key)`
    `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.
    `Collection<LockResource>` | `getLocks()`
    `ObjectNamespace` | `getNamespace()`
    `WaitNotifyKey` | `getNotifiedKey(Data key)`
    `String` | `getOwnerInfo(Data key)` 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.
    `int` | `getTotalBackupCount()`
    `int` | `getVersion(Data key)`
    `boolean` | `hasLock()`
    `boolean` | `hasSignalKey(ConditionKey conditionKey)`
    `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.
    `AwaitOperation` | `pollExpiredAwaitOp(Data key)`
    `void` | `readData(ObjectDataInput in)` Reads fields from the input stream
    `void` | `registerExpiredAwaitOp(AwaitOperation awaitResponse)`
    `void` | `removeAwait(Data key, String conditionId, String caller, long threadId)`
    `void` | `removeLocalLocks()`
    `void` | `removeSignalKey(ConditionKey conditionKey)`
    `boolean` | `shouldBlockReads(Data key)` Return whether the reads for the specific key should be blocked (see `LockStore.txnLock(Data, String, long, long, long, boolean)`).
    `void` | `signal(Data key, String conditionId, int maxSignalCount, String objectName)`
    `String` | `toString()`
    `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.
    `void` | `writeData(ObjectDataOutput out)` Writes object fields to output stream

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

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

- - ### Constructor Detail

    - #### LockStoreImpl

          public LockStoreImpl()

    - #### LockStoreImpl

          public LockStoreImpl(LockService lockService,
                               ObjectNamespace name,
                               EntryTaskScheduler<Data,Integer> entryTaskScheduler,
                               int backupCount,
                               int asyncBackupCount)

  - ### 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

    - #### getLock

          public com.hazelcast.concurrent.lock.LockResourceImpl getLock(Data key)

    - #### 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

    - #### 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

    - #### 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

    - #### getVersion

          public int getVersion(Data key)

    - #### getLocks

          public Collection<LockResource> getLocks()

    - #### removeLocalLocks

          public void removeLocalLocks()

    - #### 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

    - #### hasLock

          public boolean hasLock()

    - #### clear

          public void clear()

    - #### getNamespace

          public ObjectNamespace getNamespace()

    - #### getBackupCount

          public int getBackupCount()

    - #### getAsyncBackupCount

          public int getAsyncBackupCount()

    - #### getTotalBackupCount

          public int getTotalBackupCount()

    - #### addAwait

          public void addAwait(Data key,
                               String conditionId,
                               String caller,
                               long threadId)

    - #### removeAwait

          public void removeAwait(Data key,
                                  String conditionId,
                                  String caller,
                                  long threadId)

    - #### signal

          public void signal(Data key,
                             String conditionId,
                             int maxSignalCount,
                             String objectName)

    - #### getNotifiedKey

          public WaitNotifyKey getNotifiedKey(Data key)

    - #### removeSignalKey

          public void removeSignalKey(ConditionKey conditionKey)

    - #### hasSignalKey

          public boolean hasSignalKey(ConditionKey conditionKey)

    - #### registerExpiredAwaitOp

          public void registerExpiredAwaitOp(AwaitOperation awaitResponse)

    - #### pollExpiredAwaitOp

          public AwaitOperation pollExpiredAwaitOp(Data key)

    - #### getOwnerInfo

          public String getOwnerInfo(Data key)

      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:
        `key` - the key
      Returns:
        a string description/representation of the owner

    - #### getFactoryId

          public int getFactoryId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns DataSerializableFactory factory ID for this class.
      Specified by:
        `getFactoryId` in interface `IdentifiedDataSerializable`
      Returns:
        factory ID

    - #### getId

          public int getId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns type identifier for this class. It should be unique per DataSerializableFactory.
      Specified by:
        `getId` in interface `IdentifiedDataSerializable`
      Returns:
        type ID

    - #### writeData

          public void writeData(ObjectDataOutput out)
                         throws IOException

      Description copied from interface: `DataSerializable`
      Writes object fields to output stream
      Specified by:
        `writeData` in interface `DataSerializable`
      Parameters:
        `out` - output
      Throws:
        `IOException` - if an I/O error occurs. In particular, an `IOException` may be thrown if the output stream has been closed.

    - #### readData

          public void readData(ObjectDataInput in)
                        throws IOException

      Description copied from interface: `DataSerializable`
      Reads fields from the input stream
      Specified by:
        `readData` in interface `DataSerializable`
      Parameters:
        `in` - input
      Throws:
        `IOException` - if an I/O error occurs. In particular, an `IOException` may be thrown if the input stream has been closed.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2020. All rights reserved.