activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbert...@apache.org
Subject [activemq-artemis] branch master updated: ARTEMIS-2878 Add numberOfPages as metric
Date Wed, 16 Sep 2020 14:17:12 GMT
This is an automated email from the ASF dual-hosted git repository.

jbertram pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 100d070  ARTEMIS-2878 Add numberOfPages as metric
     new 29ccc1f  This closes #3241
100d070 is described below

commit 100d0709427513c040c635c68bc8a22b5e5c8a9b
Author: Bernd Gutjahr <bernd.gutjahr@microfocus.com>
AuthorDate: Thu Aug 13 08:30:50 2020 +0200

    ARTEMIS-2878 Add numberOfPages as metric
    
    Added metric 'number.of.pages' to provide numberOfPages for an address.
---
 .../apache/activemq/artemis/api/core/management/AddressControl.java  | 5 +++--
 .../activemq/artemis/core/management/impl/AddressControlImpl.java    | 5 ++++-
 .../artemis/core/server/management/impl/ManagementServiceImpl.java   | 1 +
 .../activemq/artemis/core/server/metrics/AddressMetricNames.java     | 1 +
 .../tests/integration/management/AddressControlUsingCoreTest.java    | 2 +-
 .../activemq/artemis/tests/integration/plugin/MetricsPluginTest.java | 4 +++-
 6 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressControl.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressControl.java
index 719a877..ac32efe 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressControl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/AddressControl.java
@@ -26,6 +26,7 @@ public interface AddressControl {
    String ROUTED_MESSAGE_COUNT_DESCRIPTION = "number of messages routed to one or more bindings";
    String UNROUTED_MESSAGE_COUNT_DESCRIPTION = "number of messages not routed to any bindings";
    String ADDRESS_SIZE_DESCRIPTION = "the number of estimated bytes being used by all the
queue(s) bound to this address; used to control paging and blocking";
+   String NUMBER_OF_PAGES_DESCRIPTION = "number of pages used by this address";
 
    /**
     * Returns the managed address.
@@ -93,8 +94,8 @@ public interface AddressControl {
    /**
     * Returns the number of pages used by this address.
     */
-   @Attribute(desc = "number of pages used by this address")
-   int getNumberOfPages() throws Exception;
+   @Attribute(desc = NUMBER_OF_PAGES_DESCRIPTION)
+   int getNumberOfPages();
 
    /**
     * Returns whether this address is paging.
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
index 166c01e..955748a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/AddressControlImpl.java
@@ -324,7 +324,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
    }
 
    @Override
-   public int getNumberOfPages() throws Exception {
+   public int getNumberOfPages() {
       if (AuditLogger.isEnabled()) {
          AuditLogger.getNumberOfPages(this.addressInfo);
       }
@@ -337,6 +337,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
          } else {
             return pageStore.getNumberOfPages();
          }
+      } catch (Exception e) {
+         ActiveMQServerLogger.LOGGER.debug("Failed to get number of pages", e);
+         return -1;
       } finally {
          blockOnIO();
       }
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
index 8af940b..f6664f4 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
@@ -270,6 +270,7 @@ public class ManagementServiceImpl implements ManagementService {
                builder.register(AddressMetricNames.ROUTED_MESSAGE_COUNT, this, metrics ->
Double.valueOf(addressInfo.getRoutedMessageCount()), AddressControl.ROUTED_MESSAGE_COUNT_DESCRIPTION);
                builder.register(AddressMetricNames.UNROUTED_MESSAGE_COUNT, this, metrics
-> Double.valueOf(addressInfo.getUnRoutedMessageCount()), AddressControl.UNROUTED_MESSAGE_COUNT_DESCRIPTION);
                builder.register(AddressMetricNames.ADDRESS_SIZE, this, metrics -> Double.valueOf(addressControl.getAddressSize()),
AddressControl.ADDRESS_SIZE_DESCRIPTION);
+               builder.register(AddressMetricNames.PAGES_COUNT, this, metrics -> Double.valueOf(addressControl.getNumberOfPages()),
AddressControl.NUMBER_OF_PAGES_DESCRIPTION);
             });
          }
       }
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/AddressMetricNames.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/AddressMetricNames.java
index 64522c4..a1fc3ec 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/AddressMetricNames.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/AddressMetricNames.java
@@ -22,5 +22,6 @@ public class AddressMetricNames {
    public static final String ROUTED_MESSAGE_COUNT = "routed.message.count";
    public static final String UNROUTED_MESSAGE_COUNT = "unrouted.message.count";
    public static final String ADDRESS_SIZE = "address.size";
+   public static final String PAGES_COUNT = "number.of.pages";
 
 }
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java
index 25f3f31..6afbc4b 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/AddressControlUsingCoreTest.java
@@ -89,7 +89,7 @@ public class AddressControlUsingCoreTest extends AddressControlTest {
          }
 
          @Override
-         public int getNumberOfPages() throws Exception {
+         public int getNumberOfPages() {
             return (int) proxy.retrieveAttributeValue("numberOfPages", Integer.class);
          }
 
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MetricsPluginTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MetricsPluginTest.java
index 5d30b00..b80b7a2 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MetricsPluginTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/plugin/MetricsPluginTest.java
@@ -167,7 +167,9 @@ public class MetricsPluginTest extends ActiveMQTestBase {
               new Metric("artemis.unrouted.message.count", "number of messages not routed
to any bindings", 0.0),
               new Metric("artemis.unrouted.message.count", "number of messages not routed
to any bindings", 2.0),
               new Metric("artemis.address.size", "the number of estimated bytes being used
by all the queue(s) bound to this address; used to control paging and blocking", 0.0),
-              new Metric("artemis.address.size", "the number of estimated bytes being used
by all the queue(s) bound to this address; used to control paging and blocking", 0.0)
+              new Metric("artemis.address.size", "the number of estimated bytes being used
by all the queue(s) bound to this address; used to control paging and blocking", 0.0),
+              new Metric("artemis.number.of.pages", "number of pages used by this address",
0.0),
+              new Metric("artemis.number.of.pages", "number of pages used by this address",
0.0)
       ));
    }
 


Mime
View raw message