public class ClientLockProxy extends ClientProxy implements ILock
name
Constructor and Description |
---|
ClientLockProxy(String serviceName,
String objectId) |
Modifier and Type | Method and Description |
---|---|
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 ClientMessage |
invokeOnPartition(ClientMessage req) |
protected <T> T |
invokeOnPartitionInterruptibly(ClientMessage clientMessage) |
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. |
protected void |
onInitialize()
Called when proxy is created.
|
String |
toString() |
boolean |
tryLock() |
boolean |
tryLock(long timeout,
TimeUnit unit) |
boolean |
tryLock(long timeout,
TimeUnit unit,
long leaseTime,
TimeUnit leaseUnit)
Tries to acquire the lock for the specified lease time.
|
void |
unlock()
Releases the lock.
|
deregisterListener, destroy, equals, getClient, getContext, getId, getName, getPartitionKey, getServiceName, hashCode, invoke, invoke, invokeOnPartition, invokeOnPartitionInterruptibly, onDestroy, onShutdown, registerListener, setContext, throwExceptionIfNull, toData, toObject
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
destroy, getName, getPartitionKey, getServiceName
@Deprecated public Object getKey()
ILock
public boolean isLocked()
ILock
public boolean isLockedByCurrentThread()
ILock
isLockedByCurrentThread
in interface ILock
true
if this lock is locked by current thread, false
otherwise.public int getLockCount()
ILock
getLockCount
in interface ILock
public long getRemainingLeaseTime()
ILock
getRemainingLeaseTime
in interface ILock
public void lock(long leaseTime, TimeUnit timeUnit)
ILock
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.
public void forceUnlock()
ILock
forceUnlock
in interface ILock
public ICondition newCondition(String name)
ILock
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.
newCondition
in interface ILock
name
- identifier of the new condition instanceICondition
instance for this ILock
instancepublic void lock()
ILock
public void lockInterruptibly() throws InterruptedException
lockInterruptibly
in interface Lock
InterruptedException
public boolean tryLock()
ILock
public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException
ILock
tryLock
in interface ILock
tryLock
in interface Lock
InterruptedException
public boolean tryLock(long timeout, TimeUnit unit, long leaseTime, TimeUnit leaseUnit) throws InterruptedException
ILock
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:
tryLock
in interface ILock
timeout
- 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.InterruptedException
public void unlock()
ILock
public Condition newCondition()
ILock
ILock.newCondition(String)
instead.newCondition
in interface ILock
newCondition
in interface Lock
protected void onInitialize()
ClientProxy
onInitialize
in class ClientProxy
protected ClientMessage invokeOnPartition(ClientMessage req)
protected <T> T invokeOnPartitionInterruptibly(ClientMessage clientMessage) throws InterruptedException
InterruptedException
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.