[rhmessaging-commits] rhmessaging commits: r4123 - store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Jul 16 11:24:03 EDT 2010


Author: rgemmell
Date: 2010-07-16 11:24:02 -0400 (Fri, 16 Jul 2010)
New Revision: 4123

Modified:
   store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
Log:
Implement new updateQueue() method to enable changing queue exclusivity in the store


Modified: store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
===================================================================
--- store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java	2010-07-16 15:23:14 UTC (rev 4122)
+++ store/trunk/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java	2010-07-16 15:24:02 UTC (rev 4123)
@@ -1073,7 +1073,7 @@
         
         createQueue(queueRecord);
     }
-    
+
     /**
      * Makes the specified queue persistent. 
      * 
@@ -1108,6 +1108,55 @@
     }
 
     /**
+     * Updates the specified queue in the persistent store, IF it is already present. If the queue
+     * is not present in the store, it will not be added.
+     * 
+     * NOTE: Currently only updates the exclusivity.
+     *
+     * @param queue The queue to update the entry for.
+     * @throws org.apache.qpid.AMQException  If the operation fails for any reason.
+     */
+    public void updateQueue(final AMQQueue queue) throws AMQException
+    {
+        if (_log.isDebugEnabled())
+        {
+            _log.debug("Updating queue: " + queue.getName());
+        }
+
+        try
+        {
+            DatabaseEntry key = new DatabaseEntry();
+            EntryBinding keyBinding = new AMQShortStringTB();
+            keyBinding.objectToEntry(queue.getNameShortString(), key);
+
+            DatabaseEntry value = new DatabaseEntry();
+            DatabaseEntry newValue = new DatabaseEntry();
+            TupleBinding queueBinding = _queueTupleBindingFactory.getInstance();
+
+            OperationStatus status = _queueDb.get(null, key, value, LockMode.RMW);
+            if(status == OperationStatus.SUCCESS)
+            {
+                //read the existing record and apply the new exclusivity setting 
+                QueueRecord queueRecord = (QueueRecord) queueBinding.entryToObject(value);
+                queueRecord.setExclusive(queue.isExclusive());
+                
+                //write the updated entry to the store
+                queueBinding.objectToEntry(queueRecord, newValue);
+                
+                _queueDb.put(null, key, newValue);
+            }
+            else if(status != OperationStatus.NOTFOUND)
+            {
+                throw new AMQException("Error updating queue details within the store: " + status);
+            }
+        }
+        catch (DatabaseException e)
+        {
+            throw new AMQException("Error updating queue details within the store: " + e,e);
+        }
+    }
+
+    /**
      * Removes the specified queue from the persistent store.
      *
      * @param queue The queue to remove.



More information about the rhmessaging-commits mailing list