}
}
}
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) {
PersistenceAdapter adapter = getPersistenceAdapter();
File dir = adapter.getDirectory();
if (dir != null) {
String dirPath = dir.getAbsolutePath();
if (!dir.isAbsolute()) {
dir = new File(dirPath);
}
while (dir != null && dir.isDirectory() == false) {
dir = dir.getParentFile();
}
long storeLimit = usage.getStoreUsage().getLimit();
long dirFreeSpace = dir.getUsableSpace();
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 usable space");
}
}
long maxJournalFileSize = 0;
long storeLimit = usage.getStoreUsage().getLimit();
if (adapter instanceof KahaDBPersistenceAdapter) {
KahaDBPersistenceAdapter kahaDB = (KahaDBPersistenceAdapter) adapter;
maxJournalFileSize = kahaDB.getJournalMaxFileLength();
} else if (adapter instanceof AMQPersistenceAdapter) {
AMQPersistenceAdapter amqAdapter = (AMQPersistenceAdapter) adapter;
maxJournalFileSize = amqAdapter.getMaxFileLength();
}
if (storeLimit < maxJournalFileSize) {
LOG.error("Store limit is " + storeLimit / (1024 * 1024) +
" mb, whilst the max journal file size for the store is: " +
maxJournalFileSize / (1024 * 1024) + " mb, " +
"the store will not accept any data when used.");
}
}
File tmpDir = getTmpDataDirectory();
if (tmpDir != null) {
String tmpDirPath = tmpDir.getAbsolutePath();
if (!tmpDir.isAbsolute()) {
tmpDir = new File(tmpDirPath);
}
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 usable space");
}
long maxJournalFileSize;
if (usage.getTempUsage().getStore() != null) {
maxJournalFileSize = usage.getTempUsage().getStore().getJournalMaxFileLength();
} else {
maxJournalFileSize = org.apache.kahadb.journal.Journal.DEFAULT_MAX_FILE_LENGTH;
}
if (storeLimit < maxJournalFileSize) {