Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 740C3200B8D for ; Thu, 8 Sep 2016 21:37:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 72FDB160AAD; Thu, 8 Sep 2016 19:37:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9BC6C160ABD for ; Thu, 8 Sep 2016 21:37:44 +0200 (CEST) Received: (qmail 52507 invoked by uid 500); 8 Sep 2016 19:37:43 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 52492 invoked by uid 99); 8 Sep 2016 19:37:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Sep 2016 19:37:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 92F79E0902; Thu, 8 Sep 2016 19:37:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cshannon@apache.org To: commits@activemq.apache.org Date: Thu, 08 Sep 2016 19:37:45 -0000 Message-Id: <83b6181466de44508fa6969b29fe3798@git.apache.org> In-Reply-To: <9d3302b2b5e04861b75e81f015b03fa4@git.apache.org> References: <9d3302b2b5e04861b75e81f015b03fa4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/3] activemq git commit: AMQ-6403 - add indexDirectory attribute to kahadb plist impl - settable via broker service tempDataStore archived-at: Thu, 08 Sep 2016 19:37:45 -0000 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 Authored: Wed Aug 24 11:39:22 2016 +0100 Committer: Christopher L. Shannon (cshannon) 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 Hiram Chirino @@ -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(); + } }