This closes #1878
This commit is contained in:
commit
e5ef7d37ae
|
@ -76,6 +76,16 @@ public final class Validators {
|
|||
}
|
||||
};
|
||||
|
||||
public static final Validator PERCENTAGE_OR_MINUS_ONE = new Validator() {
|
||||
@Override
|
||||
public void validate(final String name, final Object value) {
|
||||
Number val = (Number) value;
|
||||
if (val == null || ((val.intValue() < 0 || val.intValue() > 100) && val.intValue() != -1)) {
|
||||
throw ActiveMQMessageBundle.BUNDLE.notPercentOrMinusOne(name, val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final Validator GE_ZERO = new Validator() {
|
||||
@Override
|
||||
public void validate(final String name, final Object value) {
|
||||
|
|
|
@ -360,7 +360,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
|
|||
config.setGlobalMaxSize(globalMaxSize);
|
||||
}
|
||||
|
||||
config.setMaxDiskUsage(getInteger(e, MAX_DISK_USAGE, config.getMaxDiskUsage(), Validators.PERCENTAGE));
|
||||
config.setMaxDiskUsage(getInteger(e, MAX_DISK_USAGE, config.getMaxDiskUsage(), Validators.PERCENTAGE_OR_MINUS_ONE));
|
||||
|
||||
config.setDiskScanPeriod(getInteger(e, DISK_SCAN_PERIOD, config.getDiskScanPeriod(), Validators.MINUS_ONE_OR_GT_ZERO));
|
||||
|
||||
|
|
|
@ -436,4 +436,6 @@ public interface ActiveMQMessageBundle {
|
|||
@Message(id = 119213, value = "User: {0} does not have permission=''{1}'' for queue {2} on address {3}", format = Message.Format.MESSAGE_FORMAT)
|
||||
ActiveMQSecurityException userNoPermissionsQueue(String username, CheckType checkType, String squeue, String saddress);
|
||||
|
||||
@Message(id = 119214, value = "{0} must be a valid percentage value between 0 and 100 or -1 (actual value: {1})", format = Message.Format.MESSAGE_FORMAT)
|
||||
IllegalArgumentException notPercentOrMinusOne(String name, Number val);
|
||||
}
|
||||
|
|
|
@ -137,7 +137,15 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent {
|
|||
}
|
||||
|
||||
protected double calculateUsage(FileStore store) throws IOException {
|
||||
return 1.0 - (double) store.getUsableSpace() / (double) store.getTotalSpace();
|
||||
return 1.0 - (double) store.getUsableSpace() / getTotalSpace(store);
|
||||
}
|
||||
|
||||
private double getTotalSpace(FileStore store) throws IOException {
|
||||
double totalSpace = (double) store.getTotalSpace();
|
||||
if (totalSpace < 0) {
|
||||
totalSpace = Long.MAX_VALUE;
|
||||
}
|
||||
return totalSpace;
|
||||
}
|
||||
|
||||
public interface Callback {
|
||||
|
|
|
@ -2403,10 +2403,12 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
postOffice.startExpiryScanner();
|
||||
}
|
||||
|
||||
try {
|
||||
injectMonitor(new FileStoreMonitor(getScheduledPool(), executorFactory.getExecutor(), configuration.getDiskScanPeriod(), TimeUnit.MILLISECONDS, configuration.getMaxDiskUsage() / 100f, shutdownOnCriticalIO));
|
||||
} catch (Exception e) {
|
||||
ActiveMQServerLogger.LOGGER.unableToInjectMonitor(e);
|
||||
if (configuration.getMaxDiskUsage() != -1) {
|
||||
try {
|
||||
injectMonitor(new FileStoreMonitor(getScheduledPool(), executorFactory.getExecutor(), configuration.getDiskScanPeriod(), TimeUnit.MILLISECONDS, configuration.getMaxDiskUsage() / 100f, shutdownOnCriticalIO));
|
||||
} catch (Exception e) {
|
||||
ActiveMQServerLogger.LOGGER.unableToInjectMonitor(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,16 @@ public class ValidatorsTest extends Assert {
|
|||
ValidatorsTest.failure(Validators.PERCENTAGE, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPERCENTAGE_OR_MINUS_ONE() {
|
||||
ValidatorsTest.success(Validators.PERCENTAGE_OR_MINUS_ONE, 99);
|
||||
ValidatorsTest.success(Validators.PERCENTAGE_OR_MINUS_ONE, 100);
|
||||
ValidatorsTest.success(Validators.PERCENTAGE_OR_MINUS_ONE, 0);
|
||||
ValidatorsTest.success(Validators.PERCENTAGE_OR_MINUS_ONE, -1);
|
||||
ValidatorsTest.failure(Validators.PERCENTAGE_OR_MINUS_ONE, 101);
|
||||
ValidatorsTest.failure(Validators.PERCENTAGE_OR_MINUS_ONE, null);
|
||||
}
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
|
|
@ -86,7 +86,7 @@ Name | Description
|
|||
[management-notification-address](management.md "Configuring The Core Management Notification Address") | the name of the address that consumers bind to receive management notifications. Default=activemq.notifications
|
||||
[mask-password](masking-passwords.md "Masking Passwords") | This option controls whether passwords in server configuration need be masked. If set to "true" the passwords are masked. Default=false
|
||||
[max-saved-replicated-journals-size](ha.md#data-replication) | This specifies how many times a replicated backup server can restart after moving its files on start. Once there are this number of backup journal files the server will stop permanently after if fails back. -1 Means no Limit, 0 don't keep a copy at all, Default=2
|
||||
[max-disk-usage](paging.md#max-disk-usage) | The max percentage of data we should use from disks. The System will block while the disk is full. Default=100
|
||||
[max-disk-usage](paging.md#max-disk-usage) | The max percentage of data we should use from disks. The System will block while the disk is full. Disable by setting -1. Default=100
|
||||
[memory-measure-interval](perf-tuning.md) | frequency to sample JVM memory in ms (or -1 to disable memory sampling). Default=-1
|
||||
[memory-warning-threshold](perf-tuning.md) | Percentage of available memory which will trigger a warning log. Default=25
|
||||
[message-counter-enabled](management.md "Configuring Message Counters") | true means that message counters are enabled. Default=false
|
||||
|
|
Loading…
Reference in New Issue