diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java index 92cbf031da..cce039ec11 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java @@ -17,7 +17,6 @@ package org.apache.activemq.artemis.core.paging.impl; import java.nio.file.FileStore; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Queue; @@ -180,13 +179,7 @@ public final class PagingManagerImpl implements PagingManager { memoryReleased(); } } - Iterator storeIterator = blockedStored.iterator(); - while (storeIterator.hasNext()) { - PagingStore store = storeIterator.next(); - if (store.checkReleasedMemory()) { - storeIterator.remove(); - } - } + blockedStored.removeIf(PagingStore::checkReleasedMemory); } } @@ -213,9 +206,12 @@ public final class PagingManagerImpl implements PagingManager { @Override public void under(FileStore store, double usage) { + final boolean diskFull = PagingManagerImpl.this.diskFull; if (diskFull || !blockedStored.isEmpty() || !memoryCallback.isEmpty()) { - ActiveMQServerLogger.LOGGER.diskCapacityRestored(); - diskFull = false; + if (diskFull) { + ActiveMQServerLogger.LOGGER.diskCapacityRestored(); + PagingManagerImpl.this.diskFull = false; + } checkMemoryRelease(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java index af474f070b..9ed1419332 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java @@ -1337,7 +1337,7 @@ public interface ActiveMQServerLogger extends BasicLogger { format = Message.Format.MESSAGE_FORMAT) void diskBeyondCapacity(); - @LogMessage(level = Logger.Level.WARN) + @LogMessage(level = Logger.Level.INFO) @Message(id = 222211, value = "Storage is back to stable now, under max-disk-usage.", format = Message.Format.MESSAGE_FORMAT) void diskCapacityRestored(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java index 1e88d300be..fa57764eba 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/AddressFullLoggingTest.java @@ -58,6 +58,7 @@ public class AddressFullLoggingTest extends ActiveMQTestBase { AddressSettings defaultSetting = new AddressSettings().setPageSizeBytes(10 * 1024).setMaxSizeBytes(20 * 1024).setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); server.getAddressSettingsRepository().addMatch("#", defaultSetting); + server.getConfiguration().setDiskScanPeriod(100); server.start(); internalTest(MAX_MESSAGES, MY_ADDRESS, MY_QUEUE, server); @@ -73,7 +74,7 @@ public class AddressFullLoggingTest extends ActiveMQTestBase { AddressSettings defaultSetting = new AddressSettings().setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK); server.getAddressSettingsRepository().addMatch("#", defaultSetting); - server.getConfiguration().setGlobalMaxSize(20 * 1024); + server.getConfiguration().setGlobalMaxSize(20 * 1024).setDiskScanPeriod(100); server.start(); @@ -122,7 +123,6 @@ public class AddressFullLoggingTest extends ActiveMQTestBase { executor.shutdown(); session.close(); - session = factory.createSession(false, true, true); session.start(); ClientConsumer consumer = session.createConsumer(MY_QUEUE); @@ -132,7 +132,8 @@ public class AddressFullLoggingTest extends ActiveMQTestBase { break; msg.acknowledge(); } - + //this is needed to allow to kick-in at least once disk scan + TimeUnit.MILLISECONDS.sleep(server.getConfiguration().getDiskScanPeriod() * 2); session.close(); locator.close(); server.stop(); @@ -140,6 +141,7 @@ public class AddressFullLoggingTest extends ActiveMQTestBase { // Using the code only so the test doesn't fail just because someone edits the log text Assert.assertTrue("Expected to find AMQ222183", AssertionLoggerHandler.findText("AMQ222183", "myAddress")); Assert.assertTrue("Expected to find AMQ221046", AssertionLoggerHandler.findText("AMQ221046", "myAddress")); + Assert.assertFalse("Expected to not find AMQ222211", AssertionLoggerHandler.findText("AMQ222211")); } @AfterClass