com.hazelcast.client.proxy
Class ClientLockProxy

java.lang.Object
  extended by com.hazelcast.client.spi.ClientProxy
      extended by com.hazelcast.client.proxy.ClientLockProxy
All Implemented Interfaces:
DistributedObject, ILock, Lock

public class ClientLockProxy
extends ClientProxy
implements ILock


Constructor Summary
ClientLockProxy(String serviceName, String objectId)
           
 
Method Summary
 void forceUnlock()
          Releases the lock regardless of the lock owner.
 Object getKey()
          Deprecated. 
 int getLockCount()
          Returns re-entrant lock hold count, regardless of lock ownership.
 long getRemainingLeaseTime()
          Returns remaining lease time in milliseconds.
protected
<T> T
invoke(ClientRequest req)
           
 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)
          
 void unlock()
          Releases the lock.
 
Methods inherited from class com.hazelcast.client.spi.ClientProxy
destroy, equals, getContext, getId, getName, getPartitionKey, getServiceName, hashCode, invoke, invoke, invokeInterruptibly, listen, listen, onDestroy, onInitialize, onShutdown, setContext, stopListening, throwExceptionIfNull, toData, toObject
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getId, getName, getPartitionKey, getServiceName
 

Constructor Detail

ClientLockProxy

public ClientLockProxy(String serviceName,
                       String objectId)
Method Detail

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.

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(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.

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

lock

public void lock()
Description copied from interface: ILock

Specified by:
lock in interface ILock
Specified by:
lock in interface Lock

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

unlock

public void unlock()
Description copied from interface: ILock
Releases the lock.

Specified by:
unlock in interface ILock
Specified by:
unlock in interface Lock

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

invoke

protected <T> T invoke(ClientRequest req)
Overrides:
invoke in class ClientProxy

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.