org.jboss.cache.interceptors
Class InvalidationInterceptor

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.InvalidationInterceptor
All Implemented Interfaces:
Visitor, 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)

Nested Class Summary
 class InvalidationInterceptor.InvalidationFilterVisitor
           
 
Field Summary
protected  boolean optimistic
           
protected  Map<GlobalTransaction,List<ReversibleCommand>> txMods
           
 
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
InvalidationInterceptor()
           
 
Method Summary
 Map<String,Object> dumpStatistics()
          Returns a map of statistics.
 long getInvalidations()
          Returns the number of cache invalidations
protected  DataVersion getNodeVersion(TransactionWorkspace w, Fqn f)
           
protected  TransactionWorkspace getWorkspace(GlobalTransaction gtx)
           
 void injectDependencies(CommandsFactory commandsFactory)
           
protected  void invalidateAcrossCluster(Fqn fqn, TransactionWorkspace workspace, boolean synchronous, InvocationContext ctx)
           
 void resetStatistics()
          Resets statistics gathered.
 Object visitCommitCommand(InvocationContext ctx, CommitCommand command)
          Visits a CommitCommand.
 Object visitMoveCommand(InvocationContext ctx, MoveCommand command)
          Visits a MoveCommand.
 Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command)
          Visits a OptimisticPrepareCommand.
 Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command)
          Visits a PrepareCommand.
 Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command)
          Visits a PutDataMapCommand.
 Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
          Visits a PutKeyValueCommand.
 Object visitRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command)
          Visits a RemoveDataCommand.
 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, isSynchronous, isTransactionalAndLocal, replicateCall, replicateCall, replicateCall, replicateCall, skipReplicationOfTransactionMethod
 
Methods inherited from class org.jboss.cache.interceptors.base.CommandInterceptor
getNext, getStatisticsEnabled, handleDefault, hasNext, invokeNextInterceptor, setNext, setStatisticsEnabled
 
Methods inherited from class org.jboss.cache.commands.AbstractVisitor
visitCollection, visitCreateNodeCommand, visitEvictFqnCommand, visitExistsNodeCommand, visitGetChildrenNamesCommand, visitGetDataMapCommand, visitGetKeysCommand, visitGetKeyValueCommand, visitGetNodeCommand, visitGravitateDataCommand, visitInvalidateCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.cache.interceptors.InterceptorMBean
getStatisticsEnabled, setStatisticsEnabled
 

Field Detail

txMods

protected Map<GlobalTransaction,List<ReversibleCommand>> txMods

optimistic

protected boolean optimistic
Constructor Detail

InvalidationInterceptor

public InvalidationInterceptor()
Method Detail

injectDependencies

public void injectDependencies(CommandsFactory commandsFactory)

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.

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.

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.

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.

visitRemoveDataCommand

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

Specified by:
visitRemoveDataCommand in interface Visitor
Overrides:
visitRemoveDataCommand 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.

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.

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: CommandInterceptor
Resets statistics gathered. Is a no-op, and should be overridden if it is to be meaningful.

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

dumpStatistics

public Map<String,Object> dumpStatistics()
Description copied from class: CommandInterceptor
Returns a map of statistics. This is a default implementation which returns an empty map and should be overridden if it is to be meaningful.

Specified by:
dumpStatistics in interface InterceptorMBean
Overrides:
dumpStatistics in class CommandInterceptor
Returns:
an empty map

invalidateAcrossCluster

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

getNodeVersion

protected DataVersion getNodeVersion(TransactionWorkspace w,
                                     Fqn f)

getWorkspace

protected TransactionWorkspace getWorkspace(GlobalTransaction gtx)


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