ARTEMIS-2825 wrong calc for DiskStoreUsagePercentage

The calculation used by
ActiveMQServerControlImpl.getDiskStoreUsagePercentage() is incorrect. It
uses disk space info with global-max-size which is for address memory.
Also, the existing getDiskStoreUsage() method *already* returns a
percentage of total disk store usage so this method seems redundant.
This commit is contained in:
Justin Bertram 2020-06-26 13:17:38 -05:00 committed by Clebert Suconic
parent 74698f0bcf
commit 26091f1907
4 changed files with 1 additions and 39 deletions

View File

@ -191,7 +191,7 @@ public class NodeCheck extends CheckAbstract {
thresholdValue = diskUsage;
}
checkNodeUsage(context, "getDiskStoreUsagePercentage", thresholdValue);
checkNodeUsage(context, "getDiskStoreUsage", thresholdValue);
}
private void checkNodeMemoryUsage(final CheckContext context) throws Exception {

View File

@ -455,12 +455,6 @@ public interface ActiveMQServerControl {
@Attribute(desc = "Memory used by all the addresses on broker as a percentage of global maximum limit")
int getAddressMemoryUsagePercentage();
/**
* Returns the storage used by disk store
*/
@Attribute(desc = "Memory used by the disk store")
int getDiskStoreUsagePercentage();
// Operations ----------------------------------------------------
@Operation(desc = "Isolate the broker", impact = MBeanOperationInfo.ACTION)
boolean freezeReplication();

View File

@ -134,8 +134,6 @@ import org.apache.activemq.artemis.utils.SecurityFormatter;
import org.apache.activemq.artemis.utils.collections.TypedProperties;
import org.jboss.logging.Logger;
import static org.apache.activemq.artemis.core.server.files.FileStoreMonitor.calculateUsage;
public class ActiveMQServerControlImpl extends AbstractControl implements ActiveMQServerControl, NotificationEmitter, org.apache.activemq.artemis.core.server.management.NotificationListener {
// Constants -----------------------------------------------------
private static final Logger logger = Logger.getLogger(ActiveMQServerControlImpl.class);
@ -753,26 +751,6 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
return (int) result;
}
@Override
public int getDiskStoreUsagePercentage() {
if (AuditLogger.isEnabled()) {
AuditLogger.getDiskStoreUsagePercentage(this.server);
}
long globalMaxSize = getGlobalMaxSize();
// no max size set implies 0% used
if (globalMaxSize <= 0) {
return 0;
}
long diskUsed = getDiskStoreUsage();
if (diskUsed <= 0) {
return 0;
}
double result = 100 * calculateUsage(diskUsed, globalMaxSize);
return (int) result;
}
@Override
public boolean freezeReplication() {
if (AuditLogger.isEnabled()) {

View File

@ -773,16 +773,6 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
return 0;
}
@Override
public int getDiskStoreUsagePercentage() {
try {
return (Integer) proxy.invokeOperation(Integer.TYPE, "getDiskUseStorePercentage");
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
@Override
public boolean freezeReplication() {