[jboss-cvs] JBoss Messaging SVN: r5574 - in trunk/src/main/org/jboss/messaging/core: postoffice/impl and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Jan 3 07:01:09 EST 2009


Author: timfox
Date: 2009-01-03 07:01:08 -0500 (Sat, 03 Jan 2009)
New Revision: 5574

Added:
   trunk/src/main/org/jboss/messaging/core/transaction/TransactionPropertyIndexes.java
Modified:
   trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
   trunk/src/main/org/jboss/messaging/core/postoffice/impl/DuplicateIDCacheImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
   trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java
   trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
Log:
Transaction, paging, routing refactoring part 4


Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java	2009-01-03 11:31:18 UTC (rev 5573)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java	2009-01-03 12:01:08 UTC (rev 5574)
@@ -48,6 +48,7 @@
 import org.jboss.messaging.core.server.ServerMessage;
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.core.transaction.Transaction;
+import org.jboss.messaging.core.transaction.TransactionPropertyIndexes;
 import org.jboss.messaging.core.transaction.impl.TransactionImpl;
 import org.jboss.messaging.util.SimpleString;
 
@@ -733,7 +734,11 @@
       // Depage has to be done atomically, in case of failure it should be
       // back to where it was
       
-      Transaction depageTransaction = new TransactionImpl(storageManager, postOffice, true);
+      Transaction depageTransaction = new TransactionImpl(storageManager, postOffice);
+      
+      depageTransaction.setContainsPersistent(true);
+      
+      depageTransaction.putProperty(TransactionPropertyIndexes.IS_DEPAGE, Boolean.valueOf(true));
 
       HashSet<PageTransactionInfo> pageTransactionsToUpdate = new HashSet<PageTransactionInfo>();
             

Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/DuplicateIDCacheImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/DuplicateIDCacheImpl.java	2009-01-03 11:31:18 UTC (rev 5573)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/DuplicateIDCacheImpl.java	2009-01-03 12:01:08 UTC (rev 5574)
@@ -178,7 +178,9 @@
 
       if (persist)
       {
-         tx.addDuplicateID(address, duplID, recordID);
+         storageManager.storeDuplicateIDTransactional(tx.getID(), address, duplID, recordID);
+
+         tx.setContainsPersistent(true);
       }
 
       // For a tx, it's important that the entry is not added to the cache until commit (or prepare)

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java	2009-01-03 11:31:18 UTC (rev 5573)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/QueueImpl.java	2009-01-03 12:01:08 UTC (rev 5574)
@@ -13,10 +13,12 @@
 package org.jboss.messaging.core.server.impl;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Set;
 import java.util.concurrent.Executor;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -43,6 +45,7 @@
 import org.jboss.messaging.core.settings.impl.QueueSettings;
 import org.jboss.messaging.core.transaction.Transaction;
 import org.jboss.messaging.core.transaction.TransactionOperation;
+import org.jboss.messaging.core.transaction.TransactionPropertyIndexes;
 import org.jboss.messaging.core.transaction.impl.TransactionImpl;
 import org.jboss.messaging.util.ConcurrentHashSet;
 import org.jboss.messaging.util.ConcurrentSet;
@@ -241,9 +244,21 @@
 
          SimpleString destination = message.getDestination();
 
-         if (!tx.isDepage() && !message.isReload() && (tx.getPagingAddresses().contains(destination) || pagingManager.isPaging(destination)))
+         //TODO - this can all be optimised
+         Set<SimpleString> pagingAddresses = (Set<SimpleString>)tx.getProperty(TransactionPropertyIndexes.DESTINATIONS_IN_PAGE_MODE);
+         
+         if (pagingAddresses == null)
          {
-            tx.addPagingAddress(destination);
+            pagingAddresses = new HashSet<SimpleString>();
+            
+            tx.putProperty(TransactionPropertyIndexes.DESTINATIONS_IN_PAGE_MODE, pagingAddresses);
+         }
+         
+         boolean depage = tx.getProperty(TransactionPropertyIndexes.IS_DEPAGE) != null;
+         
+         if (!depage && !message.isReload() && (pagingAddresses.contains(destination) || pagingManager.isPaging(destination)))
+         {
+            pagingAddresses.add(destination);
 
             tx.addPagingMessage(message);
          }

Modified: trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java	2009-01-03 11:31:18 UTC (rev 5573)
+++ trunk/src/main/org/jboss/messaging/core/transaction/Transaction.java	2009-01-03 12:01:08 UTC (rev 5574)
@@ -47,28 +47,12 @@
 
    void commit() throws Exception;
 
-   //List<MessageReference> rollback(HierarchicalRepository<QueueSettings> queueSettingsRepository) throws Exception;
-   
    void rollback() throws Exception;
 
-   void addDuplicateID(SimpleString address, SimpleString duplID, long recordID) throws Exception;
-
-   Set<SimpleString> getPagingAddresses();
-   
-   void addPagingAddress(SimpleString address);
-   
    void addPagingMessage(ServerMessage message);
 
