activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r1235261 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq: broker/ store/ store/jdbc/ store/journal/ store/memory/
Date Tue, 24 Jan 2012 14:22:59 GMT
Author: rajdavies
Date: Tue Jan 24 14:22:58 2012
New Revision: 1235261

URL: http://svn.apache.org/viewvc?rev=1235261&view=rev
Log:
Fix for https://issues.apache.org/jira/browse/AMQ-3573 -
changed defaults for SystemUsage to
50GB for temp usage, 100GB for store usage and 64mb for memory usage.
Added error and warning messages if the SysteMUsage limits cannot be met by the system

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/PersistenceAdapter.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapterFactory.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.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?rev=1235261&r1=1235260&r2=1235261&view=diff
==============================================================================
--- 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
Tue Jan 24 14:22:58 2012
@@ -499,6 +499,7 @@ public class BrokerService implements Se
             if (isUseJmx()) {
                 startManagementContext();
             }
+
             getPersistenceAdapter().setUsageManager(getProducerSystemUsage());
             getPersistenceAdapter().setBrokerName(getBrokerName());
             LOG.info("Using Persistence Adapter: " + getPersistenceAdapter());
@@ -546,6 +547,7 @@ public class BrokerService implements Se
             }
             LOG.info("ActiveMQ JMS Message Broker (" + getBrokerName() + ", " + brokerId
+ ") started");
             getBroker().brokerServiceStarted();
+            checkSystemUsageLimits();
             startedLatch.countDown();
         } catch (Exception e) {
             LOG.error("Failed to start ActiveMQ JMS Message Broker (" + getBrokerName() +
", " + brokerId + "). Reason: " + e, e);
@@ -918,9 +920,9 @@ public class BrokerService implements Se
                 systemUsage.getMemoryUsage().setLimit(1024 * 1024 * 64); // Default
                                                                          // 64
                                                                          // Meg
-                systemUsage.getTempUsage().setLimit(1024L * 1024 * 1024 * 100); // 10
+                systemUsage.getTempUsage().setLimit(1024L * 1024 * 1000 * 50); // 50
                                                                                 // Gb
-                systemUsage.getStoreUsage().setLimit(1024L * 1024 * 1024 * 100); // 100
+                systemUsage.getStoreUsage().setLimit(1024L * 1024 * 1000 * 100); // 100
                                                                                  // GB
                 addService(this.systemUsage);
             }
@@ -1671,6 +1673,37 @@ public class BrokerService implements Se
             }
         }
     }
