Package org.infinispan.transaction

Examples of org.infinispan.transaction.RemoteTransaction


   @Override
   public void applyLocks(Collection<LockInfo> lockInfo, Address sender, int viewId) throws InterruptedException {
      if (lockInfo != null) {
         log.debugf("Integrating %d locks from %s", lockInfo.size(), sender);
         for (LockInfo lock : lockInfo) {
            RemoteTransaction remoteTx = transactionTable.getRemoteTransaction(lock.getGlobalTransaction());
            if (remoteTx == null) {
               remoteTx = transactionTable.createRemoteTransaction(lock.getGlobalTransaction(), null);
               remoteTx.setMissingModifications(true);
            }
            Object result = lockContainer.acquireLock(remoteTx.getGlobalTransaction(), lock.getKey(), 0, TimeUnit.SECONDS);
            if (result == null) {
               throw new IllegalStateException("Could not acquire lock for key " + lock.getKey());
            }
         }
      }
View Full Code Here


   @Override
   public Object perform(InvocationContext ignored) throws Throwable {
      if (ignored != null)
         throw new IllegalStateException("Expected null context!");

      RemoteTransaction transaction = txTable.getRemoteTransaction(globalTx);

      if (transaction == null) {
         if (unlock) {
            log.tracef("Unlock for non-existant transaction %s.  Not doing anything.", globalTx);
            return null;
View Full Code Here

            LockControlCommand lcc = (LockControlCommand) c;
            lcc.init(interceptorChain, icc, txTable);
            lcc.markTransactionAsRemote(isRemote);
            if (configuration.isEnableDeadlockDetection() && isRemote) {
               DldGlobalTransaction gtx = (DldGlobalTransaction) lcc.getGlobalTransaction();
               RemoteTransaction transaction = txTable.getRemoteTransaction(gtx);
               if (transaction != null) {
                  if (!configuration.getCacheMode().isDistributed()) {
                     Set<Object> keys = txTable.getLockedKeysForRemoteTransaction(gtx);
                     GlobalTransaction gtx2 = transaction.getGlobalTransaction();
                     ((DldGlobalTransaction) gtx2).setLocksHeldAtOrigin(keys);
                     gtx.setLocksHeldAtOrigin(keys);
                  } else {
                     GlobalTransaction gtx2 = transaction.getGlobalTransaction();
                     ((DldGlobalTransaction) gtx2).setLocksHeldAtOrigin(gtx.getLocksHeldAtOrigin());
                  }
               }
            }
            break;
View Full Code Here

      super.updateStateOnNodesLeaving(leavers);
   }

   @Override
   public RemoteTransaction getRemoteTransaction(GlobalTransaction txId) {
      RemoteTransaction remoteTransaction = super.getRemoteTransaction(txId);
      if (remoteTransaction != null) return remoteTransaction;
      //also look in the recovery manager, as this transaction might be prepared
      return recoveryManager.getPreparedTransaction(((RecoverableTransactionIdentifier) txId).getXid());
   }
View Full Code Here

   public RemoteTransaction removeRemoteTransaction(Xid xid) {
      if (clustered) {
         Iterator<RemoteTransaction> it = getRemoteTransactions().iterator();
         while (it.hasNext()) {
            RemoteTransaction next = it.next();
            RecoverableTransactionIdentifier gtx = (RecoverableTransactionIdentifier) next.getGlobalTransaction();
            if (xid.equals(gtx.getXid())) {
               it.remove();
               recalculateMinViewIdIfNeeded(next);
               next.notifyOnTransactionFinished();
               return next;
            }
         }
      }
      return null;
View Full Code Here

   }

   public Object perform(InvocationContext ctx) throws Throwable {
      if (ctx != null) throw new IllegalStateException("Expected null context!");
      markGtxAsRemote();
      RemoteTransaction transaction = txTable.getRemoteTransaction(globalTx);
      if (transaction == null || transaction.isMissingModifications()) {
         if (trace) log.tracef("Did not find a RemoteTransaction for %s", globalTx);
         return invalidRemoteTxReturnValue();
      }
      visitRemoteTransaction(transaction);
      RemoteTxInvocationContext ctxt = icc.createRemoteTxInvocationContext(
View Full Code Here

         log.tracef("The transaction %s is already prepared. Skipping prepare call.", globalTx);
         return null;
      }

      // 1. first create a remote transaction
      RemoteTransaction remoteTransaction = txTable.getRemoteTransaction(globalTx);
      boolean remoteTxInitiated = remoteTransaction != null;
      if (!remoteTxInitiated) {
         remoteTransaction = txTable.createRemoteTransaction(globalTx, modifications);
      } else {
         /*
          * remote tx was already created by Cache#lock() API call
          * set the proper modifications since lock has none
          *
          * @see LockControlCommand.java
          * https://jira.jboss.org/jira/browse/ISPN-48
          */
         remoteTransaction.setModifications(getModifications());
      }

      // 2. then set it on the invocation context
      RemoteTxInvocationContext ctx = icc.createRemoteTxInvocationContext(remoteTransaction, getOrigin());

View Full Code Here

                       command.getGlobalTransaction(), alreadyCompleted, originatorMissing);
            RollbackCommand rollback = new RollbackCommand(command.getCacheName(), command.getGlobalTransaction());
            try {
               invokeNextInterceptor(ctx, rollback);
            } finally {
               RemoteTransaction remoteTx = (RemoteTransaction) ctx.getCacheTransaction();
               remoteTx.markForRollback(true);
               txTable.removeRemoteTransaction(command.getGlobalTransaction());
            }
         }
      }
   }
View Full Code Here

                       command.getGlobalTransaction(), alreadyCompleted, originatorMissing);
            RollbackCommand rollback = new RollbackCommand(command.getCacheName(), command.getGlobalTransaction());
            try {
               invokeNextInterceptor(ctx, rollback);
            } finally {
               RemoteTransaction remoteTx = (RemoteTransaction) ctx.getCacheTransaction();
               remoteTx.markForRollback(true);
               txTable.removeRemoteTransaction(command.getGlobalTransaction());
            }
         }
      }
   }
View Full Code Here

            if (!transactionLog.hasPendingPrepare(command)) {
               if (trace) log.trace("Applying pending prepare %s", command);
               commandsFactory.initializeReplicableCommand(command, false);
               RemoteTxInvocationContext ctx = invocationContextContainer.createRemoteTxInvocationContext(null /* No idea if this right PLM */);
               RemoteTransaction transaction = txTable.createRemoteTransaction(command.getGlobalTransaction(), command.getModifications());
               ctx.setRemoteTransaction(transaction);
               ctx.setFlags(CACHE_MODE_LOCAL, Flag.SKIP_CACHE_STATUS_CHECK);
               interceptorChain.invoke(ctx, command);
            } else {
               if (trace) log.trace("Prepare %s not in tx log; not applying", command);
View Full Code Here

TOP

Related Classes of org.infinispan.transaction.RemoteTransaction

Copyright © 2018 www.massapicom. 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.