org.jboss.cache.interceptors
Class InvalidationInterceptor

java.lang.Object
  extended by org.jboss.cache.interceptors.Interceptor
      extended by org.jboss.cache.interceptors.MethodDispacherInterceptor
          extended by org.jboss.cache.interceptors.BaseRpcInterceptor
              extended by org.jboss.cache.interceptors.InvalidationInterceptor
All Implemented Interfaces:
InterceptorMBean, InvalidationInterceptorMBean

public class InvalidationInterceptor
extends BaseRpcInterceptor
implements InvalidationInterceptorMBean

This interceptor acts as a replacement to the replication interceptor when the CacheImpl is configured with ClusteredSyncMode as INVALIDATE.

The idea is that rather than replicating changes to all caches in a cluster when CRUD (Create, Remove, Update, Delete) methods are called, simply call evict(Fqn) on the remote caches for each changed node. This allows the remote node to look up the value in a shared cache loader which would have been updated with the changes.

Author:
Manik Surtani (manik@jboss.org)

Field Summary
protected  boolean optimistic
           
protected  Map<GlobalTransaction,List<MethodCall>> txMods
           
protected  TransactionTable txTable
           
 
Fields inherited from class org.jboss.cache.interceptors.BaseRpcInterceptor
defaultSynchronous
 
Fields inherited from class org.jboss.cache.interceptors.Interceptor
cache, configuration, last, log, next, trace
 
Constructor Summary
InvalidationInterceptor()
           
 
Method Summary
 Map<String,Object> dumpStatistics()
          This implementation returns an empty Map.
protected  void findAndAddFqns(Object[] objects, Set<Fqn> fqns, boolean isMove)
          Deprecated. 
 long getInvalidations()
          Returns the number of cache invalidations
protected  DataVersion getNodeVersion(TransactionWorkspace w, Fqn f)
           
protected  TransactionWorkspace getWorkspace(GlobalTransaction gtx)
           
protected  Object handleCommitMethod(InvocationContext ctx, GlobalTransaction globalTransaction)
          Handles CacheImpl.commit(org.jboss.cache.transaction.GlobalTransaction)
protected  Object handleDataGravitationCleanupMethod(InvocationContext ctx, Fqn primary, Fqn backup)
          Handles RemoteCacheInvocationDelegate.dataGravitationCleanup(org.jboss.cache.Fqn, org.jboss.cache.Fqn)
protected  Object handleMoveMethod(InvocationContext ctx, Fqn from, Fqn to)
          Handles CacheImpl._move(org.jboss.cache.Fqn, org.jboss.cache.Fqn)
protected  Object handleOptimisticPrepareMethod(InvocationContext ctx, GlobalTransaction gtx, List modifications, Map data, org.jgroups.Address address, boolean onePhaseCommit)
          Handles CacheImpl.optimisticPrepare(org.jboss.cache.transaction.GlobalTransaction, java.util.List, java.util.Map, org.jgroups.Address, boolean)
protected  Object handlePrepareMethod(InvocationContext ctx, GlobalTransaction gtx, List modification, org.jgroups.Address coordinator, boolean onePhaseCommit)
          Handles CacheImpl.prepare(org.jboss.cache.transaction.GlobalTransaction, java.util.List, org.jgroups.Address, boolean)
protected  Object handlePutDataEraseMethod(InvocationContext ctx, GlobalTransaction gt, Fqn fqn, Map newData, boolean createUndoOps, boolean eraseContents)
          Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, boolean)
protected  Object handlePutDataEraseVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Map data, boolean createUndoOps, boolean eraseContent, DataVersion dv)
          Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, boolean, org.jboss.cache.optimistic.DataVersion)
protected  Object handlePutDataMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Map data, boolean createUndoOps)
          Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, String, java.util.Map, boolean)
protected  Object handlePutDataVersionedMethod(InvocationContext ctx, GlobalTransaction globalTransaction, Fqn fqn, Map map, Boolean createUndoOps, DataVersion dataVersion)
          Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, org.jboss.cache.optimistic.DataVersion)
protected  Object handlePutKeyValueMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps)
          Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, String, Object, Object, boolean)
protected  Object handlePutKeyValueVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps, DataVersion dv)
          Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, Object, boolean, org.jboss.cache.optimistic.DataVersion)
protected  Object handleRemoveDataMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, boolean createUndoOps)
          Handles CacheImpl._removeData(org.jboss.cache.transaction.GlobalTransaction, Fqn, boolean)
protected  Object handleRemoveDataVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, boolean createUndoOps, DataVersion dv)
          Handles CacheImpl._removeData(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, boolean, org.jboss.cache.optimistic.DataVersion)
protected  Object handleRemoveKeyMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Object key, boolean createUndoOps)
          Handles CacheImpl._remove(org.jboss.cache.transaction.GlobalTransaction, String, Object, boolean)
