public final class LockStoreImpl extends Object implements IdentifiedDataSerializable, LockStore, com.hazelcast.nio.serialization.impl.Versioned
Constructor and Description |
---|
LockStoreImpl() |
LockStoreImpl(LockService lockService,
ObjectNamespace name,
EntryTaskScheduler<Data,Integer> entryTaskScheduler,
int backupCount,
int asyncBackupCount) |
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
|
public LockStoreImpl()
public LockStoreImpl(LockService lockService, ObjectNamespace name, EntryTaskScheduler<Data,Integer> entryTaskScheduler, int backupCount, int asyncBackupCount)
public boolean lock(Data key, String caller, long threadId, long referenceId, long leaseTime)
LockStore
lock
in interface LockStore
key
- the key to lockcaller
- the identifier for the callerthreadId
- the identifier for the thread on the callerreferenceId
- the identifier for the invocation of the caller (e.g. operation call ID)leaseTime
- the lease duration in millisecondspublic boolean localLock(Data key, String caller, long threadId, long referenceId, long leaseTime)
LockStore
localLock
in interface LockStore
key
- the key to lockcaller
- the identifier for the callerthreadId
- the identifier for the thread on the callerreferenceId
- the identifier for the invocation of the caller (e.g. operation call ID)leaseTime
- the lease duration in millisecondsGroupProperty.LOCK_MAX_LEASE_TIME_SECONDS
public boolean txnLock(Data key, String caller, long threadId, long referenceId, long leaseTime, boolean blockReads)
LockStore
txnLock
in interface LockStore
key
- the key to lockcaller
- the identifier for the callerthreadId
- the identifier for the thread on the callerreferenceId
- the identifier for the invocation of the caller (e.g. operation call ID)leaseTime
- the lease duration in millisecondsblockReads
- whether reads for the key should be blocked (e.g. for map and multimap)public boolean extendLeaseTime(Data key, String caller, long threadId, long leaseTime)
LockStore
extendLeaseTime
in interface LockStore
key
- the locked keycaller
- the identifier for the callerthreadId
- the identifier for the thread on the callerleaseTime
- time in milliseconds for the lease to be extendedpublic com.hazelcast.concurrent.lock.LockResourceImpl getLock(Data key)
public boolean isLocked(Data key)
LockStore
public boolean isLockedBy(Data key, String caller, long threadId)
LockStore
isLockedBy
in interface LockStore
key
- the locked keycaller
- the identifier for the callerthreadId
- the identifier for the thread on the callerpublic int getLockCount(Data key)
LockStore
getLockCount
in interface LockStore
key
- the keypublic int getLockedEntryCount()
LockStore
getLockedEntryCount
in interface LockStore
public long getRemainingLeaseTime(Data key)
LockStore
getRemainingLeaseTime
in interface LockStore
key
- the keypublic boolean canAcquireLock(Data key, String caller, long threadId)
LockStore
canAcquireLock
in interface LockStore
key
- the locked keycaller
- the identifier for the callerthreadId
- the identifier for the thread on the callerpublic boolean shouldBlockReads(Data key)
LockStore
LockStore.txnLock(Data, String, long, long, long, boolean)
).shouldBlockReads
in interface LockStore
key
- the lock keypublic boolean unlock(Data key, String caller, long threadId, long referenceId)
LockStore
public boolean forceUnlock(Data key)
LockStore
true
if the key is already unlocked but has
waiters/signals/expired operations.forceUnlock
in interface LockStore
key
- the lock keyfalse
if there is no lock for the given key
and true
otherwisepublic int getVersion(Data key)
public Collection<LockResource> getLocks()
public void removeLocalLocks()
public Set<Data> getLockedKeys()
LockStore
getLockedKeys
in interface LockStore
public boolean hasLock()
public void clear()
public ObjectNamespace getNamespace()
public int getBackupCount()
public int getAsyncBackupCount()
public int getTotalBackupCount()
public WaitNotifyKey getNotifiedKey(Data key)
public void removeSignalKey(ConditionKey conditionKey)
public boolean hasSignalKey(ConditionKey conditionKey)
public void registerExpiredAwaitOp(AwaitOperation awaitResponse)
public AwaitOperation pollExpiredAwaitOp(Data key)
public String getOwnerInfo(Data key)
LockStore
getOwnerInfo
in interface LockStore
key
- the keypublic int getFactoryId()
IdentifiedDataSerializable
getFactoryId
in interface IdentifiedDataSerializable
public int getId()
IdentifiedDataSerializable
getId
in interface IdentifiedDataSerializable
public void writeData(ObjectDataOutput out) throws IOException
DataSerializable
writeData
in interface DataSerializable
out
- outputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void readData(ObjectDataInput in) throws IOException
DataSerializable
readData
in interface DataSerializable
in
- inputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
input stream has been closed.Copyright © 2018 Hazelcast, Inc.. All rights reserved.