ARTEMIS-2829 wrong return type for getDiskStoreUsage
Since getDiskStoreUsage on the ActiveMQServerControl is converting a double to a long the value is always 0 in the management API. It should return a double instead.
This commit is contained in:
parent
cb7cd729d7
commit
fd207e75b0
|
@ -445,10 +445,10 @@ public interface ActiveMQServerControl {
|
|||
long getAddressMemoryUsage();
|
||||
|
||||
/**
|
||||
* Returns the bytes used by the disk store
|
||||
* Returns the percentage of total disk store use
|
||||
*/
|
||||
@Attribute(desc = DISK_STORE_USAGE_DESCRIPTION)
|
||||
long getDiskStoreUsage();
|
||||
double getDiskStoreUsage();
|
||||
|
||||
/**
|
||||
* Returns the memory used by all the addresses on broker as a percentage of the global-max-size
|
||||
|
|
|
@ -109,7 +109,6 @@ import org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy;
|
|||
import org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy;
|
||||
import org.apache.activemq.artemis.core.server.files.FileStoreMonitor;
|
||||
import org.apache.activemq.artemis.core.server.group.GroupingHandler;
|
||||
import org.apache.activemq.artemis.core.server.impl.Activation;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
|
@ -711,22 +710,14 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getDiskStoreUsage() {
|
||||
public double getDiskStoreUsage() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDiskStoreUsage(this.server);
|
||||
}
|
||||
checkStarted();
|
||||
clearIO();
|
||||
try {
|
||||
//this should not happen but if it does, return -1 to highlight it is not working
|
||||
if (server.getPagingManager() == null) {
|
||||
return -1L;
|
||||
}
|
||||
|
||||
long usableSpace = server.getPagingManager().getDiskUsableSpace();
|
||||
long totalSpace = server.getPagingManager().getDiskTotalSpace();
|
||||
|
||||
return (long) FileStoreMonitor.calculateUsage(usableSpace, totalSpace);
|
||||
return server.getDiskStoreUsage();
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
|
|
|
@ -889,4 +889,6 @@ public interface ActiveMQServer extends ServiceComponent {
|
|||
void removeAddressInfo(SimpleString address, SecurityAuth auth, boolean force) throws Exception;
|
||||
|
||||
String getInternalNamingPrefix();
|
||||
|
||||
double getDiskStoreUsage();
|
||||
}
|
||||
|
|
|
@ -3086,16 +3086,19 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
builder.register(BrokerMetricNames.TOTAL_CONNECTION_COUNT, this, metrics -> Double.valueOf(getTotalConnectionCount()), ActiveMQServerControl.TOTAL_CONNECTION_COUNT_DESCRIPTION);
|
||||
builder.register(BrokerMetricNames.ADDRESS_MEMORY_USAGE, this, metrics -> Double.valueOf(messagingServerControl.getAddressMemoryUsage()), ActiveMQServerControl.ADDRESS_MEMORY_USAGE_DESCRIPTION);
|
||||
builder.register(BrokerMetricNames.ADDRESS_MEMORY_USAGE_PERCENTAGE, this, metrics -> Double.valueOf(messagingServerControl.getAddressMemoryUsagePercentage()), ActiveMQServerControl.ADDRESS_MEMORY_USAGE_PERCENTAGE_DESCRIPTION);
|
||||
builder.register(BrokerMetricNames.DISK_STORE_USAGE, this, metrics -> Double.valueOf(calculateDiskStoreUsage()), ActiveMQServerControl.DISK_STORE_USAGE_DESCRIPTION);
|
||||
builder.register(BrokerMetricNames.DISK_STORE_USAGE, this, metrics -> Double.valueOf(getDiskStoreUsage()), ActiveMQServerControl.DISK_STORE_USAGE_DESCRIPTION);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private double calculateDiskStoreUsage() {
|
||||
long usableSpace = getPagingManager().getDiskUsableSpace();
|
||||
long totalSpace = getPagingManager().getDiskTotalSpace();
|
||||
@Override
|
||||
public double getDiskStoreUsage() {
|
||||
//this should not happen but if it does, return -1 to highlight it is not working
|
||||
if (getPagingManager() == null) {
|
||||
return -1L;
|
||||
}
|
||||
|
||||
return FileStoreMonitor.calculateUsage(usableSpace, totalSpace);
|
||||
return FileStoreMonitor.calculateUsage(getPagingManager().getDiskUsableSpace(), getPagingManager().getDiskTotalSpace());
|
||||
}
|
||||
|
||||
private void unregisterMeters() {
|
||||
|
|
|
@ -764,9 +764,9 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getDiskStoreUsage() {
|
||||
public double getDiskStoreUsage() {
|
||||
try {
|
||||
return (Long) proxy.invokeOperation("getDiskStoreUsage");
|
||||
return (Double) proxy.invokeOperation("getDiskStoreUsage");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue