You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2020/07/07 12:18:39 UTC
[activemq-artemis] 01/07: ARTEMIS-2825 wrong calc for
DiskStoreUsagePercentage
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 26091f1907dce5a1a9dd9f0d6a5ca976166a5c41
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Fri Jun 26 13:17:38 2020 -0500
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 +-
.../api/core/management/ActiveMQServerControl.java | 6 ------
.../management/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 c201942..601d254 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 292d112..b8df6d7 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 0cd94fd..30aff02 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);
@@ -754,26 +752,6 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
}
@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()) {
AuditLogger.freezeReplication(this.server);
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 9e3da08..2c32c25 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
@@ -774,16 +774,6 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
}
@Override
- public int getDiskStoreUsagePercentage() {
- try {
- return (Integer) proxy.invokeOperation(Integer.TYPE, "getDiskUseStorePercentage");
- } catch (Exception e) {
- e.printStackTrace();
- }
- return 0;
- }
-
- @Override
public boolean freezeReplication() {
return false;