From 466597e83bc33a4e6063453cc3d0e698417404bd Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Mon, 9 May 2022 13:29:16 -0500 Subject: [PATCH] ARTEMIS-3822 get broker name via management --- .../core/management/ActiveMQServerControl.java | 6 ++++++ .../impl/ActiveMQServerControlImpl.java | 15 +++++++++++++++ .../management/ActiveMQServerControlTest.java | 2 ++ .../ActiveMQServerControlUsingCoreTest.java | 5 +++++ 4 files changed, 28 insertions(+) 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 402545e024..c7c335f892 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 @@ -32,6 +32,12 @@ public interface ActiveMQServerControl { String ADDRESS_MEMORY_USAGE_PERCENTAGE_DESCRIPTION = "Memory used by all the addresses on broker as a percentage of the global-max-size"; String DISK_STORE_USAGE_DESCRIPTION = "Fraction of total disk store used"; + /** + * Returns this server's name. + */ + @Attribute(desc = "Server's name") + String getName(); + /** * Returns this server's version. */ 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 eaaa121698..5695cb1f65 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 @@ -204,6 +204,21 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } + @Override + public String getName() { + if (AuditLogger.isBaseLoggingEnabled()) { + AuditLogger.getName(this.server); + } + checkStarted(); + + clearIO(); + try { + return server.getConfiguration().getName(); + } finally { + blockOnIO(); + } + } + @Override public String getVersion() { if (AuditLogger.isBaseLoggingEnabled()) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java index e92270db41..6140d22eaf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java @@ -161,6 +161,8 @@ public class ActiveMQServerControlTest extends ManagementTestBase { public void testGetAttributes() throws Exception { ActiveMQServerControl serverControl = createManagementControl(); + Assert.assertEquals(server.getConfiguration().getName(), serverControl.getName()); + Assert.assertEquals(server.getVersion().getFullVersion(), serverControl.getVersion()); Assert.assertEquals(conf.isClustered(), serverControl.isClustered()); 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 e84fe107ba..0988b1d527 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 @@ -587,6 +587,11 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes return (Long) proxy.retrieveAttributeValue("transactionTimeoutScanPeriod", Long.class); } + @Override + public String getName() { + return (String) proxy.retrieveAttributeValue("name"); + } + @Override public String getVersion() { return proxy.retrieveAttributeValue("version").toString();