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 intCOMMAND_ID-
Fields inherited from class org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
cacheName, globalTx
-
-
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 ObjectacceptVisitor(InvocationContext ctx, Visitor visitor)Accept a visitor, and return the result of accepting this visitor.RemoteTxInvocationContextcreateContext(ComponentRegistry componentRegistry)It creates the transaction context.booleanequals(Object o)bytegetCommandId()Used by marshallers to convert this command into an id for streaming.longgetFlagsBitSet()ObjectgetKeyLockOwner()It returns the lock owner of the key.Collection<Object>getKeys()Collection<?>getKeysToLock()It returns aCollectionwith the keys to be lock.ObjectgetSingleKey()inthashCode()booleanhasSkipLocking()It checks if this command should acquire locks.booleanhasZeroLockAcquisition()CompletionStage<?>invokeAsync(ComponentRegistry registry)Invoke the command asynchronously.booleanisUnlock()booleanmultipleKeys()voidreadFrom(ObjectInput input)Reads this instance from the stream written byReplicableCommand.writeTo(ObjectOutput).voidsetFlagsBitSet(long bitSet)Set the flags, replacing any existing flags.voidsetGlobalTransaction(GlobalTransaction gtx)voidsetUnlock(boolean unlock)StringtoString()voidwriteTo(ObjectOutput output)Writes this instance to theObjectOutput.-
Methods inherited from class org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
getCacheName, getGlobalTransaction, getOrigin, getTopologyId, invalidRemoteTxReturnValue, isReturnValueExpected, loadType, markTransactionAsRemote, 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, hasAllFlags, hasAnyFlag, hasFlag, setFlags
-
Methods inherited from interface org.infinispan.commands.ReplicableCommand
canBlock, invoke, invokeAsync, isReturnValueExpected, isSuccessful
-
Methods inherited from interface org.infinispan.commands.TopologyAffectedCommand
getTopologyId, setTopologyId
-
Methods inherited from interface org.infinispan.commands.VisitableCommand
init, loadType
-
-
-
-
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:VisitableCommandAccept a visitor, and return the result of accepting this visitor.- Specified by:
acceptVisitorin interfaceVisitableCommand- Parameters:
ctx- invocation contextvisitor- visitor to accept- Returns:
- arbitrary return value
- Throws:
Throwable- in the event of problems
-
invokeAsync
public CompletionStage<?> invokeAsync(ComponentRegistry registry) throws Throwable
Description copied from interface:CacheRpcCommandInvoke the command asynchronously.This method replaces
ReplicableCommand.invoke()for remote execution. The default implementation andReplicableCommand.invoke()will be removed in future versions.- Specified by:
invokeAsyncin interfaceCacheRpcCommand- Overrides:
invokeAsyncin classAbstractTransactionBoundaryCommand- Throws:
Throwable
-
createContext
public RemoteTxInvocationContext createContext(ComponentRegistry componentRegistry)
Description copied from interface:TransactionalRemoteLockCommandIt creates the transaction context.- Specified by:
createContextin interfaceTransactionalRemoteLockCommand- Returns:
- the
TxInvocationContext.
-
getCommandId
public byte getCommandId()
Description copied from interface:ReplicableCommandUsed by marshallers to convert this command into an id for streaming.- Specified by:
getCommandIdin 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:ReplicableCommandWrites this instance to theObjectOutput.- Specified by:
writeToin interfaceReplicableCommand- Overrides:
writeToin 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:ReplicableCommandReads this instance from the stream written byReplicableCommand.writeTo(ObjectOutput).- Specified by:
readFromin interfaceReplicableCommand- Overrides:
readFromin 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:
equalsin classAbstractTransactionBoundaryCommand
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractTransactionBoundaryCommand
-
toString
public String toString()
- Overrides:
toStringin classAbstractTransactionBoundaryCommand
-
getFlagsBitSet
public long getFlagsBitSet()
- Specified by:
getFlagsBitSetin 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:FlagAffectedCommandSet the flags, replacing any existing flags.- Specified by:
setFlagsBitSetin interfaceFlagAffectedCommand
-
getKeysToLock
public Collection<?> getKeysToLock()
Description copied from interface:RemoteLockCommandIt returns aCollectionwith 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 andnullis not a valid return value.- Specified by:
getKeysToLockin interfaceRemoteLockCommand- Returns:
- a
Collectionof keys to lock.
-
getKeyLockOwner
public Object getKeyLockOwner()
Description copied from interface:RemoteLockCommandIt returns the lock owner of the key.Usually, in transaction caches it is the
GlobalTransactionand in non-transactional caches theCommandInvocationId.- Specified by:
getKeyLockOwnerin interfaceRemoteLockCommand- Returns:
- the lock owner of the key.
-
hasZeroLockAcquisition
public boolean hasZeroLockAcquisition()
- Specified by:
hasZeroLockAcquisitionin interfaceRemoteLockCommand- Returns:
- it the locks should be acquire with 0 (zero) acquisition timeout.
-
hasSkipLocking
public boolean hasSkipLocking()
Description copied from interface:RemoteLockCommandIt checks if this command should acquire locks.- Specified by:
hasSkipLockingin interfaceRemoteLockCommand- Returns:
trueif locks should be acquired for the keys inRemoteLockCommand.getKeysToLock().
-
-