protected  Object handleRemoveKeyVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, boolean createUndoOps, DataVersion dv)
          Handles CacheImpl._remove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, boolean, org.jboss.cache.optimistic.DataVersion)
protected  Object handleRemoveNodeMethod(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, boolean createUndoOps)
          Handles CacheImpl._remove(org.jboss.cache.transaction.GlobalTransaction, String, boolean)
protected  Object handleRemoveNodeVersionedMethod(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, boolean createUndoOps, DataVersion dv)
          Handles CacheImpl._remove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, boolean, org.jboss.cache.optimistic.DataVersion)
protected  Object handleRollbackMethod(InvocationContext ctx, GlobalTransaction globalTransaction)
          Handles CacheImpl.rollback(org.jboss.cache.transaction.GlobalTransaction)
protected  void invalidateAcrossCluster(Fqn fqn, TransactionWorkspace workspace, boolean synchronous, InvocationContext ctx)
           
protected  void invalidateAcrossCluster(Fqn fqn, TransactionWorkspace workspace, InvocationContext ctx)
          Deprecated. use {@link #invalidateAcrossCluster(Fqn,TransactionWorkspace,boolean,InvocationContext)
protected  void invalidateModifications(List<MethodCall> modifications, TransactionWorkspace workspace, boolean synchronous, InvocationContext ctx)
           
protected  void invalidateModifications(List<MethodCall> modifications, TransactionWorkspace workspace, InvocationContext ctx)
          Deprecated. use invalidateAcrossCluster(org.jboss.cache.Fqn,org.jboss.cache.optimistic.TransactionWorkspace,boolean,InvocationContext)
protected  Set<Fqn> optimisedIterator(List<MethodCall> list)
          Removes non-crud methods, plus clobs together common calls to Fqn's.
 void resetStatistics()
          This implementation is a no-op.
 void setCache(CacheSPI cache)
           
protected  boolean skipMethodCall(InvocationContext ctx)
          Each interceptor should extend this if it does not need any processing for current call.
 
Methods inherited from class org.jboss.cache.interceptors.BaseRpcInterceptor
containsModifications, checkResponses, isSynchronous, isTransactionalAndLocal, putCallOnAsyncReplicationQueue, replicateCall, replicateCall, replicateCall, replicateCall, skipReplicationOfTransactionMethod
 
Methods inherited from class org.jboss.cache.interceptors.MethodDispacherInterceptor
handleAddChildMethod, handleBlockChannelMethod, handleEvictMethod, handleEvictVersionedNodeMethod, handleExistsMethod, handleGetDataMapMethod, handleGetChildrenNamesMethod, handleGetKeysMethod, handleGetKeyValueMethod, handleGetNodeMethod, handleLockMethod, handlePrintMethod, handlePutForExternalReadMethod, handlePutForExternalReadVersionedMethod, handleReleaseAllLocksMethod, handleUnblockChannelMethod, invoke
 
Methods inherited from class org.jboss.cache.interceptors.Interceptor
assertTransactionValid, getLast, getNext, getStatisticsEnabled, initLogger, isActive, isPreparing, isValid, nextInterceptor, peekNode, setLast, setNext, setStatisticsEnabled, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.cache.interceptors.InterceptorMBean
getStatisticsEnabled, setStatisticsEnabled
 

Field Detail

txTable

protected TransactionTable txTable

txMods

protected Map<GlobalTransaction,List<MethodCall>> txMods

optimistic

protected boolean optimistic
Constructor Detail

InvalidationInterceptor

public InvalidationInterceptor()
Method Detail

setCache

public void setCache(CacheSPI cache)
Overrides:
setCache in class BaseRpcInterceptor

skipMethodCall

protected boolean skipMethodCall(InvocationContext ctx)
Description copied from class: MethodDispacherInterceptor
Each interceptor should extend this if it does not need any processing for current call. An sample usage would be: this interceptor is only interested if thre is one transaction going on. If so all handleXYZ would know that we have a transaction going and would not check its state.

Overrides:
skipMethodCall in class MethodDispacherInterceptor

handlePutDataMethod

protected Object handlePutDataMethod(InvocationContext ctx,
                                     GlobalTransaction tx,
                                     Fqn fqn,
                                     Map data,
                                     boolean createUndoOps)
                              throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, String, java.util.Map, boolean)

Overrides:
handlePutDataMethod in class MethodDispacherInterceptor
Throws:
Throwable

handlePutDataEraseMethod

protected Object handlePutDataEraseMethod(InvocationContext ctx,
                                          GlobalTransaction gt,
                                          Fqn fqn,
                                          Map newData,
                                          boolean createUndoOps,
                                          boolean eraseContents)
                                   throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, boolean)

Overrides:
handlePutDataEraseMethod in class MethodDispacherInterceptor
Throws:
Throwable

