From df81bfa567523f73005d30f5fc0bbd6157ad0234 Mon Sep 17 00:00:00 2001 From: Justin Bertram Date: Thu, 1 Dec 2022 13:21:40 -0600 Subject: [PATCH] ARTEMIS-4103 support journal-lock-acquisition-timeout in broker.xml --- .../core/deployers/impl/FileConfigurationParser.java | 2 ++ .../artemis/core/config/impl/ConfigurationImplTest.java | 5 +++++ .../core/config/impl/DefaultsFileConfigurationTest.java | 2 ++ .../artemis/core/config/impl/FileConfigurationTest.java | 1 + .../src/test/resources/ConfigurationTest-full-config.xml | 2 +- .../test/resources/ConfigurationTest-xinclude-config.xml | 2 +- docs/user-manual/en/persistence.md | 6 ++++++ 7 files changed, 18 insertions(+), 2 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java index efe2b10cbc..a3345d19dc 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java @@ -741,6 +741,8 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { config.setLogJournalWriteRate(getBoolean(e, "log-journal-write-rate", ActiveMQDefaultConfiguration.isDefaultJournalLogWriteRate())); + config.setJournalLockAcquisitionTimeout(getLong(e, "journal-lock-acquisition-timeout", config.getJournalLockAcquisitionTimeout(), Validators.MINUS_ONE_OR_GT_ZERO)); + if (e.hasAttribute("wild-card-routing-enabled")) { config.setWildcardRoutingEnabled(getBoolean(e, "wild-card-routing-enabled", config.isWildcardRoutingEnabled())); } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java index 0219017b35..aa5088452e 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java @@ -109,6 +109,7 @@ public class ConfigurationImplTest extends ActiveMQTestBase { Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultPagingDir(), conf.getPagingDirectory()); Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultLargeMessagesDir(), conf.getLargeMessagesDirectory()); Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalCompactPercentage(), conf.getJournalCompactPercentage()); + Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalLockAcquisitionTimeout(), conf.getJournalLockAcquisitionTimeout()); Assert.assertEquals(ArtemisConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO, conf.getJournalBufferTimeout_AIO()); Assert.assertEquals(ArtemisConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_NIO, conf.getJournalBufferTimeout_NIO()); Assert.assertEquals(ArtemisConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO, conf.getJournalBufferSize_AIO()); @@ -257,6 +258,10 @@ public class ConfigurationImplTest extends ActiveMQTestBase { conf.setJournalCompactPercentage(i); Assert.assertEquals(i, conf.getJournalCompactPercentage()); + l = RandomUtil.randomLong(); + conf.setJournalLockAcquisitionTimeout(l); + Assert.assertEquals(l, conf.getJournalLockAcquisitionTimeout()); + i = RandomUtil.randomInt(); conf.setJournalBufferSize_AIO(i); Assert.assertEquals(i, conf.getJournalBufferSize_AIO()); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DefaultsFileConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DefaultsFileConfigurationTest.java index dcd37314aa..c82b853154 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DefaultsFileConfigurationTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/DefaultsFileConfigurationTest.java @@ -96,6 +96,8 @@ public class DefaultsFileConfigurationTest extends ConfigurationImplTest { Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalCompactPercentage(), conf.getJournalCompactPercentage()); + Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalLockAcquisitionTimeout(), conf.getJournalLockAcquisitionTimeout()); + Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalMinFiles(), conf.getJournalMinFiles()); Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio(), conf.getJournalMaxIO_AIO()); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java index 67ed32c16f..ebe22e3010 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java @@ -172,6 +172,7 @@ public class FileConfigurationTest extends ConfigurationImplTest { Assert.assertEquals(100, conf.getJournalMinFiles()); Assert.assertEquals(123, conf.getJournalCompactMinFiles()); Assert.assertEquals(33, conf.getJournalCompactPercentage()); + Assert.assertEquals(7654, conf.getJournalLockAcquisitionTimeout()); Assert.assertEquals(true, conf.isGracefulShutdownEnabled()); Assert.assertEquals(12345, conf.getGracefulShutdownTimeout()); Assert.assertEquals(true, conf.isPopulateValidatedUser()); diff --git a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml index 409254647f..8fec6467f4 100644 --- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml +++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml @@ -30,7 +30,7 @@ 5423 333 444 - 123 + 7654 true Giraffe Whatever diff --git a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml index 4f242cb1d3..4715a4f49c 100644 --- a/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml +++ b/artemis-server/src/test/resources/ConfigurationTest-xinclude-config.xml @@ -31,7 +31,7 @@ 5423 333 444 - 123 + 7654 true Giraffe Whatever diff --git a/docs/user-manual/en/persistence.md b/docs/user-manual/en/persistence.md index d770ee1831..08ed36f59d 100644 --- a/docs/user-manual/en/persistence.md +++ b/docs/user-manual/en/persistence.md @@ -346,6 +346,12 @@ The message journal is configured using the following attributes in data files on the journal The default for this parameter is `30` + +- `journal-lock-acquisition-timeout` + + How long to wait (in milliseconds) to acquire a file lock on the journal before giving up + + The default for this parameter is `-1` (i.e. indefinite)) - `journal-datasync` (default: true)