Package org.infinispan.commands.tx
Class PrepareCommand
java.lang.Object
org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
org.infinispan.commands.tx.PrepareCommand
- All Implemented Interfaces:
CacheRpcCommand,ReplicableCommand,TopologyAffectedCommand,TransactionBoundaryCommand,VisitableCommand,RemoteLockCommand,TransactionalRemoteLockCommand
- Direct Known Subclasses:
VersionedPrepareCommand
public class PrepareCommand
extends AbstractTransactionBoundaryCommand
implements TransactionalRemoteLockCommand
Command corresponding to the 1st phase of 2PC.
- 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
FieldsModifier and TypeFieldDescriptionstatic final byteprotected List<WriteCommand>protected booleanprotected booleanFields inherited from class org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
cacheName, globalTx -
Constructor Summary
ConstructorsConstructorDescriptionPrepareCommand(ByteString cacheName) PrepareCommand(ByteString cacheName, GlobalTransaction gtx, List<WriteCommand> commands, boolean onePhaseCommit) -
Method Summary
Modifier and TypeMethodDescriptionacceptVisitor(InvocationContext ctx, Visitor visitor) Accept a visitor, and return the result of accepting this visitor.createContext(ComponentRegistry componentRegistry) It creates the transaction context.Collection<?>byteUsed by marshallers to convert this command into an id for streaming.It returns the lock owner of the key.Collection<?>It returns aCollectionwith the keys to be lock.booleanbooleanIt checks if this command should acquire locks.booleaninvokeAsync(ComponentRegistry registry) Invoke the command asynchronously.booleanbooleanIf set to true, then the keys touched by this transaction are to be wrapped again and original ones discarded.booleanbooleanIf true, a return value will be provided when performed remotely.voidreadFrom(ObjectInput input) Reads this instance from the stream written byReplicableCommand.writeTo(ObjectOutput).voidsetReplayEntryWrapping(boolean replayEntryWrapping) voidsetRetriedCommand(boolean retriedCommand) toString()voidwriteTo(ObjectOutput output) Writes this instance to theObjectOutput.Methods inherited from class org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
equals, getCacheName, getGlobalTransaction, getOrigin, getTopologyId, hashCode, invalidRemoteTxReturnValue, loadType, markTransactionAsRemote, setOrigin, setTopologyId, visitRemoteTransactionMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.infinispan.commands.ReplicableCommand
canBlock, invoke, invokeAsync, isSuccessful, logThrowableMethods inherited from interface org.infinispan.commands.VisitableCommand
init
-
Field Details
-
COMMAND_ID
public static final byte COMMAND_ID- See Also:
-
modifications
-
onePhaseCommit
protected boolean onePhaseCommit -
retriedCommand
protected boolean retriedCommand
-
-
Constructor Details
-
PrepareCommand
public PrepareCommand(ByteString cacheName, GlobalTransaction gtx, List<WriteCommand> commands, boolean onePhaseCommit) -
PrepareCommand
-
-
Method Details
-
invokeAsync
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
Description copied from interface:TransactionalRemoteLockCommandIt creates the transaction context.- Specified by:
createContextin interfaceTransactionalRemoteLockCommand- Returns:
- the
TxInvocationContext.
-
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
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().
-
acceptVisitor
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
-
getModifications
-
isOnePhaseCommit
public boolean isOnePhaseCommit() -
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
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
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.
-
toString
- Overrides:
toStringin classAbstractTransactionBoundaryCommand
-
hasModifications
public boolean hasModifications() -
getAffectedKeys
-
isReplayEntryWrapping
public boolean isReplayEntryWrapping()If set to true, then the keys touched by this transaction are to be wrapped again and original ones discarded. -
setReplayEntryWrapping
public void setReplayEntryWrapping(boolean replayEntryWrapping) - See Also:
-
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- Overrides:
isReturnValueExpectedin classAbstractTransactionBoundaryCommand- Returns:
- true or false
-
isRetriedCommand
public boolean isRetriedCommand() -
setRetriedCommand
public void setRetriedCommand(boolean retriedCommand)
-