qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1602437 - /qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
Date Fri, 13 Jun 2014 14:20:05 GMT
Author: kwall
Date: Fri Jun 13 14:20:04 2014
New Revision: 1602437

URL: http://svn.apache.org/r1602437
Log:
QPID-5800: [Java Broker] Refactor BDBConfigurationStore, move methods/fields associated with
only BDBMessageStore to the inner class.

Addresses review comment from Alex Rudyy.

Modified:
    qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java?rev=1602437&r1=1602436&r2=1602437&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
(original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java
Fri Jun 13 14:20:04 2014
@@ -99,36 +99,17 @@ public class BDBConfigurationStore imple
     private static final Logger LOGGER = Logger.getLogger(BDBConfigurationStore.class);
 
     public static final int VERSION = 8;
-    private static String CONFIGURED_OBJECTS_DB_NAME = "CONFIGURED_OBJECTS";
-    private static String CONFIGURED_OBJECT_HIERARCHY_DB_NAME = "CONFIGURED_OBJECT_HIERARCHY";
+    private static final String CONFIGURED_OBJECTS_DB_NAME = "CONFIGURED_OBJECTS";
+    private static final String CONFIGURED_OBJECT_HIERARCHY_DB_NAME = "CONFIGURED_OBJECT_HIERARCHY";
 
-    private static String MESSAGE_META_DATA_DB_NAME = "MESSAGE_METADATA";
-    private static String MESSAGE_META_DATA_SEQ_DB_NAME = "MESSAGE_METADATA.SEQ";
-    private static String MESSAGE_CONTENT_DB_NAME = "MESSAGE_CONTENT";
-    private static String DELIVERY_DB_NAME = "QUEUE_ENTRIES";
-
-    //TODO: Add upgrader to remove BRIDGES and LINKS
-    private static String BRIDGEDB_NAME = "BRIDGES";
-    private static String LINKDB_NAME = "LINKS";
-    private static String XID_DB_NAME = "XIDS";
     private EnvironmentFacade _environmentFacade;
 
-    private static final DatabaseEntry MESSAGE_METADATA_SEQ_KEY = new DatabaseEntry("MESSAGE_METADATA_SEQ_KEY".getBytes(
-            Charset.forName("UTF-8")));
-
-    private static final SequenceConfig MESSAGE_METADATA_SEQ_CONFIG = SequenceConfig.DEFAULT.
-            setAllowCreate(true).
-            setInitialValue(1).
-            setWrap(true).
-            setCacheSize(100000);
-
-    private final AtomicBoolean _messageStoreOpen = new AtomicBoolean();
     private final AtomicBoolean _configurationStoreOpen = new AtomicBoolean();
 
     private final EnvironmentFacadeFactory _environmentFacadeFactory;
 
     private String _storeLocation;
-    private final BDBMessageStore _messageStoreFacade = new BDBMessageStore();
+    private final BDBMessageStore _messageStore = new BDBMessageStore();
     private ConfiguredObject<?> _parent;
 
     public BDBConfigurationStore()
@@ -260,7 +241,7 @@ public class BDBConfigurationStore imple
     {
         if (_configurationStoreOpen.compareAndSet(true, false))
         {
-            if (!_messageStoreOpen.get())
+            if (!_messageStore.isMessageStoreOpen())
             {
                 closeEnvironment();
             }
@@ -531,12 +512,12 @@ public class BDBConfigurationStore imple
     @Override
     public MessageStore getMessageStore()
     {
-        return _messageStoreFacade;
+        return _messageStore;
     }
 
     private void checkConfigurationStoreOpen()
     {
-        if (!_configurationStoreOpen.get())
+        if (!isConfigurationStoreOpen())
         {
             throw new IllegalStateException("Configuration store is not open");
         }
@@ -544,7 +525,7 @@ public class BDBConfigurationStore imple
 
     public void onDelete()
     {
-        if (!_configurationStoreOpen.get() && !_messageStoreOpen.get())
+        if (!isConfigurationStoreOpen() && !_messageStore.isMessageStoreOpen())
         {
             if (_storeLocation != null)
             {
@@ -565,6 +546,11 @@ public class BDBConfigurationStore imple
         }
     }
 
+    private boolean isConfigurationStoreOpen()
+    {
+        return _configurationStoreOpen.get();
+    }
+
     private Database getConfiguredObjectsDb()
     {
         return _environmentFacade.openDatabase(CONFIGURED_OBJECTS_DB_NAME, DEFAULT_DATABASE_CONFIG);
@@ -575,36 +561,32 @@ public class BDBConfigurationStore imple
         return _environmentFacade.openDatabase(CONFIGURED_OBJECT_HIERARCHY_DB_NAME, DEFAULT_DATABASE_CONFIG);
     }
 
-    private Database getMessageContentDb()
+    class BDBMessageStore implements MessageStore
     {
-        return _environmentFacade.openDatabase(MESSAGE_CONTENT_DB_NAME, DEFAULT_DATABASE_CONFIG);
-    }
+        private static final int LOCK_RETRY_ATTEMPTS = 5;
 
-    private Database getMessageMetaDataDb()
-    {
-        return _environmentFacade.openDatabase(MESSAGE_META_DATA_DB_NAME, DEFAULT_DATABASE_CONFIG);
-    }
+        private static final String MESSAGE_META_DATA_DB_NAME = "MESSAGE_METADATA";
+        private static final String MESSAGE_META_DATA_SEQ_DB_NAME = "MESSAGE_METADATA.SEQ";
+        private static final String MESSAGE_CONTENT_DB_NAME = "MESSAGE_CONTENT";
+        private static final String DELIVERY_DB_NAME = "QUEUE_ENTRIES";
+
+        //TODO: Add upgrader to remove BRIDGES and LINKS
+        private static final String BRIDGEDB_NAME = "BRIDGES";
+        private static final String LINKDB_NAME = "LINKS";
+        private static final String XID_DB_NAME = "XIDS";
 
-    private Database getMessageMetaDataSeqDb()
-    {
-        return _environmentFacade.openDatabase(MESSAGE_META_DATA_SEQ_DB_NAME, DEFAULT_DATABASE_CONFIG);
-    }
+        private final EventManager _eventManager = new EventManager();
 
-    private Database getDeliveryDb()
-    {
-        return _environmentFacade.openDatabase(DELIVERY_DB_NAME, DEFAULT_DATABASE_CONFIG);
-    }
+        private final AtomicBoolean _messageStoreOpen = new AtomicBoolean();
 
-    private Database getXidDb()
-    {
-        return _environmentFacade.openDatabase(XID_DB_NAME, DEFAULT_DATABASE_CONFIG);
-    }
+        private final DatabaseEntry MESSAGE_METADATA_SEQ_KEY = new DatabaseEntry("MESSAGE_METADATA_SEQ_KEY".getBytes(
+                Charset.forName("UTF-8")));
 
-    class BDBMessageStore implements MessageStore
-    {
-        private static final int LOCK_RETRY_ATTEMPTS = 5;
-
-        private final EventManager _eventManager = new EventManager();
+        private final SequenceConfig MESSAGE_METADATA_SEQ_CONFIG = SequenceConfig.DEFAULT.
+                setAllowCreate(true).
+                setInitialValue(1).
+                setWrap(true).
+                setCacheSize(100000);
 
         private boolean _limitBusted;
         private long _persistentSizeLowThreshold;
@@ -683,6 +665,11 @@ public class BDBConfigurationStore imple
             return true;
         }
 
+        public boolean isMessageStoreOpen()
+        {
+            return _messageStoreOpen.get();
+        }
+
         @Override
         public org.apache.qpid.server.store.Transaction newTransaction()
         {
@@ -694,7 +681,7 @@ public class BDBConfigurationStore imple
         @Override
         public void closeMessageStore()
         {
-            if (_messageStoreOpen.compareAndSet(true, false) && !_configurationStoreOpen.get())
+            if (_messageStoreOpen.compareAndSet(true, false) && !isConfigurationStoreOpen())
             {
                 closeEnvironment();
             }
@@ -1451,6 +1438,31 @@ public class BDBConfigurationStore imple
             return _environmentFacade.getEnvironment().getStats(null).getTotalLogSize();
         }
 
+        private Database getMessageContentDb()
+        {
+            return _environmentFacade.openDatabase(MESSAGE_CONTENT_DB_NAME, DEFAULT_DATABASE_CONFIG);
+        }
+
+        private Database getMessageMetaDataDb()
+        {
+            return _environmentFacade.openDatabase(MESSAGE_META_DATA_DB_NAME, DEFAULT_DATABASE_CONFIG);
+        }
+
+        private Database getMessageMetaDataSeqDb()
+        {
+            return _environmentFacade.openDatabase(MESSAGE_META_DATA_SEQ_DB_NAME, DEFAULT_DATABASE_CONFIG);
+        }
+
+        private Database getDeliveryDb()
+        {
+            return _environmentFacade.openDatabase(DELIVERY_DB_NAME, DEFAULT_DATABASE_CONFIG);
+        }
+
+        private Database getXidDb()
+        {
+            return _environmentFacade.openDatabase(XID_DB_NAME, DEFAULT_DATABASE_CONFIG);
+        }
+
         private class StoredBDBMessage<T extends StorableMessageMetaData> implements
StoredMessage<T>
         {
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message