Examples of TxInvocationContext


Examples of org.infinispan.context.impl.TxInvocationContext

      if (command.hasFlag(Flag.PUT_FOR_EXTERNAL_READ)) {
         // Cache.putForExternalRead() is non-transactional
         return super.visitPutKeyValueCommand(ctx, command);
      }

      final TxInvocationContext txContext = (TxInvocationContext) ctx;
      try {
         boolean skipLocking = hasSkipLocking(command);
         if (!skipLocking) {
            boolean localLock = cdl.localNodeIsPrimaryOwner(command.getKey());
            acquireRemoteIfNeeded(ctx, command, localLock);
View Full Code Here

Examples of org.infinispan.context.impl.TxInvocationContext

   public Object visitPutMapCommand(InvocationContext ctx, PutMapCommand command) throws Throwable {
      try {
         boolean skipLocking = hasSkipLocking(command);
         if (!skipLocking) {
            acquireRemoteIfNeeded(ctx, command.getMap().keySet(), command);
            final TxInvocationContext txContext = (TxInvocationContext) ctx;
            long lockTimeout = getLockAcquisitionTimeout(command, skipLocking);
            for (Object key : command.getMap().keySet()) {
               lockAndRegisterBackupLock(txContext, key, lockTimeout, skipLocking);
            }
         }
View Full Code Here

Examples of org.infinispan.context.impl.TxInvocationContext

      try {
         boolean skipLocking = hasSkipLocking(command);
         if (!skipLocking) {
            final boolean localNodeOwnsLock = cdl.localNodeIsPrimaryOwner(command.getKey());
            acquireRemoteIfNeeded(ctx, command, localNodeOwnsLock);
            final TxInvocationContext txContext = (TxInvocationContext) ctx;
            long lockTimeout = getLockAcquisitionTimeout(command, skipLocking);
            lockAndRegisterBackupLock(txContext, command.getKey(),
                  localNodeOwnsLock, lockTimeout, skipLocking);
         }
         return invokeNextInterceptor(ctx, command);
View Full Code Here

Examples of org.infinispan.context.impl.TxInvocationContext

      try {
         boolean skipLocking = hasSkipLocking(command);
         if (!skipLocking) {
            final boolean localNodeOwnsLock = cdl.localNodeIsPrimaryOwner(command.getKey());
            acquireRemoteIfNeeded(ctx, command, localNodeOwnsLock);
            final TxInvocationContext txContext = (TxInvocationContext) ctx;
            long lockTimeout = getLockAcquisitionTimeout(command, skipLocking);
            lockAndRegisterBackupLock(txContext, command.getKey(),
                  localNodeOwnsLock, lockTimeout, skipLocking);
         }
         return invokeNextInterceptor(ctx, command);
View Full Code Here

Examples of org.infinispan.context.impl.TxInvocationContext

      }
   }

   private void acquireRemoteIfNeeded(InvocationContext ctx, Set<Object> keys, FlagAffectedCommand command) throws Throwable {
      if (ctx.isOriginLocal() && !command.hasFlag(Flag.CACHE_MODE_LOCAL)) {
         final TxInvocationContext txContext = (TxInvocationContext) ctx;
         LocalTransaction localTransaction = (LocalTransaction) txContext.getCacheTransaction();
         if (localTransaction.getAffectedKeys().containsAll(keys)) {
            log.tracef("We already have lock for keys %s, skip remote lock acquisition", keys);
            return;
         } else {
            LockControlCommand lcc = cf.buildLockControlCommand(keys,
                  command.getFlags(), txContext.getGlobalTransaction());
            invokeNextInterceptor(ctx, lcc);
         }
      }
      ((TxInvocationContext) ctx).addAllAffectedKeys(keys);
   }
View Full Code Here

Examples of org.infinispan.context.impl.TxInvocationContext

   private void acquireRemoteIfNeeded(InvocationContext ctx, AbstractDataCommand command, boolean localNodeIsLockOwner) throws Throwable {
      Object key = command.getKey();
      boolean needBackupLocks = ctx.isOriginLocal() && (!localNodeIsLockOwner || isStateTransferInProgress());
      if (needBackupLocks && !command.hasFlag(Flag.CACHE_MODE_LOCAL)) {
         final TxInvocationContext txContext = (TxInvocationContext) ctx;
         LocalTransaction localTransaction = (LocalTransaction) txContext.getCacheTransaction();
         final boolean alreadyLocked = localTransaction.getAffectedKeys().contains(key);
         if (alreadyLocked) {
            log.tracef("We already have lock for key %s, skip remote lock acquisition", key);
            return;
         } else {
            LockControlCommand lcc = cf.buildLockControlCommand(
                  key, command.getFlags(), txContext.getGlobalTransaction());
            invokeNextInterceptor(ctx, lcc);
         }
      }
      ((TxInvocationContext) ctx).addAffectedKey(key);
   }
View Full Code Here

Examples of org.infinispan.context.impl.TxInvocationContext

   }

   private void releaseLocksOnFailureBeforePrepare(InvocationContext ctx) {
      lockManager.unlockAll(ctx);
      if (ctx.isOriginLocal() && ctx.isInTxScope() && rpcManager != null) {
         final TxInvocationContext txContext = (TxInvocationContext) ctx;
         TxCompletionNotificationCommand command = cf.buildTxCompletionNotificationCommand(null, txContext.getGlobalTransaction());
         final LocalTransaction cacheTransaction = (LocalTransaction) txContext.getCacheTransaction();
         rpcManager.invokeRemotely(cacheTransaction.getRemoteLocksAcquired(), command, rpcManager.getDefaultRpcOptions(true, false));
      }
   }
View Full Code Here

Examples of org.infinispan.context.impl.TxInvocationContext

      if (log.isDebugEnabled())
         log.debug("Cache [" + rpcManager.getAddress() + "] replicating " + invalidateCommand);
     
      ReplicableCommand command = invalidateCommand;
      if (ctx.isInTxScope()) {
         TxInvocationContext txCtx = (TxInvocationContext) ctx;
         // A Prepare command containing the invalidation command in its 'modifications' list is sent to the remote nodes
         // so that the invalidation is executed in the same transaction and locks can be acquired and released properly.
         // This is 1PC on purpose, as an optimisation, even if the current TX is 2PC.
         // If the cache uses 2PC it's possible that the remotes will commit the invalidation and the originator rolls back,
         // but this does not impact consistency and the speed benefit is worth it.
         command = commandsFactory.buildPrepareCommand(txCtx.getGlobalTransaction(), Collections.<WriteCommand>singletonList(invalidateCommand), true);        
      }
      rpcManager.invokeRemotely(null, command, rpcManager.getDefaultRpcOptions(synchronous));
   }
View Full Code Here

Examples of org.infinispan.context.impl.TxInvocationContext

    *
    * Note: The algorithm described below only when nodes leave the cluster, so it doesn't add a performance burden
    * when the cluster is stable.
    */
   protected final void lockKeyAndCheckOwnership(InvocationContext ctx, Object key, long lockTimeout, boolean skipLocking) throws InterruptedException {
      TxInvocationContext txContext = (TxInvocationContext) ctx;
      int transactionTopologyId = -1;
      boolean checkForPendingLocks = false;
      if (clustered) {
         CacheTransaction tx = txContext.getCacheTransaction();
         boolean isFromStateTransfer = txContext.isOriginLocal() && ((LocalTransaction)tx).isFromStateTransfer();
         // if the transaction is from state transfer it should not wait for the backup locks of other transactions
         if (!isFromStateTransfer) {
            transactionTopologyId = tx.getTopologyId();
            if (transactionTopologyId != TransactionTable.CACHE_STOPPED_TOPOLOGY_ID) {
               checkForPendingLocks = txTable.getMinTopologyId() < transactionTopologyId;
View Full Code Here

Examples of org.infinispan.context.impl.TxInvocationContext

      if (ctx.isOriginLocal() && !isValueAvailableLocally(dm.getReadConsistentHash(), key) || dm.isAffectedByRehash(key) && !dataContainer.containsKey(key)) {
         if (trace) log.tracef("Doing a remote get for key %s", key);

         boolean acquireRemoteLock = false;
         if (ctx.isInTxScope()) {
            TxInvocationContext txContext = (TxInvocationContext) ctx;
            acquireRemoteLock = isWrite && isPessimisticCache && !txContext.getAffectedKeys().contains(key);
         }
         // attempt a remote lookup
         InternalCacheEntry ice = retrieveFromRemoteSource(key, ctx, acquireRemoteLock, command, isWrite);

         if (acquireRemoteLock) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.