activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r516439 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq: broker/BrokerService.java store/amq/AMQPersistenceAdapter.java
Date Fri, 09 Mar 2007 15:47:06 GMT
Author: jstrachan
Date: Fri Mar  9 07:47:05 2007
New Revision: 516439

URL: http://svn.apache.org/viewvc?view=rev&rev=516439
Log:
Use the broker name in the directory used for the AMQStore and temp-store area

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?view=diff&rev=516439&r1=516438&r2=516439
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
Fri Mar  9 07:47:05 2007
@@ -550,12 +550,17 @@
 
     public File getDataDirectory() {
         if (dataDirectory == null) {
-            dataDirectory = new File(new File(IOHelper.getDefaultDataDirectory()), getBrokerName()
-                    .replaceAll("[^a-zA-Z0-9\\.\\_\\-]", "_"));
+            dataDirectory = new File(IOHelper.getDefaultDataDirectory());
         }
         return dataDirectory;
     }
 
+    public File getBrokerDataDirectory() {
+        String brokerDir = getBrokerName().replaceAll("[^a-zA-Z0-9\\.\\_\\-]", "_");
+        return new File(getDataDirectory(), brokerDir);
+    }
+
+
     /**
      * Sets the directory in which the data files will be stored by default for
      * the JDBC and Journal persistence adaptors.
@@ -572,7 +577,7 @@
      */
     public File getTmpDataDirectory(){
         if (tmpDataDirectory == null) {
-            tmpDataDirectory = new File(getDataDirectory(), "tmp_storage");
+            tmpDataDirectory = new File(getBrokerDataDirectory(), "tmp_storage");
         }
         return tmpDataDirectory;
     }
@@ -1411,7 +1416,7 @@
 
     protected AMQPersistenceAdapterFactory createPersistenceFactory() {
         AMQPersistenceAdapterFactory factory = new AMQPersistenceAdapterFactory();
-        factory.setDataDirectory(getDataDirectory());
+        factory.setDataDirectory(getBrokerDataDirectory());
         factory.setTaskRunnerFactory(getPersistenceTaskRunnerFactory());
         factory.setBrokerName(getBrokerName());
         return factory;

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java?view=diff&rev=516439&r1=516438&r2=516439
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/amq/AMQPersistenceAdapter.java
Fri Mar  9 07:47:05 2007
@@ -25,6 +25,8 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.activeio.journal.Journal;
 import org.apache.activemq.broker.ConnectionContext;
+import org.apache.activemq.broker.BrokerServiceAware;
+import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTopic;
@@ -70,7 +72,7 @@
  * 
  * @version $Revision: 1.17 $
  */
-public class AMQPersistenceAdapter implements PersistenceAdapter,UsageListener{
+public class AMQPersistenceAdapter implements PersistenceAdapter, UsageListener, BrokerServiceAware
{
 
     private static final Log log=LogFactory.getLog(AMQPersistenceAdapter.class);
     private final ConcurrentHashMap<ActiveMQQueue,AMQMessageStore> queues=new ConcurrentHashMap<ActiveMQQueue,AMQMessageStore>();
@@ -94,6 +96,7 @@
     private boolean syncOnWrite;
     private String brokerName="";
     private File directory;
+    private BrokerService brokerService;
 
     public String getBrokerName(){
         return this.brokerName;
@@ -106,14 +109,29 @@
         }
     }
 
+    public BrokerService getBrokerService() {
+        return brokerService;
+    }
+
+    public void setBrokerService(BrokerService brokerService) {
+        this.brokerService = brokerService;
+    }
+
     public synchronized void start() throws Exception{
         if(!started.compareAndSet(false,true))
             return;
-        if(this.directory==null){
-            this.directory=new File(IOHelper.getDefaultDataDirectory(),brokerName);
+        if(this.directory==null) {
+            if (brokerService != null) {
+                this.directory = brokerService.getBrokerDataDirectory();
+            }
+            else {
+                this.directory=new File(IOHelper.getDefaultDataDirectory(),brokerName);
+                this.directory=new File(directory,"amqstore");
+            }
         }
-        this.directory=new File(directory,"amqstore");
+        log.info("AMQStore starting using directory: " + directory);
         this.directory.mkdirs();
+
         if(this.usageManager!=null){
             this.usageManager.addUsageListener(this);
         }
@@ -123,7 +141,7 @@
         if(referenceStoreAdapter==null){
             referenceStoreAdapter=createReferenceStoreAdapter();
         }
-        referenceStoreAdapter.setDirectory(new File(directory,"kaha-reference-store"));
+        referenceStoreAdapter.setDirectory(new File(directory,"kr-store"));
         referenceStoreAdapter.setBrokerName(getBrokerName());
         referenceStoreAdapter.setUsageManager(usageManager);
         if(taskRunnerFactory==null){



Mime
View raw message