Class PessimisticLockingInterceptor

  • All Implemented Interfaces:
    org.infinispan.commands.Visitor, AsyncInterceptor

    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.
    Author:
    Mircea Markus
    • Constructor Detail

      • PessimisticLockingInterceptor

        public PessimisticLockingInterceptor()
    • Method Detail

      • visitPrepareCommand

        public java.lang.Object visitPrepareCommand​(org.infinispan.context.impl.TxInvocationContext ctx,
                                                    org.infinispan.commands.tx.PrepareCommand command)
                                             throws java.lang.Throwable
        Specified by:
        visitPrepareCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitPrepareCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable
      • handleWriteManyCommand

        protected <K> java.lang.Object handleWriteManyCommand​(InvocationContext ctx,
                                                              org.infinispan.commands.write.WriteCommand command,
                                                              java.util.Collection<K> keys,
                                                              boolean forwarded)
                                                       throws java.lang.Throwable
        Specified by:
        handleWriteManyCommand in class AbstractLockingInterceptor
        Throws:
        java.lang.Throwable
      • visitLockControlCommand

        public java.lang.Object visitLockControlCommand​(org.infinispan.context.impl.TxInvocationContext ctx,
                                                        org.infinispan.commands.control.LockControlCommand command)
                                                 throws java.lang.Throwable
        Specified by:
        visitLockControlCommand in interface org.infinispan.commands.Visitor
        Overrides:
        visitLockControlCommand in class DDAsyncInterceptor
        Throws:
        java.lang.Throwable