[rhmessaging-commits] rhmessaging commits: r4285 - in store/branches/java/0.5.x-dev/src: tools/java/org/apache/qpid/server/store/berkeleydb and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Sep 14 10:43:58 EDT 2010


Author: rgemmell
Date: 2010-09-14 10:43:58 -0400 (Tue, 14 Sep 2010)
New Revision: 4285

Modified:
   store/branches/java/0.5.x-dev/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
   store/branches/java/0.5.x-dev/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java
Log:
Only clean the logs when closing the store if it is not read only, preventing UnsupportedOperationException being thrown when using BDB4 libraries.

(reverts change in r4284, instead fixes the overlooked issue in the store itself)


Modified: store/branches/java/0.5.x-dev/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
===================================================================
--- store/branches/java/0.5.x-dev/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java	2010-09-14 14:23:36 UTC (rev 4284)
+++ store/branches/java/0.5.x-dev/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java	2010-09-14 14:43:58 UTC (rev 4285)
@@ -157,6 +157,8 @@
 
     private TransactionConfig _transactionConfig = new TransactionConfig();
 
+    private boolean _readOnly = false;
+
     public BDBMessageStore()
     {
         this(DATABASE_FORMAT_VERSION);
@@ -224,6 +226,7 @@
 
     public void configure(VirtualHost virtualHost, File environmentPath, boolean readonly) throws AMQException, DatabaseException
     {
+        _readOnly  = readonly;
         stateTransition(State.INITIAL, State.CONFIGURING);
 
         _log.info("Configuring BDB message store");
@@ -483,10 +486,13 @@
     {
         if (_environment != null)
         {
-            // Clean the log before closing. This makes sure it doesn't contain
-            // redundant data. Closing without doing this means the cleaner may not
-            // get a chance to finish.
-            _environment.cleanLog();
+            if(!_readOnly)
+            {
+                // Clean the log before closing. This makes sure it doesn't contain
+                // redundant data. Closing without doing this means the cleaner may not
+                // get a chance to finish.
+                _environment.cleanLog();
+            }
             _environment.close();
         }
     }

Modified: store/branches/java/0.5.x-dev/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java
===================================================================
--- store/branches/java/0.5.x-dev/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java	2010-09-14 14:23:36 UTC (rev 4284)
+++ store/branches/java/0.5.x-dev/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java	2010-09-14 14:43:58 UTC (rev 4285)
@@ -89,8 +89,6 @@
     VirtualHost _oldVirtualHost;
     /** The file ending that is used by BDB Store Files */
     private static final String BDB_FILE_ENDING = ".jdb";
-    /** Message of Exception thrown when closing down a read-only BDB3.3 store when using BDB4 */
-    private static final String NO_CLEAN_READ_ONLY = "Log cleaning not allowed in a read-only or memory-only environment";
 
     static final Options _options = new Options();
     static CommandLine _commandLine;
@@ -370,25 +368,7 @@
             _oldVirtualHost.close();
 
             _newMessageStore.close();
-            try
-            {
-                _oldMessageStore.close();
-            }
-            catch(UnsupportedOperationException e)
-            {
-                //When closing the old BDB3.3store, BDB4 will try to clean the logs 
-                //upgrade them and then throw an UnsupportedOperationException
-                String msg = e.getMessage();
-                
-                if(e !=null && msg.endsWith(NO_CLEAN_READ_ONLY))
-                {
-                    //ignore, expected
-                }
-                else
-                {
-                    throw e;
-                }
-            }
+            _oldMessageStore.close();
 
             //Shutdown the AR that the Vhosts will have created.
             ApplicationRegistry.remove(1);



More information about the rhmessaging-commits mailing list