activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1187280 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/store/kahadb/ test/java/org/apache/activemq/store/
Date Fri, 21 Oct 2011 10:15:26 GMT
Author: gtully
Date: Fri Oct 21 10:15:26 2011
New Revision: 1187280

URL: http://svn.apache.org/viewvc?rev=1187280&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3533 - mKahaDB, allow the directory of a filtered
destination to be specified, such that destination journals can be split across disks. Fixed
with test

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/StorePerDestinationTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java?rev=1187280&r1=1187279&r2=1187280&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
Fri Oct 21 10:15:26 2011
@@ -100,7 +100,7 @@ public abstract class MessageDatabase ex
 
     public static final String PROPERTY_LOG_SLOW_ACCESS_TIME = "org.apache.activemq.store.kahadb.LOG_SLOW_ACCESS_TIME";
     public static final int LOG_SLOW_ACCESS_TIME = Integer.parseInt(System.getProperty(PROPERTY_LOG_SLOW_ACCESS_TIME,
"0"));
-
+    public static final File DEFAULT_DIRECTORY = new File("KahaDB");
     protected static final Buffer UNMATCHED;
     static {
         UNMATCHED = new Buffer(new byte[]{});
@@ -202,7 +202,7 @@ public abstract class MessageDatabase ex
     protected boolean failIfDatabaseIsLocked;
 
     protected boolean deleteAllMessages;
-    protected File directory = new File("KahaDB");
+    protected File directory = DEFAULT_DIRECTORY;
     protected Thread checkpointThread;
     protected boolean enableJournalDiskSyncs=true;
     protected boolean archiveDataLogs;

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java?rev=1187280&r1=1187279&r2=1187280&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/MultiKahaDBPersistenceAdapter.java
Fri Oct 21 10:15:26 2011
@@ -103,7 +103,9 @@ public class MultiKahaDBPersistenceAdapt
             if (filteredAdapter.getDestination() == null) {
                 filteredAdapter.setDestination(matchAll);
             }
-            adapter.setDirectory(new File(getDirectory(), nameFromDestinationFilter(filteredAdapter.getDestination())));
+            if (MessageDatabase.DEFAULT_DIRECTORY.equals(adapter.getDirectory())) {
+                adapter.setDirectory(new File(getDirectory(), nameFromDestinationFilter(filteredAdapter.getDestination())));
+            }
 
             // need a per store factory that will put the store in the branch qualifier to
disiambiguate xid mbeans
             adapter.getStore().setTransactionIdTransformer(transactionIdTransformer);

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/StorePerDestinationTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/StorePerDestinationTest.java?rev=1187280&r1=1187279&r2=1187280&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/StorePerDestinationTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/StorePerDestinationTest.java
Fri Oct 21 10:15:26 2011
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.store;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Vector;
@@ -176,6 +177,32 @@ public class StorePerDestinationTest  {
     }
 
     @Test
+    public void testDirectoryDefault() throws Exception {
+        MultiKahaDBPersistenceAdapter multiKahaDBPersistenceAdapter = new MultiKahaDBPersistenceAdapter();
+        ArrayList<FilteredKahaDBPersistenceAdapter> adapters = new ArrayList<FilteredKahaDBPersistenceAdapter>();
+
+        FilteredKahaDBPersistenceAdapter otherFilteredKahaDBPersistenceAdapter =
+                new FilteredKahaDBPersistenceAdapter();
+        KahaDBPersistenceAdapter otherStore = createStore(false);
+        File someOtherDisk = new File("target" + File.separator + "someOtherDisk");
+        otherStore.setDirectory(someOtherDisk);
+        otherFilteredKahaDBPersistenceAdapter.setPersistenceAdapter(otherStore);
+        otherFilteredKahaDBPersistenceAdapter.setDestination(new ActiveMQQueue("Other"));
+        adapters.add(otherFilteredKahaDBPersistenceAdapter);
+
+        FilteredKahaDBPersistenceAdapter filteredKahaDBPersistenceAdapterDefault =
+                new FilteredKahaDBPersistenceAdapter();
+        KahaDBPersistenceAdapter storeDefault = createStore(false);
+        filteredKahaDBPersistenceAdapterDefault.setPersistenceAdapter(storeDefault);
+        adapters.add(filteredKahaDBPersistenceAdapterDefault);
+
+        multiKahaDBPersistenceAdapter.setFilteredPersistenceAdapters(adapters);
+
+        assertEquals(multiKahaDBPersistenceAdapter.getDirectory(), storeDefault.getDirectory().getParentFile());
+        assertEquals(someOtherDisk, otherStore.getDirectory());
+    }
+
+    @Test
     public void testSlowFastDestinationsStoreUsage() throws Exception {
         brokerService.start();
         ExecutorService executorService = Executors.newCachedThreadPool();



Mime
View raw message