From bb94d0a5b30af0e492171f47e53325b6740c918b Mon Sep 17 00:00:00 2001 From: Andy Taylor Date: Mon, 22 Mar 2021 11:31:23 +0000 Subject: [PATCH] ARTEMIS-3196 - expose journal pool files in JMX https://issues.apache.org/jira/browse/ARTEMIS-3196 --- .../core/management/ActiveMQServerControl.java | 6 ++++++ .../impl/ActiveMQServerControlImpl.java | 15 +++++++++++++++ .../management/ActiveMQServerControlTest.java | 1 + .../ActiveMQServerControlUsingCoreTest.java | 5 +++++ 4 files changed, 27 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 7668b65734..e2211f3696 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 @@ -183,6 +183,12 @@ public interface ActiveMQServerControl { @Attribute(desc = "Size of the internal buffer on the journal") int getJournalBufferSize(); + /** + * Number of files that would be acceptable to keep on a pool + */ + @Attribute(desc = "Number of files that would be acceptable to keep on a pool") + int getJournalPoolFiles(); + /** * Returns the timeout (in nanoseconds) used to flush internal buffers on the journal. */ 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 67f9281b77..8c4f906d03 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 @@ -311,6 +311,21 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } } + @Override + public int getJournalPoolFiles() { + if (AuditLogger.isEnabled()) { + AuditLogger.getJournalBufferSize(this.server); + } + checkStarted(); + + clearIO(); + try { + return configuration.getJournalPoolFiles(); + } finally { + blockOnIO(); + } + } + @Override public int getJournalBufferSize() { if (AuditLogger.isEnabled()) { 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 1a887979ce..de80874428 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 @@ -197,6 +197,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase { Assert.assertEquals(conf.getJournalCompactMinFiles(), serverControl.getJournalCompactMinFiles()); Assert.assertEquals(conf.getJournalCompactPercentage(), serverControl.getJournalCompactPercentage()); Assert.assertEquals(conf.isPersistenceEnabled(), serverControl.isPersistenceEnabled()); + Assert.assertEquals(conf.getJournalPoolFiles(), serverControl.getJournalPoolFiles()); Assert.assertTrue(serverControl.isActive()); } 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 c7719550bb..3f0a884d11 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 @@ -747,6 +747,11 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes return (Integer) proxy.retrieveAttributeValue("JournalBufferSize", Integer.class); } + @Override + public int getJournalPoolFiles() { + return (Integer) proxy.retrieveAttributeValue("getJournalPoolFiles", Integer.class); + } + @Override public int getJournalBufferTimeout() { return (Integer) proxy.retrieveAttributeValue("JournalBufferTimeout", Integer.class);