From 26091f1907dce5a1a9dd9f0d6a5ca976166a5c41 Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Fri, 26 Jun 2020 13:17:38 -0500 Subject: [PATCH] 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. --- .../artemis/cli/commands/check/NodeCheck.java | 2 +- .../management/ActiveMQServerControl.java | 6 ----- .../impl/ActiveMQServerControlImpl.java | 22 ------------------- .../ActiveMQServerControlUsingCoreTest.java | 10 --------- 4 files changed, 1 insertion(+), 39 deletions(-) diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/NodeCheck.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/NodeCheck.java index c201942beb..601d254016 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/NodeCheck.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/check/NodeCheck.java @@ -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 { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java index 292d112e0c..b8df6d7d72 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java @@ -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(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java index 0cd94fdf62..30aff028a6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java @@ -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()) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java index 9e3da08d89..2c32c25e48 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java @@ -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() {