Package org.jboss.cache.transaction

Examples of org.jboss.cache.transaction.TransactionContext


    * transaction.
    * This is O(N) WRT to the number of modifications so far.
    */
   private boolean wasRemovedInTx(Fqn fqn, InvocationContext ctx)
   {
      TransactionContext transactionContext = ctx.getTransactionContext();
      if (transactionContext == null) return false;

      for (WriteCommand txCacheCommand : transactionContext.getModifications())
      {
         if (txCacheCommand instanceof RemoveNodeCommand && fqn.isChildOrEquals(txCacheCommand.getFqn())) return true;
      }
      return false;
   }
View Full Code Here


         // Asssociate the local TX with the global TX. Create new
         // transactionContext for TX in txTable, the modifications
         // below will need this transactionContext to add their modifications
         // under the GlobalTx key
         TransactionContext transactionContext = txTable.get(gtx);
         if (transactionContext == null)
         {
            // create a new transaction transactionContext
            if (trace) log.trace("creating new tx transactionContext");
            transactionContext = contextFactory.createTransactionContext(ltx);
View Full Code Here

      }
   }

   protected void cleanupStaleLocks(InvocationContext ctx) throws Throwable
   {
      TransactionContext transactionContext = ctx.getTransactionContext();
      if (transactionContext != null) lockManager.unlock(ctx);
   }
View Full Code Here

      GlobalTransaction gtx;

      if (transactions.add(tx))
      {
         gtx = txTable.getCurrentTransaction(tx, true);
         TransactionContext transactionContext;
         if (ctx.getGlobalTransaction() == null)
         {
            ctx.setGlobalTransaction(gtx);
            transactionContext = txTable.get(gtx);
            ctx.setTransactionContext(transactionContext);
View Full Code Here

      // pass up the chain.
      Object retval = invokeNextInterceptor(ctx, command);
      if (!skipReplicationOfTransactionMethod(ctx))
      {
         GlobalTransaction gtx = getGlobalTransaction(ctx);
         TransactionContext transactionContext = ctx.getTransactionContext();
         if (transactionContext.hasLocalModifications())
         {
            OptimisticPrepareCommand replicablePrepareCommand = command.copy(); // makre sure we remove any "local" transactions
            replicablePrepareCommand.removeModifications(transactionContext.getLocalModifications());
            command = replicablePrepareCommand;
         }

         // replicate the prepare call.
         broadcastPrepare(command, gtx, ctx);
View Full Code Here

    * transaction.
    * This is O(N) WRT to the number of modifications so far.
    */
   private boolean wasRemovedInTx(Fqn fqn, InvocationContext ctx)
   {
      TransactionContext transactionContext = ctx.getTransactionContext();
      if (transactionContext == null) return false;

      for (WriteCommand txCacheCommand : transactionContext.getModifications())
      {
         if (txCacheCommand instanceof RemoveNodeCommand && fqn.isChildOrEquals(txCacheCommand.getFqn())) return true;
      }
      return false;
   }
View Full Code Here

   @Override
   public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
   {
      Object retVal = invokeNextInterceptor(ctx, command);
      TransactionContext transactionContext = ctx.getTransactionContext();
      if (transactionContext.hasLocalModifications())
      {
         PrepareCommand replicablePrepareCommand = command.copy(); // makre sure we remove any "local" transactions
         replicablePrepareCommand.removeModifications(transactionContext.getLocalModifications());
         command = replicablePrepareCommand;
      }

      if (!skipReplicationOfTransactionMethod(ctx)) runPreparePhase(command, command.getGlobalTransaction(), ctx);
      return retVal;
View Full Code Here

   }

   @Override
   protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
   {
      TransactionContext transactionContext = ctx.getTransactionContext();
      if (trace)
      {
         log.trace("called to rollback cache with GlobalTransaction=" + command.getGlobalTransaction());
      }
      if (transactionContext == null)
      {
         log.error("transactionContext for transaction " + command.getGlobalTransaction() + " not found (transaction has possibly already been rolled back)");
      }
      else
      {
         for (Fqn fqn : transactionContext.getRemovedNodes())
         {
            dataContainer.removeFromDataStructure(fqn, false);
         }
         // 1. Revert the modifications by running the undo-op list in reverse. This *cannot* throw any exceptions !

View Full Code Here

      // need to make a note of ALL nodes created here!!
      List<NodeSPI> createdNodes = new LinkedList<NodeSPI>();
      // we need to mark new nodes created as deleted since they are only created to form a path to the node being removed, to
      // create a lock.
      boolean created = lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, true, false, true, true, createdNodes, true);
      TransactionContext transactionContext = null;
      if (ctx.getGlobalTransaction() != null)
      {
         transactionContext = ctx.getTransactionContext();
         transactionContext.addRemovedNode(command.getFqn());
         for (NodeSPI nodeSPI : createdNodes)
         {
            transactionContext.addRemovedNode(nodeSPI.getFqn());
            nodeSPI.markAsDeleted(true);
         }
      }

      lockAllForRemoval(dataContainer.peek(command.getFqn(), false, false), ctx, transactionContext);
View Full Code Here

   }

   private void prepareCacheLoader(InvocationContext ctx) throws Throwable
   {
      GlobalTransaction gtx = ctx.getGlobalTransaction();
      TransactionContext tCtx = ctx.getTransactionContext();
      if (tCtx == null)
      {
         throw new Exception("tCtx for transaction " + gtx + " not found in transaction table");
      }
      List<Modification> cacheLoaderModifications = new ArrayList<Modification>();

      builder.visitCollection(ctx, tCtx.getModifications());
      if (cacheLoaderModifications.size() > 0)
      {
         loader.prepare(gtx, cacheLoaderModifications, false);
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.transaction.TransactionContext

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.