+    
+    protected void checkSystemUsageLimits() throws IOException {
+        SystemUsage usage = getSystemUsage();
+        long memLimit = usage.getMemoryUsage().getLimit();
+        long jvmLimit = Runtime.getRuntime().maxMemory();
+        if (memLimit > jvmLimit){
+            LOG.error("Memory Usage for the Broker (" + memLimit/(1024*1024) + " mb) is more
than the maximum available for the JVM: " + jvmLimit/(1024*1024) + " mb" );
+        }
+        if (getPersistenceAdapter() != null){
+            File dir = getPersistenceAdapter().getDirectory();
+            if (dir != null){
+                long storeLimit = usage.getStoreUsage().getLimit();
+                long dirFreeSpace = dir.getFreeSpace();
+                if (storeLimit > dirFreeSpace){
+                    LOG.warn("Store limit is " + storeLimit/(1024*1024) + " mb, whilst the
data directory: " + dir.getAbsolutePath() + " only has " + dirFreeSpace/(1024*1024) + " mb
of free space");
+                }
+            }
+        }
+        File tmpDir = getTmpDataDirectory();
+        if (tmpDir != null){
+            String tmpDirPath = tmpDir.getAbsolutePath();
+            long storeLimit = usage.getTempUsage().getLimit();
+            while (tmpDir != null && tmpDir.isDirectory()== false){
+                tmpDir = tmpDir.getParentFile();
+            }
+            long dirFreeSpace = tmpDir.getUsableSpace();
+            if (storeLimit > dirFreeSpace){
+                LOG.error("Temporary Store limit is " + storeLimit/(1024*1024) + " mb, whilst
the temporary data directory: " + tmpDirPath + " only has " + dirFreeSpace/(1024*1024) + "
mb of free space");
+            }
+        }
+    }
 
     public void stopAllConnectors(ServiceStopper stopper) {
         for (Iterator<NetworkConnector> iter = getNetworkConnectors().iterator(); iter.hasNext();)
{

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/PersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/PersistenceAdapter.java?rev=1235261&r1=1235260&r2=1235261&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/PersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/PersistenceAdapter.java
Tue Jan 24 14:22:58 2012
@@ -22,7 +22,6 @@ import java.util.Set;
 
 import org.apache.activemq.Service;
 import org.apache.activemq.broker.ConnectionContext;
-import org.apache.activemq.broker.region.Destination;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.ActiveMQQueue;
 import org.apache.activemq.command.ActiveMQTopic;
@@ -144,6 +143,11 @@ public interface PersistenceAdapter exte
      * @param dir
      */
     void setDirectory(File dir);
+
+    /**
+     * @return the directory used by the persistence adaptor
+     */
+    File getDirectory();
     
     /**
      * checkpoint any

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java?rev=1235261&r1=1235260&r2=1235261&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java
Tue Jan 24 14:22:58 2012
@@ -92,6 +92,7 @@ public class JDBCPersistenceAdapter exte
     private boolean createTablesOnStartup = true;
     private DataSource lockDataSource;
     private int transactionIsolation;
+    private File directory;
     
     protected int maxProducersToAudit=1024;
     protected int maxAuditDepth=1000;
@@ -638,6 +639,14 @@ public class JDBCPersistenceAdapter exte
     }
 
     public void setDirectory(File dir) {
+        this.directory=dir;
+    }
+    
+    public File getDirectory(){
+        if (this.directory==null && brokerService != null){
+            this.directory=brokerService.getBrokerDataDirectory();
+        }
+        return this.directory;
     }
 
     // interesting bit here is proof that DB is ok

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java?rev=1235261&r1=1235260&r2=1235261&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java
Tue Jan 24 14:22:58 2012
@@ -115,6 +115,7 @@ public class JournalPersistenceAdapter i
     private final Runnable periodicCheckpointTask = createPeriodicCheckpointTask();
 
     private TaskRunnerFactory taskRunnerFactory;
+    private File directory;
 
     public JournalPersistenceAdapter() {        
     }
@@ -730,6 +731,11 @@ public class JournalPersistenceAdapter i
     }
 
     public void setDirectory(File dir) {
+        this.directory=dir;
+    }
+    
+    public File getDirectory(){
+        return directory;
     }
     
     public long size(){

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapterFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapterFactory.java?rev=1235261&r1=1235260&r2=1235261&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapterFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapterFactory.java
Tue Jan 24 14:22:58 2012
@@ -62,7 +62,9 @@ public class JournalPersistenceAdapterFa
         if (!useJournal) {
             return jdbcPersistenceAdapter;
         }
-        return new JournalPersistenceAdapter(getJournal(), jdbcPersistenceAdapter, getTaskRunnerFactory());
+        JournalPersistenceAdapter result =  new JournalPersistenceAdapter(getJournal(), jdbcPersistenceAdapter,
getTaskRunnerFactory());
+        result.setDirectory(getDataDirectoryFile());
+        return result;
 
     }
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java?rev=1235261&r1=1235260&r2=1235261&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java
Tue Jan 24 14:22:58 2012
@@ -189,6 +189,10 @@ public class MemoryPersistenceAdapter im
 
     public void setDirectory(File dir) {
     }
+    
+    public File getDirectory(){
+        return null;
+    }
 
     public void checkpoint(boolean sync) throws IOException {
     }



Mime
View raw message