activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6005 - have plist whack it existing state on start. Start the temp store after the primary persistence adapter which does the locking
Date Thu, 10 Dec 2015 14:25:50 GMT
Repository: activemq
Updated Branches:
  refs/heads/master d7febddb6 -> 768fa1708


https://issues.apache.org/jira/browse/AMQ-6005 - have plist whack it existing state on start.
Start the temp store after the primary persistence adapter which does the locking


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/768fa170
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/768fa170
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/768fa170

Branch: refs/heads/master
Commit: 768fa17085ac938441915a82987c99b37ac52515
Parents: d7febdd
Author: gtully <gary.tully@gmail.com>
Authored: Thu Dec 10 14:24:03 2015 +0000
Committer: gtully <gary.tully@gmail.com>
Committed: Thu Dec 10 14:24:03 2015 +0000

----------------------------------------------------------------------
 .../apache/activemq/broker/BrokerService.java   | 41 +++++++-------------
 .../store/kahadb/plist/PListStoreImpl.java      |  1 +
 .../FilePendingMessageCursorTestSupport.java    |  3 +-
 .../KahaDBFilePendingMessageCursorTest.java     |  1 +
 4 files changed, 17 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/768fa170/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
index 0c582a4..a899490 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/BrokerService.java
@@ -665,6 +665,19 @@ public class BrokerService implements Service {
         }
         getPersistenceAdapter().start();
 
+        getTempDataStore();
+        if (tempDataStore != null) {
+            try {
+                // start after we have the store lock
+                tempDataStore.start();
+            } catch (Exception e) {
+                RuntimeException exception = new RuntimeException(
+                        "Failed to start temp data store: " + tempDataStore, e);
+                LOG.error(exception.getLocalizedMessage(), e);
+                throw exception;
+            }
+        }
+
         getJobSchedulerStore();
         if (jobSchedulerStore != null) {
             try {
@@ -1717,32 +1730,11 @@ public class BrokerService implements Service {
                 throw new RuntimeException(e);
             }
 
-            boolean result = true;
-            boolean empty = true;
             try {
-                File directory = getTmpDataDirectory();
-                if (directory.exists() && directory.isDirectory()) {
-                    File[] files = directory.listFiles();
-                    if (files != null && files.length > 0) {
-                        empty = false;
-                        for (int i = 0; i < files.length; i++) {
-                            File file = files[i];
-                            if (!file.isDirectory()) {
-                                result &= file.delete();
-                            }
-                        }
-                    }
-                }
-                if (!empty) {
-                    String str = result ? "Successfully deleted" : "Failed to delete";
-                    LOG.info("{} temporary storage", str);
-                }
-
                 String clazz = "org.apache.activemq.store.kahadb.plist.PListStoreImpl";
                 this.tempDataStore = (PListStore) getClass().getClassLoader().loadClass(clazz).newInstance();
                 this.tempDataStore.setDirectory(getTmpDataDirectory());
                 configureService(tempDataStore);
-                this.tempDataStore.start();
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
@@ -1757,13 +1749,6 @@ public class BrokerService implements Service {
     public void setTempDataStore(PListStore tempDataStore) {
         this.tempDataStore = tempDataStore;
         configureService(tempDataStore);
-        try {
-            tempDataStore.start();
-        } catch (Exception e) {
-            RuntimeException exception = new RuntimeException("Failed to start provided temp
data store: " + tempDataStore, e);
-            LOG.error(exception.getLocalizedMessage(), e);
-            throw exception;
-        }
     }
 
     public int getPersistenceThreadPriority() {

http://git-wip-us.apache.org/repos/asf/activemq/blob/768fa170/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/plist/PListStoreImpl.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/plist/PListStoreImpl.java
b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/plist/PListStoreImpl.java
index 33012ba..8c2ece2 100644
--- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/plist/PListStoreImpl.java
+++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/plist/PListStoreImpl.java
@@ -276,6 +276,7 @@ public class PListStoreImpl extends ServiceSupport implements BrokerServiceAware
                     this.directory = new File(IOHelper.getDefaultDataDirectory() + File.pathSeparator
+ "delayedDB");
                 }
                 IOHelper.mkdirs(this.directory);
+                IOHelper.deleteChildren(this.directory);
                 lock();
                 this.journal = new Journal();
                 this.journal.setDirectory(directory);

http://git-wip-us.apache.org/repos/asf/activemq/blob/768fa170/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java
index ac341a2..57f3a86 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursorTestSupport.java
@@ -39,7 +39,7 @@ public class FilePendingMessageCursorTestSupport {
     @After
     public void stopBroker() throws Exception {
         if (brokerService != null) {
-            brokerService.getTempDataStore().stop();
+            brokerService.stop();
         }
     }
 
@@ -48,6 +48,7 @@ public class FilePendingMessageCursorTestSupport {
         brokerService.setUseJmx(false);
         SystemUsage usage = brokerService.getSystemUsage();
         usage.getTempUsage().setLimit(1025*1024*15);
+        brokerService.start();
 
         // put something in the temp store to on demand initialise it
         PList dud = brokerService.getTempDataStore().getPList("dud");

http://git-wip-us.apache.org/repos/asf/activemq/blob/768fa170/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/KahaDBFilePendingMessageCursorTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/KahaDBFilePendingMessageCursorTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/KahaDBFilePendingMessageCursorTest.java
index 5a3b318..ce4a8ed 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/KahaDBFilePendingMessageCursorTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/plist/KahaDBFilePendingMessageCursorTest.java
@@ -44,6 +44,7 @@ public class KahaDBFilePendingMessageCursorTest extends FilePendingMessageCursor
         String body = new String(new byte[1024]);
         Destination destination = new Queue(brokerService, new ActiveMQQueue("Q"), null,
new DestinationStatistics(), null);
 
+        brokerService.start();
         underTest = new FilePendingMessageCursor(brokerService.getBroker(), "test", false);
         underTest.setSystemUsage(usage);
 


Mime
View raw message