org.jboss.cache.interceptors
Class OptimisticReplicationInterceptor

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.OptimisticReplicationInterceptor
All Implemented Interfaces:
Visitor, InterceptorMBean

public class OptimisticReplicationInterceptor
extends BaseRpcInterceptor

Replication interceptor for the optimistically locked interceptor chain. Responsible for replicating state to remote nodes. Unlike it's cousin, the ReplicationInterceptor, this interceptor only deals with transactional calls. Just like all things to do with Optimistic Locking, it is a requirement that everything is done in a transaction and the transaction context is available via InvocationContext.getTransaction() and InvocationContext.getGlobalTransaction().

Author:
Manik Surtani (manik@jboss.org), Steve Woodcock (stevew@jofti.com)

Nested Class Summary
 class OptimisticReplicationInterceptor.DataVersionPopulator
           
 
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
OptimisticReplicationInterceptor()
           
 
Method Summary
protected  void broadcastCommit(GlobalTransaction gtx, InvocationContext ctx)
           
protected  void broadcastPrepare(OptimisticPrepareCommand command, GlobalTransaction gtx, InvocationContext ctx)
           
protected  void broadcastRollback(GlobalTransaction gtx, InvocationContext ctx)
           
protected  TransactionWorkspace getTransactionWorkspace(InvocationContext ctx)
           
 Object handleDefault(InvocationContext ctx, VisitableCommand command)
          The default behaviour of the visitXXX methods, which is to ignore the call and pass the call up to the next interceptor in the chain.
 void initialize(CommandsFactory commandsFactory)
           
 Object visitCommitCommand(InvocationContext ctx, CommitCommand command)
          Visits a CommitCommand.
 Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command)
          Visits a OptimisticPrepareCommand.
 Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command)
          Visits a PutForExternalReadCommand.
 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
dumpStatistics, getNext, getStatisticsEnabled, hasNext, invokeNextInterceptor, resetStatistics, setNext, setStatisticsEnabled
 
Methods inherited from class org.jboss.cache.commands.AbstractVisitor
visitClearDataCommand, visitCollection, visitCreateNodeCommand, visitEvictFqnCommand, visitExistsNodeCommand, visitGetChildrenNamesCommand, visitGetDataMapCommand, visitGetKeysCommand, visitGetKeyValueCommand, visitGetNodeCommand, visitGravitateDataCommand, visitInvalidateCommand, visitMoveCommand, visitPrepareCommand, visitPutDataMapCommand, visitPutKeyValueCommand, visitRemoveKeyCommand, visitRemoveNodeCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptimisticReplicationInterceptor

public OptimisticReplicationInterceptor()
Method Detail

initialize

public void initialize(CommandsFactory commandsFactory)

visitOptimisticPrepareCommand

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

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

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.

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.

handleDefault

public Object handleDefault(InvocationContext ctx,
                            VisitableCommand command)
                     throws Throwable
Description copied from class: CommandInterceptor
The default behaviour of the visitXXX methods, which is to ignore the call and pass the call up to the next interceptor in the chain.

Overrides:
handleDefault in class CommandInterceptor
Parameters:
ctx - invocation context
command - command to invoke
Returns:
return value
Throws:
Throwable - in the event of problems

broadcastPrepare

protected void broadcastPrepare(OptimisticPrepareCommand command,
                                GlobalTransaction gtx,
                                InvocationContext ctx)
                         throws Throwable
Throws:
Throwable

broadcastCommit

protected void broadcastCommit(GlobalTransaction gtx,
                               InvocationContext ctx)
                        throws Throwable
Throws:
Throwable

broadcastRollback

protected void broadcastRollback(GlobalTransaction gtx,
                                 InvocationContext ctx)
                          throws Throwable
Throws:
Throwable

getTransactionWorkspace

protected TransactionWorkspace getTransactionWorkspace(InvocationContext ctx)
                                                throws CacheException
Throws:
CacheException


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