handlePutKeyValueMethod

protected Object handlePutKeyValueMethod(InvocationContext ctx,
                                         GlobalTransaction gtx,
                                         Fqn fqn,
                                         Object key,
                                         Object value,
                                         boolean createUndoOps)
                                  throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, String, Object, Object, boolean)

Overrides:
handlePutKeyValueMethod in class MethodDispacherInterceptor
Throws:
Throwable

handlePutDataEraseVersionedMethod

protected Object handlePutDataEraseVersionedMethod(InvocationContext ctx,
                                                   GlobalTransaction gtx,
                                                   Fqn fqn,
                                                   Map data,
                                                   boolean createUndoOps,
                                                   boolean eraseContent,
                                                   DataVersion dv)
                                            throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, boolean, org.jboss.cache.optimistic.DataVersion)

Overrides:
handlePutDataEraseVersionedMethod in class MethodDispacherInterceptor
Throws:
Throwable

handlePutDataVersionedMethod

protected Object handlePutDataVersionedMethod(InvocationContext ctx,
                                              GlobalTransaction globalTransaction,
                                              Fqn fqn,
                                              Map map,
                                              Boolean createUndoOps,
                                              DataVersion dataVersion)
                                       throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, java.util.Map, boolean, org.jboss.cache.optimistic.DataVersion)

Overrides:
handlePutDataVersionedMethod in class MethodDispacherInterceptor
Throws:
Throwable

handlePutKeyValueVersionedMethod

protected Object handlePutKeyValueVersionedMethod(InvocationContext ctx,
                                                  GlobalTransaction gtx,
                                                  Fqn fqn,
                                                  Object key,
                                                  Object value,
                                                  boolean createUndoOps,
                                                  DataVersion dv)
                                           throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._put(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, Object, boolean, org.jboss.cache.optimistic.DataVersion)

Overrides:
handlePutKeyValueVersionedMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleRemoveNodeMethod

protected Object handleRemoveNodeMethod(InvocationContext ctx,
                                        GlobalTransaction tx,
                                        Fqn fqn,
                                        boolean createUndoOps)
                                 throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._remove(org.jboss.cache.transaction.GlobalTransaction, String, boolean)

Overrides:
handleRemoveNodeMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleRemoveKeyMethod

protected Object handleRemoveKeyMethod(InvocationContext ctx,
                                       GlobalTransaction tx,
                                       Fqn fqn,
                                       Object key,
                                       boolean createUndoOps)
                                throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._remove(org.jboss.cache.transaction.GlobalTransaction, String, Object, boolean)

Overrides:
handleRemoveKeyMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleRemoveDataMethod

protected Object handleRemoveDataMethod(InvocationContext ctx,
                                        GlobalTransaction tx,
                                        Fqn fqn,
                                        boolean createUndoOps)
                                 throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._removeData(org.jboss.cache.transaction.GlobalTransaction, Fqn, boolean)

Overrides:
handleRemoveDataMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleDataGravitationCleanupMethod

protected Object handleDataGravitationCleanupMethod(InvocationContext ctx,
                                                    Fqn primary,
                                                    Fqn backup)
                                             throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles RemoteCacheInvocationDelegate.dataGravitationCleanup(org.jboss.cache.Fqn, org.jboss.cache.Fqn)

Overrides:
handleDataGravitationCleanupMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleMoveMethod

protected Object handleMoveMethod(InvocationContext ctx,
                                  Fqn from,
                                  Fqn to)
                           throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._move(org.jboss.cache.Fqn, org.jboss.cache.Fqn)

Overrides:
handleMoveMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleRemoveKeyVersionedMethod

protected Object handleRemoveKeyVersionedMethod(InvocationContext ctx,
                                                GlobalTransaction gtx,
                                                Fqn fqn,
                                                Object key,
                                                boolean createUndoOps,
                                                DataVersion dv)
                                         throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._remove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, Object, boolean, org.jboss.cache.optimistic.DataVersion)

Overrides:
handleRemoveKeyVersionedMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleRemoveNodeVersionedMethod

protected Object handleRemoveNodeVersionedMethod(InvocationContext ctx,
                                                 GlobalTransaction gtx,
                                                 Fqn fqn,
                                                 boolean createUndoOps,
                                                 DataVersion dv)
                                          throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._remove(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, boolean, org.jboss.cache.optimistic.DataVersion)

Overrides:
handleRemoveNodeVersionedMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleRemoveDataVersionedMethod

protected Object handleRemoveDataVersionedMethod(InvocationContext ctx,
                                                 GlobalTransaction gtx,
                                                 Fqn fqn,
                                                 boolean createUndoOps,
                                                 DataVersion dv)
                                          throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl._removeData(org.jboss.cache.transaction.GlobalTransaction, org.jboss.cache.Fqn, boolean, org.jboss.cache.optimistic.DataVersion)

