activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject [3/3] activemq git commit: AMQ-6403 - add indexDirectory attribute to kahadb plist impl - settable via broker service tempDataStore
Date Thu, 08 Sep 2016 19:37:45 GMT
AMQ-6403 - add indexDirectory attribute to kahadb plist impl - settable via broker service
tempDataStore

(cherry picked from commit 5a874816b74a485822bcb60e1cf7fc550644d62a)


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

Branch: refs/heads/activemq-5.14.x
Commit: f0d898cc9d7cbeea19ee54334e504ac52ef854cc
Parents: 1d1c926
Author: gtully <gary.tully@gmail.com>
Authored: Wed Aug 24 11:39:22 2016 +0100
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Thu Sep 8 15:36:44 2016 -0400

----------------------------------------------------------------------
 .../apache/activemq/store/PListTestSupport.java |  2 +-
 .../store/kahadb/plist/PListStoreImpl.java      | 18 +++++++++++++-
 .../store/kahadb/plist/PListImplTest.java       | 25 ++++++++++++++++++++
 3 files changed, 43 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/f0d898cc/activemq-broker/src/test/java/org/apache/activemq/store/PListTestSupport.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/test/java/org/apache/activemq/store/PListTestSupport.java
b/activemq-broker/src/test/java/org/apache/activemq/store/PListTestSupport.java
index fad72f3..fb265b0 100644
--- a/activemq-broker/src/test/java/org/apache/activemq/store/PListTestSupport.java
+++ b/activemq-broker/src/test/java/org/apache/activemq/store/PListTestSupport.java
@@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory;
 
 public abstract class PListTestSupport {
     static final Logger LOG = LoggerFactory.getLogger(PListTestSupport.class);
-    private PListStore store;
+    protected PListStore store;
     private PList plist;
     final ByteSequence payload = new ByteSequence(new byte[400]);
     final String idSeed = new String("Seed" + new byte[1024]);

http://git-wip-us.apache.org/repos/asf/activemq/blob/f0d898cc/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 8c2ece2..e39c313 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
@@ -54,6 +54,7 @@ public class PListStoreImpl extends ServiceSupport implements BrokerServiceAware
     static final int OPEN_STATE = 2;
 
     private File directory;
+    private File indexDirectory;
     PageFile pageFile;
     private Journal journal;
     private LockFile lockFile;
@@ -202,6 +203,14 @@ public class PListStoreImpl extends ServiceSupport implements BrokerServiceAware
         this.directory = directory;
     }
 
+    public File getIndexDirectory() {
+        return indexDirectory != null ? indexDirectory : directory;
+    }
+
+    public void setIndexDirectory(File indexDirectory) {
+        this.indexDirectory = indexDirectory;
+    }
+
     public long size() {
         synchronized (this) {
             if (!initialized) {
@@ -277,13 +286,17 @@ public class PListStoreImpl extends ServiceSupport implements BrokerServiceAware
                 }
                 IOHelper.mkdirs(this.directory);
                 IOHelper.deleteChildren(this.directory);
+                if (this.indexDirectory != null) {
+                    IOHelper.mkdirs(this.indexDirectory);
+                    IOHelper.deleteChildren(this.indexDirectory);
+                }
                 lock();
                 this.journal = new Journal();
                 this.journal.setDirectory(directory);
                 this.journal.setMaxFileLength(getJournalMaxFileLength());
                 this.journal.setWriteBatchSize(getJournalMaxWriteBatchSize());
                 this.journal.start();
-                this.pageFile = new PageFile(directory, "tmpDB");
+                this.pageFile = new PageFile(getIndexDirectory(), "tmpDB");
                 this.pageFile.setEnablePageCaching(getIndexEnablePageCaching());
                 this.pageFile.setPageSize(getIndexPageSize());
                 this.pageFile.setWriteBatchSize(getIndexWriteBatchSize());
@@ -485,6 +498,9 @@ public class PListStoreImpl extends ServiceSupport implements BrokerServiceAware
     @Override
     public String toString() {
         String path = getDirectory() != null ? getDirectory().getAbsolutePath() : "DIRECTORY_NOT_SET";
+        if (indexDirectory != null) {
+            path += "|" + indexDirectory.getAbsolutePath();
+        }
         return "PListStore:[" + path + "]";
     }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/f0d898cc/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/plist/PListImplTest.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/plist/PListImplTest.java
b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/plist/PListImplTest.java
index 59e1a32..eaf4287 100644
--- a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/plist/PListImplTest.java
+++ b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/plist/PListImplTest.java
@@ -18,6 +18,12 @@ package org.apache.activemq.store.kahadb.plist;
 
 import org.apache.activemq.store.PListStore;
 import org.apache.activemq.store.PListTestSupport;
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
@@ -65,4 +71,23 @@ public class PListImplTest extends PListTestSupport {
         store.setIndexPageSize(2*1024);
         return store;
     }
+
+    @Test
+    public void testIndexDir() throws Exception {
+        PListStoreImpl pListStore = (PListStoreImpl)store;
+        assertEquals(pListStore.getDirectory(), pListStore.getIndexDirectory());
+    }
+
+    @Test
+    public void testSetIndexDir() throws Exception {
+        PListStoreImpl pListStore = (PListStoreImpl)store;
+        final File directory = pListStore.getDirectory();
+        pListStore.stop();
+        pListStore = createPListStore();
+        pListStore.setLazyInit(false);
+        pListStore.setIndexDirectory(new File(directory, "indexDir"));
+        pListStore.start();
+        assertNotEquals(pListStore.getDirectory(), pListStore.getIndexDirectory());
+        pListStore.stop();
+    }
 }


Mime
View raw message