org.infinispan.interceptors.locking
Class PessimisticLockingInterceptor

java.lang.Object
  extended by org.infinispan.commands.AbstractVisitor
      extended by org.infinispan.interceptors.base.CommandInterceptor
          extended by org.infinispan.interceptors.locking.AbstractLockingInterceptor
              extended by org.infinispan.interceptors.locking.AbstractTxLockingInterceptor
                  extended by org.infinispan.interceptors.locking.PessimisticLockingInterceptor
All Implemented Interfaces:
Visitor

public class PessimisticLockingInterceptor
extends AbstractTxLockingInterceptor

Locking interceptor to be used by pessimistic caches. Design note: when a lock "k" needs to be acquired (e.g. cache.put("k", "v")), if the lock owner is the local node, no remote call is performed to migrate locking logic to the other (numOwners - 1) lock owners. This is a good optimisation for in-vm transactions: if the local node crashes before prepare then the replicated lock information would be useless as the tx is rolled back. OTOH for remote hotrod/transactions this additional RPC makes sense because there's no such thing as transaction originator node, so this might become a configuration option when HotRod tx are in place. Implementation note: current implementation acquires locks remotely first and then locally. This is required by the deadlock detection logic, but might not be optimal: acquiring locks locally first might help to fail fast the in the case of keys being locked.

Since:
5.1
Author:
Mircea Markus

Field Summary
 
Fields inherited from class org.infinispan.interceptors.locking.AbstractTxLockingInterceptor
rpcManager, txTable
 
Fields inherited from class org.infinispan.interceptors.base.CommandInterceptor
configuration
 
Constructor Summary
PessimisticLockingInterceptor()
           
 
Method Summary
protected  Log getLog()
           
 void init(CommandsFactory factory)
           
protected  void lockAndRegisterBackupLock(TxInvocationContext ctx, Object key, boolean isLockOwner)
           
 Object visitApplyDeltaCommand(InvocationContext ctx, ApplyDeltaCommand command)
           
 Object visitClearCommand(InvocationContext ctx, ClearCommand command)
           
 Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command)
           
 Object visitLockControlCommand(TxInvocationContext ctx, LockControlCommand command)
           
 Object visitPrepareCommand(TxInvocationContext ctx, PrepareCommand command)
           
 Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command)
           
 Object visitPutMapCommand(InvocationContext ctx, PutMapCommand command)
           
 Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command)
           
 Object visitReplaceCommand(InvocationContext ctx, ReplaceCommand command)
           
 
Methods inherited from class org.infinispan.interceptors.locking.AbstractTxLockingInterceptor
abortIfRemoteTransactionInvalid, invokeNextAndCommitIf1Pc, lockAndRegisterBackupLock, lockKeyAndCheckOwnership, setDependencies, visitCommitCommand, visitEvictCommand, visitRollbackCommand
 
Methods inherited from class org.infinispan.interceptors.locking.AbstractLockingInterceptor
cleanLocksAndRethrow, lockKey, setDependencies, visitInvalidateCommand, visitInvalidateL1Command
 
Methods inherited from class org.infinispan.interceptors.base.CommandInterceptor
getNext, handleDefault, hasNext, invokeNextInterceptor, setNext
 
Methods inherited from class org.infinispan.commands.AbstractVisitor
visitCollection, visitDistributedExecuteCommand, visitEntrySetCommand, visitKeySetCommand, visitSizeCommand, visitUnknownCommand, visitValuesCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PessimisticLockingInterceptor

public PessimisticLockingInterceptor()
Method Detail

getLog

protected Log getLog()
Overrides:
getLog in class CommandInterceptor

init

public void init(CommandsFactory factory)

visitGetKeyValueCommand

public final Object visitGetKeyValueCommand(InvocationContext ctx,
                                            GetKeyValueCommand command)
                                     throws Throwable
Specified by:
visitGetKeyValueCommand in interface Visitor
Overrides:
visitGetKeyValueCommand in class AbstractTxLockingInterceptor
Throws:
Throwable

visitPrepareCommand

public Object visitPrepareCommand(TxInvocationContext ctx,
                                  PrepareCommand command)
                           throws Throwable
Specified by:
visitPrepareCommand in interface Visitor
Overrides:
visitPrepareCommand in class AbstractVisitor
Throws:
Throwable

visitPutKeyValueCommand

public Object visitPutKeyValueCommand(InvocationContext ctx,
                                      PutKeyValueCommand command)
                               throws Throwable
Specified by:
visitPutKeyValueCommand in interface Visitor
Overrides:
visitPutKeyValueCommand in class AbstractVisitor
Throws:
Throwable

visitPutMapCommand

public Object visitPutMapCommand(InvocationContext ctx,
                                 PutMapCommand command)
                          throws Throwable
Specified by:
visitPutMapCommand in interface Visitor
Overrides:
visitPutMapCommand in class AbstractVisitor
Throws:
Throwable

visitRemoveCommand

public Object visitRemoveCommand(InvocationContext ctx,
                                 RemoveCommand command)
                          throws Throwable
Specified by:
visitRemoveCommand in interface Visitor
Overrides:
visitRemoveCommand in class AbstractVisitor
Throws:
Throwable

visitApplyDeltaCommand

public Object visitApplyDeltaCommand(InvocationContext ctx,
                                     ApplyDeltaCommand command)
                              throws Throwable
Specified by:
visitApplyDeltaCommand in interface Visitor
Overrides:
visitApplyDeltaCommand in class AbstractVisitor
Throws:
Throwable

visitReplaceCommand

public Object visitReplaceCommand(InvocationContext ctx,
                                  ReplaceCommand command)
                           throws Throwable
Specified by:
visitReplaceCommand in interface Visitor
Overrides:
visitReplaceCommand in class AbstractVisitor
Throws:
Throwable

visitClearCommand

public Object visitClearCommand(InvocationContext ctx,
                                ClearCommand command)
                         throws Throwable
Specified by:
visitClearCommand in interface Visitor
Overrides:
visitClearCommand in class AbstractVisitor
Throws:
Throwable

visitLockControlCommand

public Object visitLockControlCommand(TxInvocationContext ctx,
                                      LockControlCommand command)
                               throws Throwable
Specified by:
visitLockControlCommand in interface Visitor
Overrides:
visitLockControlCommand in class AbstractVisitor
Throws:
Throwable

lockAndRegisterBackupLock

protected final void lockAndRegisterBackupLock(TxInvocationContext ctx,
                                               Object key,
                                               boolean isLockOwner)
                                        throws InterruptedException
Throws:
InterruptedException

-->

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