Package org.jboss.cache

Examples of org.jboss.cache.TransactionEntry


            // under the GlobalTx key
            if (txTable.get(gtx) == null)
            {
                // create a new transaction entry

                TransactionEntry entry = cache.isNodeLockingOptimistic() ? new OptimisticTransactionEntry() : new TransactionEntry();
                entry.setTransaction(ltx);
                log.debug("creating new tx entry");
                txTable.put(gtx, entry);
                if (log.isTraceEnabled()) log.trace("TxTable contents: " + txTable);
            }
View Full Code Here


    }


    private void cleanupStaleLocks(GlobalTransaction gtx) throws Throwable
    {
        TransactionEntry entry = txTable.get(gtx);
        if (entry != null)
           entry.releaseAllLocksLIFO(gtx);
    }
View Full Code Here


    private void lockNodes(GlobalTransaction gtx) throws Exception
    {
        TransactionWorkspace workspace = getTransactionWorkspace(gtx);
        TransactionEntry te = cache.getTransactionTable().get(gtx);
        log.debug("locking nodes");

        // should be an ordered list
        Collection nodes = workspace.getNodes().values();

        for (Iterator it = nodes.iterator(); it.hasNext();)
        {
            WorkspaceNode workspaceNode = (WorkspaceNode) it.next();
            DataNode node = workspaceNode.getNode();

            boolean writeLock = workspaceNode.isDirty() || workspaceNode.isCreated() || workspaceNode.isDeleted() || (workspaceNode.isChildrenModified() && cache.getLockParentForChildInsertRemove());

            boolean acquired = node.acquire(gtx, lockAcquisitionTimeout, writeLock ? DataNode.LOCK_TYPE_WRITE : DataNode.LOCK_TYPE_READ);
            if (acquired)
            {
                if (log.isTraceEnabled()) log.trace("acquired lock on node " + node.getName());
                te.addLock(node.getLock());
            }
            else
            {
                throw new CacheException("unable to acquire lock on node " + node.getName());
            }
View Full Code Here

    }


    private void unlock(GlobalTransaction gtx)
    {
        TransactionEntry entry = txTable.get(gtx);
        entry.releaseAllLocksFIFO(gtx);
    }
View Full Code Here

      return o;
   }

   private void cleanup(GlobalTransaction gtx)
   {
      TransactionEntry entry = tx_table.get(gtx);
      // Let's do it in stack style, LIFO
      entry.releaseAllLocksLIFO(gtx);

      Transaction ltx = entry.getTransaction();
      if (log.isTraceEnabled())
      {
         log.trace("removing local transaction " + ltx + " and global transaction " + gtx);
      }
      tx_table.remove(ltx);
View Full Code Here

   private void commit(GlobalTransaction gtx)
   {
      if (log.isTraceEnabled())
         log.trace("committing cache with gtx " + gtx);

      TransactionEntry entry = tx_table.get(gtx);
      if (entry == null)
      {
         log.error("entry for transaction " + gtx + " not found (maybe already committed)");
         return;
      }

      // first remove nodes that should be deleted.
      Iterator removedNodes = entry.getRemovedNodes().iterator();
      while (removedNodes.hasNext())
      {
         Fqn f = (Fqn) removedNodes.next();
         cache.realRemove(f, false);
      }
View Full Code Here

    *
    * @param tx
    */
   private void rollback(GlobalTransaction tx)
   {
      TransactionEntry entry = tx_table.get(tx);

      if (log.isTraceEnabled())
         log.trace("called to rollback cache with GlobalTransaction=" + tx);

      if (entry == null)
      {
         log.error("entry for transaction " + tx + " not found (transaction has possibly already been rolled back)");
         return;
      }

      Iterator removedNodes = entry.getRemovedNodes().iterator();
      while (removedNodes.hasNext())
      {
         Fqn f = (Fqn) removedNodes.next();
         cache.realRemove(f, false);

      }

      // Revert the modifications by running the undo-op list in reverse. This *cannot* throw any exceptions !
      entry.undoOperations(cache);
   }
View Full Code Here

      boolean acquireLock = false; // do we need to acquire a lock if we load this node from cloader?
      Map nodeData = null;
      boolean initNode = false; // keep uninitialized
      Object key = null;
      InvocationContext ctx = getInvocationContext();
      TransactionEntry entry = null;
      GlobalTransaction gtx = null;
      if ((gtx = ctx.getGlobalTransaction()) != null)
      {
         entry = txTable.get(gtx);
      }
View Full Code Here

   private boolean wasRemovedInTx(Fqn fqn)
   {
      GlobalTransaction t = getInvocationContext().getGlobalTransaction();
      if (t == null)
         return false;
      TransactionEntry entry = txTable.get(t);
      Iterator i = entry.getCacheLoaderModifications().iterator();
      while (i.hasNext())
      {
         JBCMethodCall m = (JBCMethodCall) i.next();
         if (m.getMethodId() == MethodDeclarations.removeNodeMethodLocal_id
                 && fqn.isChildOrEquals((Fqn) m.getArgs()[1]))
View Full Code Here

      return o;
   }

   private void cleanup(GlobalTransaction gtx)
   {
      TransactionEntry entry = tx_table.get(gtx);
      // Let's do it in stack style, LIFO
      entry.releaseAllLocksLIFO(gtx);

      Transaction ltx = entry.getTransaction();
      if (log.isTraceEnabled())
      {
         log.trace("removing local transaction " + ltx + " and global transaction " + gtx);
      }
      tx_table.remove(ltx);
View Full Code Here

TOP

Related Classes of org.jboss.cache.TransactionEntry

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.