ARTEMIS-2878 Add numberOfPages as metric

Added metric 'number.of.pages' to provide numberOfPages for an address.
This commit is contained in:
Bernd Gutjahr 2020-08-13 08:30:50 +02:00 committed by Justin Bertram
parent b71bfccde2
commit 100d070942
6 changed files with 13 additions and 5 deletions

View File

@ -26,6 +26,7 @@ public interface AddressControl {
String ROUTED_MESSAGE_COUNT_DESCRIPTION = "number of messages routed to one or more bindings"; 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 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 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. * Returns the managed address.
@ -93,8 +94,8 @@ public interface AddressControl {
/** /**
* Returns the number of pages used by this address. * Returns the number of pages used by this address.
*/ */
@Attribute(desc = "number of pages used by this address") @Attribute(desc = NUMBER_OF_PAGES_DESCRIPTION)
int getNumberOfPages() throws Exception; int getNumberOfPages();
/** /**
* Returns whether this address is paging. * Returns whether this address is paging.

View File

@ -324,7 +324,7 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
} }
@Override @Override
public int getNumberOfPages() throws Exception { public int getNumberOfPages() {
if (AuditLogger.isEnabled()) { if (AuditLogger.isEnabled()) {
AuditLogger.getNumberOfPages(this.addressInfo); AuditLogger.getNumberOfPages(this.addressInfo);
} }
@ -337,6 +337,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
} else { } else {
return pageStore.getNumberOfPages(); return pageStore.getNumberOfPages();
} }
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.debug("Failed to get number of pages", e);
return -1;
} finally { } finally {
blockOnIO(); blockOnIO();
} }

View File

@ -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.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.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.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);
}); });
} }
} }

View File

@ -22,5 +22,6 @@ public class AddressMetricNames {
public static final String ROUTED_MESSAGE_COUNT = "routed.message.count"; public static final String ROUTED_MESSAGE_COUNT = "routed.message.count";
public static final String UNROUTED_MESSAGE_COUNT = "unrouted.message.count"; public static final String UNROUTED_MESSAGE_COUNT = "unrouted.message.count";
public static final String ADDRESS_SIZE = "address.size"; public static final String ADDRESS_SIZE = "address.size";
public static final String PAGES_COUNT = "number.of.pages";
} }

View File

@ -89,7 +89,7 @@ public class AddressControlUsingCoreTest extends AddressControlTest {
} }
@Override @Override
public int getNumberOfPages() throws Exception { public int getNumberOfPages() {
return (int) proxy.retrieveAttributeValue("numberOfPages", Integer.class); return (int) proxy.retrieveAttributeValue("numberOfPages", Integer.class);
} }

View File

@ -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", 0.0),
new Metric("artemis.unrouted.message.count", "number of messages not routed to any bindings", 2.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.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)
)); ));
} }