From 652f8265c88f6ac545ad62033ac92a5754964e78 Mon Sep 17 00:00:00 2001 From: jbertram Date: Wed, 10 Aug 2016 14:12:44 -0500 Subject: [PATCH] ARTEMIS-678 refactor log for expiry optimization --- .../artemis/core/server/impl/QueueImpl.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java index 16b8880305..dfcba279ea 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java @@ -1375,10 +1375,7 @@ public class QueueImpl implements Queue { @Override public synchronized boolean expireReference(final long messageID) throws Exception { - if (expiryAddress != null && expiryAddress.equals(this.address)) { - // check expire with itself would be silly (waste of time) - if (logger.isDebugEnabled()) - logger.debug("Cannot expire from " + address + " into " + expiryAddress); + if (isExpirationRedundant()) { return false; } @@ -1400,10 +1397,7 @@ public class QueueImpl implements Queue { @Override public synchronized int expireReferences(final Filter filter) throws Exception { - if (expiryAddress != null && expiryAddress.equals(this.address)) { - // check expire with itself would be silly (waste of time) - if (logger.isDebugEnabled()) - logger.debug("Cannot expire from " + address + " into " + expiryAddress); + if (isExpirationRedundant()) { return 0; } @@ -1432,10 +1426,7 @@ public class QueueImpl implements Queue { @Override public void expireReferences() { - if (expiryAddress != null && expiryAddress.equals(this.address)) { - // check expire with itself would be silly (waste of time) - if (logger.isDebugEnabled()) - logger.debug("Cannot expire from " + address + " into " + expiryAddress); + if (isExpirationRedundant()) { return; } @@ -1445,6 +1436,18 @@ public class QueueImpl implements Queue { } } + public boolean isExpirationRedundant() { + if (expiryAddress != null && expiryAddress.equals(this.address)) { + // check expire with itself would be silly (waste of time) + if (logger.isTraceEnabled()) + logger.trace("Redundant expiration from " + address + " to " + expiryAddress); + + return true; + } + + return false; + } + class ExpiryScanner implements Runnable { public AtomicInteger scannerRunning = new AtomicInteger(0);