Overrides:
handleRemoveDataVersionedMethod in class MethodDispacherInterceptor
Throws:
Throwable

handlePrepareMethod

protected Object handlePrepareMethod(InvocationContext ctx,
                                     GlobalTransaction gtx,
                                     List modification,
                                     org.jgroups.Address coordinator,
                                     boolean onePhaseCommit)
                              throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl.prepare(org.jboss.cache.transaction.GlobalTransaction, java.util.List, org.jgroups.Address, boolean)

Overrides:
handlePrepareMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleOptimisticPrepareMethod

protected Object handleOptimisticPrepareMethod(InvocationContext ctx,
                                               GlobalTransaction gtx,
                                               List modifications,
                                               Map data,
                                               org.jgroups.Address address,
                                               boolean onePhaseCommit)
                                        throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl.optimisticPrepare(org.jboss.cache.transaction.GlobalTransaction, java.util.List, java.util.Map, org.jgroups.Address, boolean)

Overrides:
handleOptimisticPrepareMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleCommitMethod

protected Object handleCommitMethod(InvocationContext ctx,
                                    GlobalTransaction globalTransaction)
                             throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl.commit(org.jboss.cache.transaction.GlobalTransaction)

Overrides:
handleCommitMethod in class MethodDispacherInterceptor
Throws:
Throwable

handleRollbackMethod

protected Object handleRollbackMethod(InvocationContext ctx,
                                      GlobalTransaction globalTransaction)
                               throws Throwable
Description copied from class: MethodDispacherInterceptor
Handles CacheImpl.rollback(org.jboss.cache.transaction.GlobalTransaction)

Overrides:
handleRollbackMethod in class MethodDispacherInterceptor
Throws:
Throwable

getInvalidations

public long getInvalidations()
Description copied from interface: InvalidationInterceptorMBean
Returns the number of cache invalidations

Specified by:
getInvalidations in interface InvalidationInterceptorMBean
Returns:
the number of invalidations

resetStatistics

public void resetStatistics()
Description copied from class: Interceptor
This implementation is a no-op. If individual Interceptors wish to expose statistics, they can override this method.

Specified by:
resetStatistics in interface InterceptorMBean
Overrides:
resetStatistics in class Interceptor

dumpStatistics

public Map<String,Object> dumpStatistics()
Description copied from class: Interceptor
This implementation returns an empty Map. If individual Interceptors wish to expose statistics, they can override this method.

Specified by:
dumpStatistics in interface InterceptorMBean
Overrides:
dumpStatistics in class Interceptor
Returns:
a map containing statistics

invalidateAcrossCluster

protected void invalidateAcrossCluster(Fqn fqn,
                                       TransactionWorkspace workspace,
                                       InvocationContext ctx)
                                throws Throwable
Deprecated. use {@link #invalidateAcrossCluster(Fqn,TransactionWorkspace,boolean,InvocationContext)

Same as invalidateAcrossCluster(fqn, workspace, defaultSynchronous)

Throws:
Throwable

invalidateAcrossCluster

protected void invalidateAcrossCluster(Fqn fqn,
                                       TransactionWorkspace workspace,
                                       boolean synchronous,
                                       InvocationContext ctx)
                                throws Throwable
Throws:
Throwable

getNodeVersion

protected DataVersion getNodeVersion(TransactionWorkspace w,
                                     Fqn f)

invalidateModifications

protected void invalidateModifications(List<MethodCall> modifications,
                                       TransactionWorkspace workspace,
                                       InvocationContext ctx)
                                throws Throwable
Deprecated. use invalidateAcrossCluster(org.jboss.cache.Fqn,org.jboss.cache.optimistic.TransactionWorkspace,boolean,InvocationContext)

Same as invalidateModifications(modifications, workspace, defaultSynchronous)

Throws:
Throwable

invalidateModifications

protected void invalidateModifications(List<MethodCall> modifications,
                                       TransactionWorkspace workspace,
                                       boolean synchronous,
                                       InvocationContext ctx)
                                throws Throwable
Throws:
Throwable

getWorkspace

protected TransactionWorkspace getWorkspace(GlobalTransaction gtx)

findAndAddFqns

@Deprecated
protected void findAndAddFqns(Object[] objects,
                                         Set<Fqn> fqns,
                                         boolean isMove)
Deprecated. 


optimisedIterator

protected Set<Fqn> optimisedIterator(List<MethodCall> list)
Removes non-crud methods, plus clobs together common calls to Fqn's. E.g, if we have put("/a/b", "1", "2") followed by a put("/a/b", "3", "4") we should only evict "/a/b" once.

Parameters:
list -
Returns:
Iterator containing a unique set of Fqns of crud methods in this tx


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