Package org.infinispan.commands.tx
Class AbstractTransactionBoundaryCommand
- java.lang.Object
-
- org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
-
- All Implemented Interfaces:
CacheRpcCommand,ReplicableCommand,TopologyAffectedCommand,TransactionBoundaryCommand,VisitableCommand
- Direct Known Subclasses:
CommitCommand,LockControlCommand,PrepareCommand,RollbackCommand
public abstract class AbstractTransactionBoundaryCommand extends Object implements TransactionBoundaryCommand
An abstract transaction boundary command that holds a reference to aGlobalTransaction- Since:
- 4.0
- Author:
- Manik Surtani (manik@jboss.org), 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 protected ByteStringcacheNameprotected GlobalTransactionglobalTx
-
Constructor Summary
Constructors Constructor Description AbstractTransactionBoundaryCommand(ByteString cacheName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)ByteStringgetCacheName()GlobalTransactiongetGlobalTransaction()AddressgetOrigin()Get the origin of the commandintgetTopologyId()inthashCode()protected ObjectinvalidRemoteTxReturnValue(TransactionTable txTable)This is what is returned to remote callers when an invalid RemoteTransaction is encountered.CompletionStage<?>invokeAsync(ComponentRegistry registry)Invoke the command asynchronously.booleanisReturnValueExpected()If true, a return value will be provided when performed remotely.VisitableCommand.LoadTypeloadType()voidmarkTransactionAsRemote(boolean isRemote)voidreadFrom(ObjectInput input)Reads this instance from the stream written byReplicableCommand.writeTo(ObjectOutput).voidsetOrigin(Address origin)Sets the sender'sAddress.voidsetTopologyId(int topologyId)StringtoString()protected voidvisitRemoteTransaction(RemoteTransaction tx)voidwriteTo(ObjectOutput output)Writes this instance to theObjectOutput.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.infinispan.commands.ReplicableCommand
canBlock, getCommandId, invoke, invokeAsync, isSuccessful
-
Methods inherited from interface org.infinispan.commands.VisitableCommand
acceptVisitor, init
-
-
-
-
Field Detail
-
globalTx
protected GlobalTransaction globalTx
-
cacheName
protected final ByteString cacheName
-
-
Constructor Detail
-
AbstractTransactionBoundaryCommand
public AbstractTransactionBoundaryCommand(ByteString cacheName)
-
-
Method Detail
-
getTopologyId
public int getTopologyId()
- Specified by:
getTopologyIdin interfaceTopologyAffectedCommand
-
setTopologyId
public void setTopologyId(int topologyId)
- Specified by:
setTopologyIdin interfaceTopologyAffectedCommand
-
getCacheName
public ByteString getCacheName()
- Specified by:
getCacheNamein interfaceCacheRpcCommand- Returns:
- the name of the cache that produced this command. This will also be the name of the cache this command is intended for.
-
getGlobalTransaction
public GlobalTransaction getGlobalTransaction()
- Specified by:
getGlobalTransactionin interfaceTransactionBoundaryCommand
-
markTransactionAsRemote
public void markTransactionAsRemote(boolean isRemote)
- Specified by:
markTransactionAsRemotein interfaceTransactionBoundaryCommand
-
invalidRemoteTxReturnValue
protected Object invalidRemoteTxReturnValue(TransactionTable txTable)
This is what is returned to remote callers when an invalid RemoteTransaction is encountered. Can happen if a remote node propagates a transactional call to the current node, and the current node has no idea of the transaction in question. Can happen during rehashing, when ownerships are reassigned during a transactions. Returning a null usually means the transactional command succeeded.- Returns:
- return value to respond to a remote caller with if the transaction context is invalid.
-
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- Throws:
Throwable
-
visitRemoteTransaction
protected void visitRemoteTransaction(RemoteTransaction tx)
-
writeTo
public void writeTo(ObjectOutput output) throws IOException
Description copied from interface:ReplicableCommandWrites this instance to theObjectOutput.- Specified by:
writeToin interfaceReplicableCommand- 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- 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.
-
loadType
public VisitableCommand.LoadType loadType()
- Specified by:
loadTypein interfaceVisitableCommand- Returns:
- Nodes on which the command needs to read the previous values of the keys it acts on.
-
getOrigin
public Address getOrigin()
Description copied from interface:CacheRpcCommandGet the origin of the command- Specified by:
getOriginin interfaceCacheRpcCommand
-
setOrigin
public void setOrigin(Address origin)
Description copied from interface:ReplicableCommandSets the sender'sAddress.By default, it doesn't set anything. Implement this method if the sender's
Addressis needed.- Specified by:
setOriginin interfaceCacheRpcCommand- Specified by:
setOriginin interfaceReplicableCommand- Parameters:
origin- the sender'sAddress
-
isReturnValueExpected
public boolean isReturnValueExpected()
Description copied from interface:ReplicableCommandIf true, a return value will be provided when performed remotely. Otherwise, a remoteResponseGeneratormay choose to simply return null to save on marshalling costs.- Specified by:
isReturnValueExpectedin interfaceReplicableCommand- Returns:
- true or false
-
-