ARTEMIS-3405 Log the end of paging mode for a destination

This commit is contained in:
franz1981 2021-07-27 15:34:13 +02:00 committed by clebertsuconic
parent 57790a93a9
commit 63577c7264
3 changed files with 61 additions and 5 deletions

View File

@ -506,7 +506,11 @@ public class PagingStoreImpl implements PagingStore {
public void stopPaging() { public void stopPaging() {
lock.writeLock().lock(); lock.writeLock().lock();
try { try {
paging = false; final boolean isPaging = this.paging;
if (isPaging) {
paging = false;
ActiveMQServerLogger.LOGGER.pageStoreStop(storeName, sizeInBytes.get(), maxSize, pagingManager.getGlobalSize());
}
this.cursorProvider.onPageModeCleared(); this.cursorProvider.onPageModeCleared();
} finally { } finally {
lock.writeLock().unlock(); lock.writeLock().unlock();
@ -549,8 +553,8 @@ public class PagingStoreImpl implements PagingStore {
return false; return false;
} }
} }
paging = true; paging = true;
ActiveMQServerLogger.LOGGER.pageStoreStart(storeName, sizeInBytes.get(), maxSize, pagingManager.getGlobalSize());
return true; return true;
} finally { } finally {
@ -762,9 +766,7 @@ public class PagingStoreImpl implements PagingStore {
} else if (addressFullMessagePolicy == AddressFullMessagePolicy.PAGE) { } else if (addressFullMessagePolicy == AddressFullMessagePolicy.PAGE) {
if (size > 0) { if (size > 0) {
if (maxSize != -1 && newSize > maxSize || globalFull) { if (maxSize != -1 && newSize > maxSize || globalFull) {
if (startPaging()) { startPaging();
ActiveMQServerLogger.LOGGER.pageStoreStart(storeName, newSize, maxSize, pagingManager.getGlobalSize());
}
} }
} }

View File

@ -2146,4 +2146,8 @@ public interface ActiveMQServerLogger extends BasicLogger {
@LogMessage(level = Logger.Level.INFO) @LogMessage(level = Logger.Level.INFO)
@Message(id = 224107, value = "The Critical Analyzer detected slow paths on the broker. It is recommended that you enable trace logs on org.apache.activemq.artemis.utils.critical while you troubleshoot this issue. You should disable the trace logs when you have finished troubleshooting.", format = Message.Format.MESSAGE_FORMAT) @Message(id = 224107, value = "The Critical Analyzer detected slow paths on the broker. It is recommended that you enable trace logs on org.apache.activemq.artemis.utils.critical while you troubleshoot this issue. You should disable the trace logs when you have finished troubleshooting.", format = Message.Format.MESSAGE_FORMAT)
void enableTraceForCriticalAnalyzer(); void enableTraceForCriticalAnalyzer();
@LogMessage(level = Logger.Level.WARN)
@Message(id = 224108, value = "Stopped paging on address ''{0}''; size is currently: {1} bytes; max-size-bytes: {2}; global-size-bytes: {3}", format = Message.Format.MESSAGE_FORMAT)
void pageStoreStop(SimpleString storeName, long addressSize, long maxSize, long globalMaxSize);
} }

View File

@ -56,6 +56,7 @@ import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
import org.apache.activemq.artemis.core.settings.HierarchicalRepository; import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy; import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessagePersister; import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessagePersister;
import org.apache.activemq.artemis.spi.core.protocol.MessagePersister; import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
@ -71,6 +72,8 @@ import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.apache.activemq.artemis.logs.AssertionLoggerHandler.findText;
public class PagingStoreImplTest extends ActiveMQTestBase { public class PagingStoreImplTest extends ActiveMQTestBase {
private static final Logger log = Logger.getLogger(PagingStoreImplTest.class); private static final Logger log = Logger.getLogger(PagingStoreImplTest.class);
@ -802,6 +805,53 @@ public class PagingStoreImplTest extends ActiveMQTestBase {
storeImpl.stop(); storeImpl.stop();
} }
@Test
public void testLogStartPaging() throws Exception {
SequentialFileFactory factory = new FakeSequentialFileFactory();
PagingStoreFactory storeFactory = new FakeStoreFactory(factory);
PagingStoreImpl store = new PagingStoreImpl(PagingStoreImplTest.destinationTestName, null, 100,
createMockManager(), createStorageManagerMock(), factory, storeFactory,
PagingStoreImplTest.destinationTestName,
new AddressSettings()
.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE),
getExecutorFactory().getExecutor(), true);
store.start();
AssertionLoggerHandler.startCapture();
try {
store.startPaging();
store.stopPaging();
Assert.assertTrue(findText("AMQ222038"));
} finally {
AssertionLoggerHandler.stopCapture();
}
}
@Test
public void testLogStopPaging() throws Exception {
SequentialFileFactory factory = new FakeSequentialFileFactory();
PagingStoreFactory storeFactory = new FakeStoreFactory(factory);
PagingStoreImpl store = new PagingStoreImpl(PagingStoreImplTest.destinationTestName, null, 100,
createMockManager(), createStorageManagerMock(), factory, storeFactory,
PagingStoreImplTest.destinationTestName,
new AddressSettings()
.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE),
getExecutorFactory().getExecutor(), true);
store.start();
AssertionLoggerHandler.startCapture();
try {
store.startPaging();
store.stopPaging();
Assert.assertTrue(findText("AMQ224108"));
} finally {
AssertionLoggerHandler.stopCapture();
}
}
/** /**
* @return * @return
*/ */