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

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1235261 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2012-01-24 14:22:58 +00:00
parent 1d52f3b53c
commit dbc661fd9b
6 changed files with 62 additions and 4 deletions

View File

@ -499,6 +499,7 @@ public class BrokerService implements Service {
if (isUseJmx()) {
startManagementContext();
}
getPersistenceAdapter().setUsageManager(getProducerSystemUsage());
getPersistenceAdapter().setBrokerName(getBrokerName());
LOG.info("Using Persistence Adapter: " + getPersistenceAdapter());
@ -546,6 +547,7 @@ public class BrokerService implements Service {
}
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 Service {
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);
}
@ -1672,6 +1674,37 @@ public class BrokerService implements Service {
}
}
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();) {
NetworkConnector connector = iter.next();

View File

@ -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;
@ -145,6 +144,11 @@ public interface PersistenceAdapter extends Service {
*/
void setDirectory(File dir);
/**
* @return the directory used by the persistence adaptor
*/
File getDirectory();
/**
* checkpoint any
* @param sync

View File

@ -92,6 +92,7 @@ public class JDBCPersistenceAdapter extends DataSourceSupport implements Persist
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 extends DataSourceSupport implements Persist
}
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

View File

@ -115,6 +115,7 @@ public class JournalPersistenceAdapter implements PersistenceAdapter, JournalEve
private final Runnable periodicCheckpointTask = createPeriodicCheckpointTask();
private TaskRunnerFactory taskRunnerFactory;
private File directory;
public JournalPersistenceAdapter() {
}
@ -730,6 +731,11 @@ public class JournalPersistenceAdapter implements PersistenceAdapter, JournalEve
}
public void setDirectory(File dir) {
this.directory=dir;
}
public File getDirectory(){
return directory;
}
public long size(){

View File

@ -62,7 +62,9 @@ public class JournalPersistenceAdapterFactory extends DataSourceSupport implemen
if (!useJournal) {
return jdbcPersistenceAdapter;
}
return new JournalPersistenceAdapter(getJournal(), jdbcPersistenceAdapter, getTaskRunnerFactory());
JournalPersistenceAdapter result = new JournalPersistenceAdapter(getJournal(), jdbcPersistenceAdapter, getTaskRunnerFactory());
result.setDirectory(getDataDirectoryFile());
return result;
}

View File

@ -190,6 +190,10 @@ public class MemoryPersistenceAdapter implements PersistenceAdapter {
public void setDirectory(File dir) {
}
public File getDirectory(){
return null;
}
public void checkpoint(boolean sync) throws IOException {
}