[hornetq-commits] JBoss hornetq SVN: r8264 - in trunk: src/main/org/hornetq/core/postoffice/impl and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Nov 11 13:33:35 EST 2009


Author: timfox
Date: 2009-11-11 13:33:34 -0500 (Wed, 11 Nov 2009)
New Revision: 8264

Modified:
   trunk/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
   trunk/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java
   trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
   trunk/src/main/org/hornetq/core/server/impl/QueueImpl.java
   trunk/src/main/org/hornetq/core/transaction/Transaction.java
   trunk/src/main/org/hornetq/core/transaction/TransactionPropertyIndexes.java
   trunk/src/main/org/hornetq/core/transaction/impl/TransactionImpl.java
   trunk/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java
Log:
some tweaks to transactions

Modified: trunk/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java	2009-11-11 17:05:22 UTC (rev 8263)
+++ trunk/src/main/org/hornetq/core/paging/impl/PagingStoreImpl.java	2009-11-11 18:33:34 UTC (rev 8264)
@@ -988,7 +988,7 @@
       for (PageTransactionInfo pageWithTransaction : pageTransactionsToUpdate)
       {
          // This will set the journal transaction to commit;
-         depageTransaction.putProperty(TransactionPropertyIndexes.CONTAINS_PERSISTENT, true);
+         depageTransaction.setContainsPersistent();
 
          if (pageWithTransaction.getNumberOfMessages() == 0)
          {

Modified: trunk/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java	2009-11-11 17:05:22 UTC (rev 8263)
+++ trunk/src/main/org/hornetq/core/postoffice/impl/DuplicateIDCacheImpl.java	2009-11-11 18:33:34 UTC (rev 8264)
@@ -25,7 +25,6 @@
 import org.hornetq.core.server.Queue;
 import org.hornetq.core.transaction.Transaction;
 import org.hornetq.core.transaction.TransactionOperation;
-import org.hornetq.core.transaction.TransactionPropertyIndexes;
 import org.hornetq.utils.Pair;
 import org.hornetq.utils.SimpleString;
 
@@ -147,7 +146,7 @@
          {
             storageManager.storeDuplicateIDTransactional(tx.getID(), address, duplID, recordID);
 
-            tx.putProperty(TransactionPropertyIndexes.CONTAINS_PERSISTENT, true);
+            tx.setContainsPersistent();
          }
 
          // For a tx, it's important that the entry is not added to the cache until commit (or prepare)

Modified: trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java	2009-11-11 17:05:22 UTC (rev 8263)
+++ trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java	2009-11-11 18:33:34 UTC (rev 8264)
@@ -895,7 +895,7 @@
             {
                storageManager.storeReferenceTransactional(tx.getID(), queue.getID(), message.getMessageID());
 
-               tx.putProperty(TransactionPropertyIndexes.CONTAINS_PERSISTENT, true);
+               tx.setContainsPersistent();
             }
             else
             {
@@ -1190,7 +1190,7 @@
 
             if (pagingPersistent)
             {
-               tx.putProperty(TransactionPropertyIndexes.CONTAINS_PERSISTENT, true);
+               tx.setContainsPersistent();
 
                if (!pagingStoresToSync.isEmpty())
                {

Modified: trunk/src/main/org/hornetq/core/server/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/QueueImpl.java	2009-11-11 17:05:22 UTC (rev 8263)
+++ trunk/src/main/org/hornetq/core/server/impl/QueueImpl.java	2009-11-11 18:33:34 UTC (rev 8264)
@@ -522,7 +522,7 @@
       {
          storageManager.storeAcknowledgeTransactional(tx.getID(), id, message.getMessageID());
 
-         tx.putProperty(TransactionPropertyIndexes.CONTAINS_PERSISTENT, true);
+         tx.setContainsPersistent();
       }
 
       getRefsOperation(tx).addAck(ref);
@@ -534,7 +534,7 @@
 
       if (message.isDurable() && durable)
       {
-         tx.putProperty(TransactionPropertyIndexes.CONTAINS_PERSISTENT, true);
+         tx.setContainsPersistent();
       }
 
       getRefsOperation(tx).addAck(ref);

Modified: trunk/src/main/org/hornetq/core/transaction/Transaction.java
===================================================================
--- trunk/src/main/org/hornetq/core/transaction/Transaction.java	2009-11-11 17:05:22 UTC (rev 8263)
+++ trunk/src/main/org/hornetq/core/transaction/Transaction.java	2009-11-11 18:33:34 UTC (rev 8264)
@@ -59,6 +59,8 @@
    
    Object getProperty(int index);
    
+   void setContainsPersistent();
+   
    static enum State
    {
       ACTIVE, PREPARED, COMMITTED, ROLLEDBACK, SUSPENDED, ROLLBACK_ONLY

Modified: trunk/src/main/org/hornetq/core/transaction/TransactionPropertyIndexes.java
===================================================================
--- trunk/src/main/org/hornetq/core/transaction/TransactionPropertyIndexes.java	2009-11-11 17:05:22 UTC (rev 8263)
+++ trunk/src/main/org/hornetq/core/transaction/TransactionPropertyIndexes.java	2009-11-11 18:33:34 UTC (rev 8264)
@@ -26,8 +26,6 @@
 {
    public static final int IS_DEPAGE = 3;
    
-   public static final int CONTAINS_PERSISTENT = 4;
-   
    public static final int PAGE_TRANSACTION = 5;
    
    public static final int REFS_OPERATION = 6;

Modified: trunk/src/main/org/hornetq/core/transaction/impl/TransactionImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/transaction/impl/TransactionImpl.java	2009-11-11 17:05:22 UTC (rev 8263)
+++ trunk/src/main/org/hornetq/core/transaction/impl/TransactionImpl.java	2009-11-11 18:33:34 UTC (rev 8264)
@@ -24,7 +24,6 @@
 import org.hornetq.core.postoffice.PostOffice;
 import org.hornetq.core.transaction.Transaction;
 import org.hornetq.core.transaction.TransactionOperation;
-import org.hornetq.core.transaction.TransactionPropertyIndexes;
 
 /**
  * A TransactionImpl
@@ -57,8 +56,10 @@
 
    private final long createTime;
 
+   private volatile boolean containsPersistent;
+
    public TransactionImpl(final StorageManager storageManager)
-   {    
+   {
       this.storageManager = storageManager;
 
       xid = null;
@@ -69,7 +70,7 @@
    }
 
    public TransactionImpl(final Xid xid, final StorageManager storageManager, final PostOffice postOffice)
-   {      
+   {
       this.storageManager = storageManager;
 
       this.xid = xid;
@@ -80,7 +81,7 @@
    }
 
    public TransactionImpl(final long id, final Xid xid, final StorageManager storageManager)
-   {    
+   {
       this.storageManager = storageManager;
 
       this.xid = xid;
@@ -93,6 +94,11 @@
    // Transaction implementation
    // -----------------------------------------------------------
 
+   public void setContainsPersistent()
+   {
+      this.containsPersistent = true;
+   }
+   
    public long getID()
    {
       return id;
@@ -157,7 +163,7 @@
    }
 
    public void commit(boolean onePhase) throws Exception
-   {      
+   {
       synchronized (timeoutLock)
       {
          if (state == State.ROLLBACK_ONLY)
@@ -202,9 +208,9 @@
                operation.beforeCommit(this);
             }
          }
-         
+
          Runnable execAfterCommit = null;
-         
+
          if (operations != null)
          {
             execAfterCommit = new Runnable()
@@ -228,10 +234,12 @@
             };
          }
 
-         if ((getProperty(TransactionPropertyIndexes.CONTAINS_PERSISTENT) != null) || (xid != null && state == State.PREPARED))
+         if (containsPersistent || (xid != null && state == State.PREPARED))
          {
             storageManager.commit(id);
+
             state = State.COMMITTED;
+
             if (execAfterCommit != null)
             {
                if (storageManager.isReplicated())
@@ -273,7 +281,7 @@
          if (operations != null)
          {
             for (TransactionOperation operation : operations)
-            {              
+            {
                operation.beforeRollback(this);
             }
          }
@@ -375,7 +383,7 @@
 
    private void doRollback() throws Exception
    {
-      if ((getProperty(TransactionPropertyIndexes.CONTAINS_PERSISTENT) != null) || (xid != null && state == State.PREPARED))
+      if (containsPersistent || (xid != null && state == State.PREPARED))
       {
          storageManager.rollback(id);
       }

Modified: trunk/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java	2009-11-11 17:05:22 UTC (rev 8263)
+++ trunk/tests/src/org/hornetq/tests/unit/core/postoffice/impl/BindingsImplTest.java	2009-11-11 18:33:34 UTC (rev 8264)
@@ -274,6 +274,12 @@
          return Collections.emptySet();
       }
 
+      public void setContainsPersistent()
+      {
+         // TODO Auto-generated method stub
+         
+      }
+
    }
 
    class FakeMessage implements ServerMessage



More information about the hornetq-commits mailing list