You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2016/08/24 10:39:48 UTC
activemq git commit: AMQ-6403 - add indexDirectory attribute to
kahadb plist impl - settable via broker service tempDataStore
Repository: activemq
Updated Branches:
refs/heads/master 1030fb184 -> 5a874816b
AMQ-6403 - add indexDirectory attribute to kahadb plist impl - settable via broker service tempDataStore
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/5a874816
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/5a874816
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/5a874816
Branch: refs/heads/master
Commit: 5a874816b74a485822bcb60e1cf7fc550644d62a
Parents: 1030fb1
Author: gtully <ga...@gmail.com>
Authored: Wed Aug 24 11:39:22 2016 +0100
Committer: gtully <ga...@gmail.com>
Committed: Wed Aug 24 11:39:22 2016 +0100
----------------------------------------------------------------------
.../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/5a874816/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/5a874816/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/5a874816/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();
+ }
}