org.infinispan.commands.tx
Class PrepareCommand

java.lang.Object
  extended by org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
      extended by org.infinispan.commands.tx.PrepareCommand
All Implemented Interfaces:
CacheRpcCommand, ReplicableCommand, TransactionBoundaryCommand, VisitableCommand
Direct Known Subclasses:
VersionedPrepareCommand

public class PrepareCommand
extends AbstractTransactionBoundaryCommand

Command corresponding to the 1st phase of 2PC.

Since:
4.0
Author:
Manik Surtani (manik@jboss.org), Mircea.Markus@jboss.com

Field Summary
static byte COMMAND_ID
           
protected  WriteCommand[] modifications
           
protected  CacheNotifier notifier
           
protected  boolean onePhaseCommit
           
protected  RecoveryManager recoveryManager
           
 
Fields inherited from class org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
cacheName, configuration, globalTx, icc, invoker, txTable
 
Constructor Summary
PrepareCommand(String cacheName)
           
PrepareCommand(String cacheName, GlobalTransaction gtx, boolean onePhaseCommit, WriteCommand... modifications)
           
PrepareCommand(String cacheName, GlobalTransaction gtx, List<WriteCommand> commands, boolean onePhaseCommit)
           
 
Method Summary
 Object acceptVisitor(InvocationContext ctx, Visitor visitor)
          Accept a visitor, and return the result of accepting this visitor.
 boolean containsModificationType(Class<? extends ReplicableCommand> replicableCommandClass)
           
 PrepareCommand copy()
           
 boolean existModifications()
           
 Set<Object> getAffectedKeys()
           
 byte getCommandId()
          Used by marshallers to convert this command into an id for streaming.
 WriteCommand[] getModifications()
           
 int getModificationsCount()
           
 Object[] getParameters()
          Used by marshallers to stream this command across a network
 boolean hasModifications()
           
 void initialize(CacheNotifier notifier, RecoveryManager recoveryManager)
           
 boolean isOnePhaseCommit()
           
 boolean isReplayEntryWrapping()
          If set to true, then the keys touched by this transaction are to be wrapped again and original ones discarded.
 boolean isReturnValueExpected()
          If true, a return value will be provided when performed remotely.
 Object perform(InvocationContext ignored)
          Performs the primary function of the command.
 void setParameters(int commandId, Object[] args)
          Used by the CommandsFactory to create a command from raw data read off a stream.
 void setReplayEntryWrapping(boolean replayEntryWrapping)
           
 String toString()
           
 boolean writesToASingleKey()
           
 
Methods inherited from class org.infinispan.commands.tx.AbstractTransactionBoundaryCommand
equals, getCacheName, getConfiguration, getGlobalTransaction, getOrigin, hashCode, ignoreCommandOnStatus, init, injectComponents, invalidRemoteTxReturnValue, markTransactionAsRemote, setOrigin, shouldInvoke, visitRemoteTransaction
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMAND_ID

public static final byte COMMAND_ID
See Also:
Constant Field Values

modifications

protected WriteCommand[] modifications

onePhaseCommit

protected boolean onePhaseCommit

notifier

protected CacheNotifier notifier

recoveryManager

protected RecoveryManager recoveryManager
Constructor Detail

PrepareCommand

public PrepareCommand(String cacheName,
                      GlobalTransaction gtx,
                      boolean onePhaseCommit,
                      WriteCommand... modifications)

PrepareCommand

public PrepareCommand(String cacheName,
                      GlobalTransaction gtx,
                      List<WriteCommand> commands,
                      boolean onePhaseCommit)

PrepareCommand

public PrepareCommand(String cacheName)
Method Detail

initialize

public void initialize(CacheNotifier notifier,
                       RecoveryManager recoveryManager)

perform

public Object perform(InvocationContext ignored)
               throws Throwable
Description copied from interface: ReplicableCommand
Performs the primary function of the command. Please see specific implementation classes for details on what is performed as well as return types. Important: this method will be invoked at the end of interceptors chain. It should never be called directly from a custom interceptor.

Specified by:
perform in interface ReplicableCommand
Overrides:
perform in class AbstractTransactionBoundaryCommand
Parameters:
ignored - invocation context
Returns:
arbitrary return value generated by performing this command
Throws:
Throwable - in the event of problems.

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.

Parameters:
ctx - invocation context
visitor - visitor to accept
Returns:
arbitrary return value
Throws:
Throwable - in the event of problems

getModifications

public WriteCommand[] getModifications()

isOnePhaseCommit

public boolean isOnePhaseCommit()

existModifications

public boolean existModifications()

getModificationsCount

public int getModificationsCount()

getCommandId

public byte getCommandId()
Description copied from interface: ReplicableCommand
Used by marshallers to convert this command into an id for streaming.

Returns:
the method id of this command. This is compatible with pre-2.2.0 MethodCall ids.

getParameters

public Object[] getParameters()
Description copied from interface: ReplicableCommand
Used by marshallers to stream this command across a network

Specified by:
getParameters in interface ReplicableCommand
Overrides:
getParameters in class AbstractTransactionBoundaryCommand
Returns:
an object array of arguments, compatible with pre-2.2.0 MethodCall args.

setParameters

public void setParameters(int commandId,
                          Object[] args)
Description copied from interface: ReplicableCommand
Used by the CommandsFactory to create a command from raw data read off a stream.

Specified by:
setParameters in interface ReplicableCommand
Overrides:
setParameters in class AbstractTransactionBoundaryCommand
Parameters:
commandId - command id to set. This is usually unused but *could* be used in the event of a command having multiple IDs, such as PutKeyValueCommand.
args - object array of args

copy

public PrepareCommand copy()

toString

public String toString()
Overrides:
toString in class AbstractTransactionBoundaryCommand

containsModificationType

public boolean containsModificationType(Class<? extends ReplicableCommand> replicableCommandClass)

hasModifications

public boolean hasModifications()

getAffectedKeys

public Set<Object> 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:
isReplayEntryWrapping()

writesToASingleKey

public boolean writesToASingleKey()

isReturnValueExpected

public boolean isReturnValueExpected()
Description copied from interface: ReplicableCommand
If true, a return value will be provided when performed remotely. Otherwise, a remote ResponseGenerator may choose to simply return null to save on marshalling costs.

Specified by:
isReturnValueExpected in interface ReplicableCommand
Overrides:
isReturnValueExpected in class AbstractTransactionBoundaryCommand
Returns:
true or false

-->

Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.