com.hazelcast.concurrent.lock

## Class LockProxy

- java.lang.Object
- - com.hazelcast.spi.AbstractDistributedObject<LockServiceImpl>
  - - com.hazelcast.concurrent.lock.LockProxy

- All Implemented Interfaces:
    DistributedObject, ILock, Lock

      public class LockProxy
      extends AbstractDistributedObject<LockServiceImpl>
      implements ILock

- - ### Field Summary

    - ### Fields inherited from class com.hazelcast.spi.AbstractDistributedObject

      `PARTITIONING_STRATEGY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LockProxy(NodeEngine nodeEngine, LockServiceImpl lockService, String name)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `forceUnlock()` Releases the lock regardless of the lock owner.
    `Object` | `getKey()` Deprecated.
    `Data` | `getKeyData()`
    `int` | `getLockCount()` Returns re-entrant lock hold count, regardless of lock ownership.
    `String` | `getName()` Returns the unique name for this DistributedObject.
    `int` | `getPartitionId()`
    `long` | `getRemainingLeaseTime()` Returns remaining lease time in milliseconds.
    `String` | `getServiceName()` Returns the service name for this object.
    `boolean` | `isLocked()` Returns whether this lock is locked or not.
    `boolean` | `isLockedByCurrentThread()` Returns whether this lock is locked by current thread or not.
    `void` | `lock()`
    `void` | `lock(long leaseTime, TimeUnit timeUnit)` Acquires the lock for the specified lease time.
    `void` | `lockInterruptibly()`
    `Condition` | `newCondition()` This method is not implemented! Use `ILock.newCondition(String)` instead.
    `ICondition` | `newCondition(String name)` Returns a new `ICondition` instance that is bound to this `ILock` instance with given name.
    `String` | `toString()`
    `boolean` | `tryLock()`
    `boolean` | `tryLock(long time, TimeUnit unit)`
    `boolean` | `tryLock(long time, TimeUnit unit, long leaseTime, TimeUnit leaseUnit)` Tries to acquire the lock for the specified lease time.
    `void` | `unlock()` Releases the lock.

    - ### Methods inherited from class com.hazelcast.spi.AbstractDistributedObject

      `destroy, equals, getDistributedObjectName, getNameAsPartitionAwareData, getNodeEngine, getOperationService, getPartitionId, getPartitionKey, getService, hashCode, invalidate, invokeOnPartition, postDestroy, preDestroy, throwNotActiveException, toData`

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

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

    - ### Methods inherited from interface com.hazelcast.core.DistributedObject

      `destroy, getPartitionKey`

- - ### Constructor Detail

    - #### LockProxy

          public LockProxy(NodeEngine nodeEngine,
                           LockServiceImpl lockService,
                           String name)

  - ### Method Detail

    - #### isLocked

          public boolean isLocked()

      Description copied from interface: `ILock`
      Returns whether this lock is locked or not.
      Specified by:
        `isLocked` in interface `ILock`
      Returns:
        `true` if this lock is locked, `false` otherwise.

    - #### isLockedByCurrentThread

          public boolean isLockedByCurrentThread()

      Description copied from interface: `ILock`
      Returns whether this lock is locked by current thread or not.
      Specified by:
        `isLockedByCurrentThread` in interface `ILock`
      Returns:
        `true` if this lock is locked by current thread, `false` otherwise.

    - #### getLockCount

          public int getLockCount()

      Description copied from interface: `ILock`
      Returns re-entrant lock hold count, regardless of lock ownership.
      Specified by:
        `getLockCount` in interface `ILock`
      Returns:
        the lock hold count.

    - #### getRemainingLeaseTime

          public long getRemainingLeaseTime()

      Description copied from interface: `ILock`
      Returns remaining lease time in milliseconds. If the lock is not locked then -1 will be returned.
      Specified by:
        `getRemainingLeaseTime` in interface `ILock`
      Returns:
        remaining lease time in milliseconds.

    - #### lock

          public void lock()

      Description copied from interface: `ILock`
      Specified by:
        `lock` in interface `ILock`
      Specified by:
        `lock` in interface `Lock`

    - #### lock

          public void lock(long leaseTime,
                           TimeUnit timeUnit)

      Description copied from interface: `ILock`
      Acquires the lock for the specified lease time.

      After lease time, lock will be released..

      If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.

      Specified by:
        `lock` in interface `ILock`
      Parameters:
        `leaseTime` - time to wait before releasing the lock.
        `timeUnit` - unit of time for the lease time.

    - #### lockInterruptibly

          public void lockInterruptibly()
                                 throws InterruptedException

      Specified by:
        `lockInterruptibly` in interface `Lock`
      Throws:
        `InterruptedException`

    - #### tryLock

          public boolean tryLock()

      Description copied from interface: `ILock`
      Specified by:
        `tryLock` in interface `ILock`
      Specified by:
        `tryLock` in interface `Lock`

    - #### tryLock

          public boolean tryLock(long time,
                                 TimeUnit unit)
                          throws InterruptedException

      Description copied from interface: `ILock`
      Specified by:
        `tryLock` in interface `ILock`
      Specified by:
        `tryLock` in interface `Lock`
      Throws:
        `InterruptedException`

    - #### tryLock

          public boolean tryLock(long time,
                                 TimeUnit unit,
                                 long leaseTime,
                                 TimeUnit leaseUnit)
                          throws InterruptedException

      Description copied from interface: `ILock`
      Tries to acquire the lock for the specified lease time.

      After lease time, the lock will be released.

      If the lock is not available, then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:

      - the lock is acquired by the current thread, or
      - the specified waiting time elapses.
      Specified by:
        `tryLock` in interface `ILock`
      Parameters:
        `time` - maximum time to wait for the lock.
        `unit` - time unit of the `time` argument.
        `leaseTime` - time to wait before releasing the lock.
        `leaseUnit` - unit of time to specify lease time.
      Returns:
        `true` if the lock was acquired and `false` if the waiting time elapsed before the lock was acquired.
      Throws:
        `InterruptedException`

    - #### unlock

          public void unlock()

      Description copied from interface: `ILock`
      Releases the lock.
      Specified by:
        `unlock` in interface `ILock`
      Specified by:
        `unlock` in interface `Lock`

    - #### forceUnlock

          public void forceUnlock()

      Description copied from interface: `ILock`
      Releases the lock regardless of the lock owner. It always successfully unlocks, never blocks, and returns immediately.
      Specified by:
        `forceUnlock` in interface `ILock`

    - #### newCondition

          public Condition newCondition()

      Description copied from interface: `ILock`
      This method is not implemented! Use `ILock.newCondition(String)` instead.
      Specified by:
        `newCondition` in interface `ILock`
      Specified by:
        `newCondition` in interface `Lock`

    - #### newCondition

          public ICondition newCondition(String name)

      Description copied from interface: `ILock`
      Returns a new `ICondition` instance that is bound to this `ILock` instance with given name.

      Before waiting on the condition the lock must be held by the current thread. A call to `Condition.await()` will atomically release the lock before waiting and re-acquire the lock before the wait returns.

      Specified by:
        `newCondition` in interface `ILock`
      Parameters:
        `name` - identifier of the new condition instance
      Returns:
        A new `ICondition` instance for this `ILock` instance

    - #### getName

          public String getName()

      Description copied from interface: `DistributedObject`
      Returns the unique name for this DistributedObject. The returned value will never be null. The suggested way for getting name is retrieving it through `DistributedObjectUtil.getName(DistributedObject)` because this might be also a `PrefixedDistributedObject`.
      Specified by:
        `getName` in interface `DistributedObject`
      Returns:
        the unique name for this object.

    - #### getServiceName

          public String getServiceName()

      Description copied from interface: `DistributedObject`
      Returns the service name for this object.
      Specified by:
        `getServiceName` in interface `DistributedObject`
      Specified by:
        `getServiceName` in class `AbstractDistributedObject<LockServiceImpl>`
      Returns:
        the service name for this object.

    - #### getKey

          @Deprecated
          public Object getKey()

      Deprecated.
      Description copied from interface: `ILock`
      Returns the lock object, the key for this lock instance.
      Specified by:
        `getKey` in interface `ILock`
      Returns:
        lock object.

    - #### getKeyData

          public Data getKeyData()

    - #### getPartitionId

          public int getPartitionId()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `AbstractDistributedObject<LockServiceImpl>`

Copyright © 2018. All rights reserved.