org.jboss.cache.interceptors
Class ReplicationInterceptor

java.lang.Object
  extended by org.jboss.cache.interceptors.Interceptor
      extended by org.jboss.cache.interceptors.BaseRpcInterceptor
          extended by org.jboss.cache.interceptors.ReplicationInterceptor
All Implemented Interfaces:
InterceptorMBean

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,v 1.44 2007/05/23 15:22:03 msurtani Exp $
Author:
Bela Ban

Field Summary
 
Fields inherited from class org.jboss.cache.interceptors.Interceptor
cache, configuration, last, log, next
 
Constructor Summary
ReplicationInterceptor()
           
 
Method Summary
 java.lang.Object invoke(InvocationContext ctx)
           
protected  void runPreparePhase(MethodCall prepareMethod, GlobalTransaction gtx)
          Calls prepare(GlobalTransaction,List,org.jgroups.Address,boolean)) in all members except self.
 
Methods inherited from class org.jboss.cache.interceptors.BaseRpcInterceptor
checkResponses, containsModifications, putCallOnAsyncReplicationQueue, replicateCall, replicateCall, setCache
 
Methods inherited from class org.jboss.cache.interceptors.Interceptor
dumpStatistics, getLast, getNext, getStatisticsEnabled, isActive, isOnePhaseCommitPrepareMehod, isPreparing, isValid, resetStatistics, setLast, setNext, setStatisticsEnabled, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReplicationInterceptor

public ReplicationInterceptor()
Method Detail

invoke

public java.lang.Object invoke(InvocationContext ctx)
                        throws java.lang.Throwable
Overrides:
invoke in class Interceptor
Throws:
java.lang.Throwable

runPreparePhase

protected void runPreparePhase(MethodCall prepareMethod,
                               GlobalTransaction gtx)
                        throws java.lang.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:
java.lang.Exception
java.lang.Throwable