-  // void addAcknowledgement(MessageReference acknowledgement) throws Exception;
-   
-  // void addAckTempUntilNextRefactoring(MessageReference ref);
-   
-   boolean isDepage();
-   
    void setContainsPersistent(boolean containsPersistent);
 
-  // int getAcknowledgementsCount();
-   
    int getOperationsCount();
 
    long getID();
@@ -89,8 +73,6 @@
 
    void setPageTransaction(PageTransactionInfo pageTransaction);
 
-//   List<MessageReference> timeout() throws Exception;
-
    long getCreateTime();
 
    void addOperation(TransactionOperation sync);

Added: trunk/src/main/org/jboss/messaging/core/transaction/TransactionPropertyIndexes.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/TransactionPropertyIndexes.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/transaction/TransactionPropertyIndexes.java	2009-01-03 12:01:08 UTC (rev 5574)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.jboss.messaging.core.transaction;
+
+/**
+ * A TransactionPropertyIndexes
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * 
+ * Created 2 Jan 2009 19:48:07
+ *
+ *
+ */
+public class TransactionPropertyIndexes
+{
+   public static final int QUEUE_MAP_INDEX = 0;
+   
+   public static final int ROLLBACK_COUNTER_INDEX = 1;
+   
+   public static final int DESTINATIONS_IN_PAGE_MODE = 2;
+   
+   public static final int IS_DEPAGE = 3;
+}

Modified: trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java	2009-01-03 11:31:18 UTC (rev 5573)
+++ trunk/src/main/org/jboss/messaging/core/transaction/impl/TransactionImpl.java	2009-01-03 12:01:08 UTC (rev 5574)
@@ -56,11 +56,6 @@
 
    private final PagingManager pagingManager;
 
-   /** List of destinations in page mode.
-    *  Once a destination was considered in page, it should go toward paging until commit is called, 
-    *  even if the page-mode has changed, or messageOrder won't be respected */
-   private final Set<SimpleString> destinationsInPageMode = new HashSet<SimpleString>();
-
    // FIXME: As part of https://jira.jboss.org/jira/browse/JBMESSAGING-1313
    private final List<ServerMessage> pagedMessages = new ArrayList<ServerMessage>();
 
@@ -81,7 +76,7 @@
    private final long createTime;
    
    //For a transaction used for depaging, we never want to immediately page the refs again
-   private final boolean depage;
+   //private final boolean depage;
 
    public TransactionImpl(final StorageManager storageManager, final PostOffice postOffice)
    {
@@ -103,40 +98,8 @@
       id = storageManager.generateUniqueID();
 
       createTime = System.currentTimeMillis();
-      
-      this.depage = false;
    }
-   
-   public TransactionImpl(final StorageManager storageManager, final PostOffice postOffice, final boolean depage)
-   {
-      this.storageManager = storageManager;
 
-      this.postOffice = postOffice;
-
-      if (postOffice == null)
-      {
-         pagingManager = null;
-      }
-      else
-      {
-         pagingManager = postOffice.getPagingManager();
-      }
-
-      xid = null;
-
-      id = storageManager.generateUniqueID();
-
-      createTime = System.currentTimeMillis();
-      
-      this.depage = depage;
-      
-      if (depage)
-      {
-         //Need to force to true, since other last page record won't be committed
-         this.containsPersistent = true;
-      }
-   }
-
    public TransactionImpl(final Xid xid, final StorageManager storageManager, final PostOffice postOffice)
    {
       this.storageManager = storageManager;
@@ -157,8 +120,6 @@
       id = storageManager.generateUniqueID();
 
       createTime = System.currentTimeMillis();
-      
-      this.depage = false;
    }
 
    public TransactionImpl(final long id, final Xid xid, final StorageManager storageManager, final PostOffice postOffice)
@@ -181,8 +142,6 @@
       }
 
       createTime = System.currentTimeMillis();
-      
-      this.depage = false;
    }
 
    // Transaction implementation
@@ -193,13 +152,6 @@
       return id;
    }
 
-   public void addDuplicateID(final SimpleString address, final SimpleString duplID, final long recordID) throws Exception
-   {
-      storageManager.storeDuplicateIDTransactional(id, address, duplID, recordID);
-
-      containsPersistent = true;
-   }
-
    public long getCreateTime()
    {
       return createTime;
@@ -439,26 +391,11 @@
       this.pageTransaction = pageTransaction;      
    }
    
-   public Set<SimpleString> getPagingAddresses()
-   {
-      return destinationsInPageMode;
-   }
-   
    public void addPagingMessage(final ServerMessage message)
    {
       this.pagedMessages.add(message);
    }
    
-   public boolean isDepage()
-   {
-      return depage;
-   }
-   
-   public void addPagingAddress(final SimpleString address)
-   {
-      this.destinationsInPageMode.add(address);
-   }
-   
    public int getOperationsCount()
    {
       return operations.size();




More information about the jboss-cvs-commits mailing list