Package org.infinispan.commands.control
Class LockControlCommand
- java.lang.Object
-
- org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
-
- org.infinispan.commands.control.LockControlCommand
-
- All Implemented Interfaces:
FlagAffectedCommand
,CacheRpcCommand
,ReplicableCommand
,TopologyAffectedCommand
,TransactionBoundaryCommand
,VisitableCommand
,RemoteLockCommand
,TransactionalRemoteLockCommand
public class LockControlCommand extends AbstractTransactionBoundaryCommand implements FlagAffectedCommand, TopologyAffectedCommand, TransactionalRemoteLockCommand
LockControlCommand is a command that enables distributed locking across infinispan nodes. For more details refer to: https://jira.jboss.org/jira/browse/ISPN-70 https://jira.jboss.org/jira/browse/ISPN-48- Since:
- 4.0
- Author:
- Vladimir Blagojevic (vblagoje@redhat.com), Mircea.Markus@jboss.com
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.commands.VisitableCommand
VisitableCommand.LoadType
-
-
Field Summary
Fields Modifier and Type Field Description static int
COMMAND_ID
-
Constructor Summary
Constructors Constructor Description LockControlCommand(Object key, ByteString cacheName, long flags, GlobalTransaction gtx)
LockControlCommand(Collection<?> keys, ByteString cacheName, long flags, GlobalTransaction gtx)
LockControlCommand(ByteString cacheName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
acceptVisitor(InvocationContext ctx, Visitor visitor)
Accept a visitor, and return the result of accepting this visitor.RemoteTxInvocationContext
createContext()
It creates the transaction context.boolean
equals(Object o)
byte
getCommandId()
Used by marshallers to convert this command into an id for streaming.long
getFlagsBitSet()
Object
getKeyLockOwner()
It returns the lock owner of the key.Collection<Object>
getKeys()
Collection<?>
getKeysToLock()
It returns aCollection
with the keys to be lock.Object
getSingleKey()
int
hashCode()
boolean
hasSkipLocking()
It checks if this command should acquire locks.boolean
hasZeroLockAcquisition()
CompletableFuture<Object>
invokeAsync()
Invoke the command asynchronously.boolean
isUnlock()
boolean
multipleKeys()
void
readFrom(ObjectInput input)
Reads this instance from the stream written byReplicableCommand.writeTo(ObjectOutput)
.void
replaceKey(Object oldKey, Object replacement)
void
replaceKeys(Map<Object,Object> replacements)
void
setFlagsBitSet(long bitSet)
Set the flags, replacing any existing flags.void
setGlobalTransaction(GlobalTransaction gtx)
void
setUnlock(boolean unlock)
String
toString()
void
writeTo(ObjectOutput output)
Writes this instance to theObjectOutput
.-
Methods inherited from class org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
canBlock, getCacheName, getGlobalTransaction, getOrigin, getTopologyId, init, invalidRemoteTxReturnValue, isReturnValueExpected, loadType, markTransactionAsRemote, perform, setOrigin, setTopologyId, visitRemoteTransaction
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.infinispan.commands.FlagAffectedCommand
addFlag, addFlags, addFlags, getFlags, hasAnyFlag, hasFlag, setFlags
-
Methods inherited from interface org.infinispan.commands.ReplicableCommand
canBlock, invoke, isReturnValueExpected, isSuccessful
-
Methods inherited from interface org.infinispan.commands.TopologyAffectedCommand
getTopologyId, setTopologyId
-
Methods inherited from interface org.infinispan.commands.VisitableCommand
ignoreCommandOnStatus, loadType, perform, shouldInvoke
-
-
-
-
Field Detail
-
COMMAND_ID
public static final int COMMAND_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LockControlCommand
public LockControlCommand(ByteString cacheName)
-
LockControlCommand
public LockControlCommand(Collection<?> keys, ByteString cacheName, long flags, GlobalTransaction gtx)
-
LockControlCommand
public LockControlCommand(Object key, ByteString cacheName, long flags, GlobalTransaction gtx)
-
-
Method Detail
-
setGlobalTransaction
public void setGlobalTransaction(GlobalTransaction gtx)
-
getKeys
public Collection<Object> getKeys()
-
multipleKeys
public boolean multipleKeys()
-
getSingleKey
public Object getSingleKey()
-
acceptVisitor
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
Description copied from interface:VisitableCommand
Accept a visitor, and return the result of accepting this visitor.- Specified by:
acceptVisitor
in interfaceVisitableCommand
- Parameters:
ctx
- invocation contextvisitor
- visitor to accept- Returns:
- arbitrary return value
- Throws:
Throwable
- in the event of problems
-
invokeAsync
public CompletableFuture<Object> invokeAsync() throws Throwable
Description copied from interface:ReplicableCommand
Invoke the command asynchronously.This method replaces
ReplicableCommand.perform(InvocationContext)
for remote execution. The default implementation andReplicableCommand.perform(InvocationContext)
will be removed in future versions.- Specified by:
invokeAsync
in interfaceReplicableCommand
- Overrides:
invokeAsync
in classAbstractTransactionBoundaryCommand
- Throws:
Throwable
-
createContext
public RemoteTxInvocationContext createContext()
Description copied from interface:TransactionalRemoteLockCommand
It creates the transaction context.- Specified by:
createContext
in interfaceTransactionalRemoteLockCommand
- Returns:
- the
TxInvocationContext
.
-
getCommandId
public byte getCommandId()
Description copied from interface:ReplicableCommand
Used by marshallers to convert this command into an id for streaming.- Specified by:
getCommandId
in interfaceReplicableCommand
- Returns:
- the method id of this command. This is compatible with pre-2.2.0 MethodCall ids.
-
writeTo
public void writeTo(ObjectOutput output) throws IOException
Description copied from interface:ReplicableCommand
Writes this instance to theObjectOutput
.- Specified by:
writeTo
in interfaceReplicableCommand
- Overrides:
writeTo
in classAbstractTransactionBoundaryCommand
- Parameters:
output
- the stream.- Throws:
IOException
- if an error occurred during the I/O.
-
readFrom
public void readFrom(ObjectInput input) throws IOException, ClassNotFoundException
Description copied from interface:ReplicableCommand
Reads this instance from the stream written byReplicableCommand.writeTo(ObjectOutput)
.- Specified by:
readFrom
in interfaceReplicableCommand
- Overrides:
readFrom
in classAbstractTransactionBoundaryCommand
- Parameters:
input
- the stream to read.- Throws:
IOException
- if an error occurred during the I/O.ClassNotFoundException
- if it tries to load an undefined class.
-
isUnlock
public boolean isUnlock()
-
setUnlock
public void setUnlock(boolean unlock)
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classAbstractTransactionBoundaryCommand
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractTransactionBoundaryCommand
-
toString
public String toString()
- Overrides:
toString
in classAbstractTransactionBoundaryCommand
-
getFlagsBitSet
public long getFlagsBitSet()
- Specified by:
getFlagsBitSet
in interfaceFlagAffectedCommand
- Returns:
- The command flags. Flags can be modified with
FlagAffectedCommand.setFlagsBitSet(long)
,FlagAffectedCommand.addFlags(long)
andFlagAffectedCommand.addFlags(Set)
methods.
-
setFlagsBitSet
public void setFlagsBitSet(long bitSet)
Description copied from interface:FlagAffectedCommand
Set the flags, replacing any existing flags.- Specified by:
setFlagsBitSet
in interfaceFlagAffectedCommand
-
getKeysToLock
public Collection<?> getKeysToLock()
Description copied from interface:RemoteLockCommand
It returns aCollection
with the keys to be lock.It may return an empty collection if no keys needs to be locked independently of the return value of
RemoteLockCommand.hasSkipLocking()
. It may contains duplicated keys andnull
is not a valid return value.- Specified by:
getKeysToLock
in interfaceRemoteLockCommand
- Returns:
- a
Collection
of keys to lock.
-
getKeyLockOwner
public Object getKeyLockOwner()
Description copied from interface:RemoteLockCommand
It returns the lock owner of the key.Usually, in transaction caches it is the
GlobalTransaction
and in non-transactional caches theCommandInvocationId
.- Specified by:
getKeyLockOwner
in interfaceRemoteLockCommand
- Returns:
- the lock owner of the key.
-
hasZeroLockAcquisition
public boolean hasZeroLockAcquisition()
- Specified by:
hasZeroLockAcquisition
in interfaceRemoteLockCommand
- Returns:
- it the locks should be acquire with 0 (zero) acquisition timeout.
-
hasSkipLocking
public boolean hasSkipLocking()
Description copied from interface:RemoteLockCommand
It checks if this command should acquire locks.- Specified by:
hasSkipLocking
in interfaceRemoteLockCommand
- Returns:
true
if locks should be acquired for the keys inRemoteLockCommand.getKeysToLock()
.
-
-