org.jboss.cache.interceptors
Class ReplicationInterceptor

java.lang.Object
  extended by org.jboss.cache.commands.AbstractVisitor
      extended by org.jboss.cache.interceptors.base.CommandInterceptor
          extended by org.jboss.cache.interceptors.BaseRpcInterceptor
              extended by org.jboss.cache.interceptors.ReplicationInterceptor
All Implemented Interfaces:
Visitor

public class ReplicationInterceptor
extends BaseRpcInterceptor

Takes care of replicating modifications to other nodes in a cluster. Also listens for prepare(), commit() and rollback() messages which are received 'side-ways' (see docs/design/Refactoring.txt).

Version:
$Id: ReplicationInterceptor.java 7168 2008-11-19 17:37:20Z jason.greene@jboss.com $
Author:
Bela Ban

Field Summary
 
Fields inherited from class org.jboss.cache.interceptors.BaseRpcInterceptor
defaultSynchronous, rpcManager, txTable
 
Fields inherited from class org.jboss.cache.interceptors.base.CommandInterceptor
configuration, log, trace
 
Constructor Summary
ReplicationInterceptor()
           
 
Method Summary
protected  void runPreparePhase(PrepareCommand prepareMethod, GlobalTransaction gtx, InvocationContext ctx)
          Calls prepare(GlobalTransaction,List,org.jgroups.Address,boolean)) in all members except self.
 Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command)
          Visits a RemoveDataCommand.
 Object visitCommitCommand(InvocationContext ctx, CommitCommand command)
          Visits a CommitCommand.
 Object visitMoveCommand(InvocationContext ctx, MoveCommand command)
          Visits a MoveCommand.
 Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command)
          Visits a PrepareCommand.
 Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command)
          Visits a PutDataMapCommand.
 Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command)
          Visits a PutForExternalReadCommand.
 Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
          Visits a PutKeyValueCommand.
 Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command)
          Visits a RemoveKeyCommand.
 Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command)
          Visits a RemoveNodeCommand.
 Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command)
          Visits a RollbackCommand.
 
Methods inherited from class org.jboss.cache.interceptors.BaseRpcInterceptor
checkResponses, injectComponents, isLocalModeForced, isSynchronous, isTransactionalAndLocal, replicateCall, replicateCall, replicateCall, replicateCall, skipReplicationOfTransactionMethod
 
Methods inherited from class org.jboss.cache.interceptors.base.CommandInterceptor
getNext, handleDefault, hasNext, invokeNextInterceptor, setNext
 
Methods inherited from class org.jboss.cache.commands.AbstractVisitor
visitCollection, visitCreateNodeCommand, visitEvictFqnCommand, visitExistsNodeCommand, visitGetChildrenNamesCommand, visitGetDataMapCommand, visitGetKeysCommand, visitGetKeyValueCommand, visitGetNodeCommand, visitGravitateDataCommand, visitInvalidateCommand, visitOptimisticPrepareCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplicationInterceptor

public ReplicationInterceptor()
Method Detail

visitCommitCommand

public Object visitCommitCommand(InvocationContext ctx,
                                 CommitCommand command)
                          throws Throwable
Description copied from interface: Visitor
Visits a CommitCommand.

Specified by:
visitCommitCommand in interface Visitor
Overrides:
visitCommitCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitPrepareCommand

public Object visitPrepareCommand(InvocationContext ctx,
                                  PrepareCommand command)
                           throws Throwable
Description copied from interface: Visitor
Visits a PrepareCommand.

Specified by:
visitPrepareCommand in interface Visitor
Overrides:
visitPrepareCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitRollbackCommand

public Object visitRollbackCommand(InvocationContext ctx,
                                   RollbackCommand command)
                            throws Throwable
Description copied from interface: Visitor
Visits a RollbackCommand.

Specified by:
visitRollbackCommand in interface Visitor
Overrides:
visitRollbackCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitPutForExternalReadCommand

public Object visitPutForExternalReadCommand(InvocationContext ctx,
                                             PutForExternalReadCommand command)
                                      throws Throwable
Description copied from interface: Visitor
Visits a PutForExternalReadCommand.

Specified by:
visitPutForExternalReadCommand in interface Visitor
Overrides:
visitPutForExternalReadCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitPutKeyValueCommand

public Object visitPutKeyValueCommand(InvocationContext ctx,
                                      PutKeyValueCommand command)
                               throws Throwable
Description copied from interface: Visitor
Visits a PutKeyValueCommand.

Specified by:
visitPutKeyValueCommand in interface Visitor
Overrides:
visitPutKeyValueCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitPutDataMapCommand

public Object visitPutDataMapCommand(InvocationContext ctx,
                                     PutDataMapCommand command)
                              throws Throwable
Description copied from interface: Visitor
Visits a PutDataMapCommand.

Specified by:
visitPutDataMapCommand in interface Visitor
Overrides:
visitPutDataMapCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitMoveCommand

public Object visitMoveCommand(InvocationContext ctx,
                               MoveCommand command)
                        throws Throwable
Description copied from interface: Visitor
Visits a MoveCommand.

Specified by:
visitMoveCommand in interface Visitor
Overrides:
visitMoveCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitRemoveNodeCommand

public Object visitRemoveNodeCommand(InvocationContext ctx,
                                     RemoveNodeCommand command)
                              throws Throwable
Description copied from interface: Visitor
Visits a RemoveNodeCommand.

Specified by:
visitRemoveNodeCommand in interface Visitor
Overrides:
visitRemoveNodeCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitRemoveKeyCommand

public Object visitRemoveKeyCommand(InvocationContext ctx,
                                    RemoveKeyCommand command)
                             throws Throwable
Description copied from interface: Visitor
Visits a RemoveKeyCommand.

Specified by:
visitRemoveKeyCommand in interface Visitor
Overrides:
visitRemoveKeyCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

visitClearDataCommand

public Object visitClearDataCommand(InvocationContext ctx,
                                    ClearDataCommand command)
                             throws Throwable
Description copied from interface: Visitor
Visits a RemoveDataCommand.

Specified by:
visitClearDataCommand in interface Visitor
Overrides:
visitClearDataCommand in class AbstractVisitor
Parameters:
ctx - invocation context
command - command to visit
Returns:
response from the visit
Throws:
Throwable - in the event of problems.

runPreparePhase

protected void runPreparePhase(PrepareCommand prepareMethod,
                               GlobalTransaction gtx,
                               InvocationContext ctx)
                        throws Throwable
Calls prepare(GlobalTransaction,List,org.jgroups.Address,boolean)) in all members except self. Waits for all responses. If one of the members failed to prepare, its return value will be an exception. If there is one exception we rethrow it. This will mark the current transaction as rolled back, which will cause the afterCompletion(int) callback to have a status of MARKED_ROLLBACK. When we get that call, we simply roll back the transaction.
If everything runs okay, the afterCompletion(int) callback will trigger the @link #runCommitPhase(GlobalTransaction)).

Throws:
Exception
Throwable


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