diff --git a/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java b/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java index 2ef5353591..27c63af775 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java @@ -107,14 +107,25 @@ public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener private Runnable periodicCleanupTask; private boolean deleteAllMessages; private boolean syncOnWrite; - private File directory = new File(IOHelper.getDefaultDataDirectory() + "/amq"); + private String brokerName; + private File directory; + + public AMQPersistenceAdapter() { + this("localhost"); + } + public AMQPersistenceAdapter(String brokerName) { + this.brokerName = brokerName; + this.directory=new File(IOHelper.getDefaultDataDirectory(),brokerName + "-amqstore"); + } public synchronized void start() throws Exception { if( !started.compareAndSet(false, true) ) return; - this.usageManager.addUsageListener(this); + if (this.usageManager!=null) { + this.usageManager.addUsageListener(this); + } if( asyncDataManager == null ) { asyncDataManager = createAsyncDataManager(); diff --git a/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/AMQStoreCursorDurableTest.java b/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/AMQStoreCursorDurableTest.java index 154ea0267d..0844a3aa7e 100644 --- a/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/AMQStoreCursorDurableTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/AMQStoreCursorDurableTest.java @@ -31,7 +31,7 @@ public class AMQStoreCursorDurableTest extends CursorDurableTest{ protected void configureBroker(BrokerService answer) throws Exception{ - AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter(); + AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter("localhost"); answer.setPersistenceAdapter(adaptor); answer.setDeleteAllMessagesOnStartup(true); answer.addConnector(bindAddress); diff --git a/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/AMQStoreQueueStoreTest.java b/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/AMQStoreQueueStoreTest.java index 2f20f55a80..a80b532641 100644 --- a/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/AMQStoreQueueStoreTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/broker/region/cursors/AMQStoreQueueStoreTest.java @@ -35,7 +35,7 @@ public class AMQStoreQueueStoreTest extends CursorQueueStoreTest{ protected void configureBroker(BrokerService answer) throws Exception{ - PersistenceAdapter adaptor = new AMQPersistenceAdapter(); + PersistenceAdapter adaptor = new AMQPersistenceAdapter("localhost"); answer.setPersistenceAdapter(adaptor); PolicyEntry policy = new PolicyEntry(); policy.setPendingQueuePolicy(new StorePendingQueueMessageStoragePolicy()); diff --git a/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java b/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java index 705ba7794f..9a2cec19be 100644 --- a/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreDurableTopicTest.java @@ -17,7 +17,6 @@ package org.apache.activemq.perf; import java.io.File; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.store.amq.AMQPersistenceAdapter; -import org.apache.activemq.store.quick.QuickPersistenceAdapter; /** * @version $Revision: 1.3 $ @@ -27,10 +26,10 @@ public class AMQStoreDurableTopicTest extends SimpleDurableTopicTest{ protected void configureBroker(BrokerService answer) throws Exception{ File dataFileDir=new File("target/test-amq-data/perfTest/amqdb"); - AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter(); + AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter("localhost"); adaptor.setDirectory(dataFileDir); answer.setPersistenceAdapter(adaptor); - answer.addConnector(bindAddress); answer.setDeleteAllMessagesOnStartup(true); + answer.addConnector(bindAddress); } } diff --git a/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreQueueTest.java b/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreQueueTest.java index 91ea16cf37..5129404ed3 100644 --- a/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreQueueTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/perf/AMQStoreQueueTest.java @@ -31,7 +31,7 @@ public class AMQStoreQueueTest extends SimpleQueueTest{ File dataFileDir = new File("target/test-amq-data/perfTest/amq"); - AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter(); + AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter("localhost"); adaptor.setDirectory(dataFileDir); answer.setPersistenceAdapter(adaptor);