@Component(value="cuba_LockManager") public class LockManager extends java.lang.Object implements LockManagerAPI, ClusterListener<LockInfo>
NAME
Constructor and Description |
---|
LockManager() |
Modifier and Type | Method and Description |
---|---|
void |
expireLocks()
Process locks expiring.
|
java.util.List<LockInfo> |
getCurrentLocks()
List of current locks
|
LockInfo |
getLockInfo(java.lang.String name,
java.lang.String id)
Get locking status for particular object
|
byte[] |
getState()
Get state of this cluster node to send it to other nodes.
|
LockInfo |
lock(Entity entity)
Try to lock an entity.
|
LockInfo |
lock(java.lang.String name,
java.lang.String id)
Try to lock an arbitrary object.
|
void |
receive(LockInfo message)
Receive a message from other cluster nodes.
|
void |
reloadConfiguration() |
void |
setClusterManager(ClusterManagerAPI clusterManager) |
void |
setState(byte[] state)
Set state of this cluster node receiving it from other active node.
|
void |
unlock(Entity entity)
Unlock an entity.
|
void |
unlock(java.lang.String name,
java.lang.String id)
Unlock an arbitrary object.
|
@Inject public void setClusterManager(ClusterManagerAPI clusterManager)
public LockInfo lock(java.lang.String name, java.lang.String id)
LockManagerAPI
lock
in interface LockManagerAPI
name
- locking object nameid
- locking object IDLockNotSupported
instance in case of locking is not configured for this object,LockInfo
instance in case of this object is already locked by someone@Nullable public LockInfo lock(Entity entity)
LockManagerAPI
lock
in interface LockManagerAPI
entity
- entity instanceLockNotSupported
instance in case of locking is not configured for this entity,LockInfo
instance in case of this entity is already locked by someonepublic void unlock(java.lang.String name, java.lang.String id)
LockManagerAPI
unlock
in interface LockManagerAPI
name
- locking object nameid
- locking object IDpublic void unlock(Entity entity)
LockManagerAPI
unlock
in interface LockManagerAPI
entity
- entity instancepublic LockInfo getLockInfo(java.lang.String name, java.lang.String id)
LockManagerAPI
getLockInfo
in interface LockManagerAPI
name
- locking object nameid
- locking object IDLockNotSupported
instance in case of locking is not configured for this object,LockInfo
instance in case of this object is locked by someonepublic java.util.List<LockInfo> getCurrentLocks()
LockManagerAPI
getCurrentLocks
in interface LockManagerAPI
public void expireLocks()
LockManagerAPI
expireLocks
in interface LockManagerAPI
public void reloadConfiguration()
reloadConfiguration
in interface LockManagerAPI
public void receive(LockInfo message)
ClusterListener
receive
in interface ClusterListener<LockInfo>
message
- message instancepublic byte[] getState()
ClusterListener
This method is invoked by clustering implementation when a new node joins the cluster and wants to receive the state from this active node.
getState
in interface ClusterListener<LockInfo>
public void setState(byte[] state)
ClusterListener
This method is invoked by clustering implementation once when this node joins the cluster.
setState
in interface ClusterListener<LockInfo>
state
- byte array containing the state