activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1404732 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/region/ test/java/org/apache/activemq/usecases/
Date Thu, 01 Nov 2012 19:44:38 GMT
Author: tabish
Date: Thu Nov  1 19:44:37 2012
New Revision: 1404732

URL: http://svn.apache.org/viewvc?rev=1404732&view=rev
Log:
fix and updated test for: https://issues.apache.org/jira/browse/AMQ-4149

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java?rev=1404732&r1=1404731&r2=1404732&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/DurableTopicSubscription.java
Thu Nov  1 19:44:37 2012
@@ -72,6 +72,10 @@ public class DurableTopicSubscription ex
         return offlineTimestamp.get();
     }
 
+    public void setOfflineTimestamp(long timestamp) {
+        offlineTimestamp.set(timestamp);
+    }
+
     public boolean isFull() {
         return !active.get() || super.isFull();
     }
@@ -139,7 +143,9 @@ public class DurableTopicSubscription ex
                 }
             }
 
-            LOG.debug("Activating " + this);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Activating " + this);
+            }
             if (!keepDurableSubsActive) {
                 for (Destination destination : durableDestinations.values()) {
                     Topic topic = (Topic) destination;
@@ -170,7 +176,9 @@ public class DurableTopicSubscription ex
     }
 
     public void deactivate(boolean keepDurableSubsActive) throws Exception {
-        LOG.debug("Deactivating keepActive=" + keepDurableSubsActive + ", " + this);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Deactivating keepActive=" + keepDurableSubsActive + ", " + this);
+        }
         active.set(false);
         offlineTimestamp.set(System.currentTimeMillis());
         this.usageManager.getMemoryUsage().removeUsageListener(this);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java?rev=1404732&r1=1404731&r2=1404732&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/TopicRegion.java
Thu Nov  1 19:44:37 2012
@@ -86,7 +86,7 @@ public class TopicRegion extends Abstrac
         for (Map.Entry<SubscriptionKey, DurableTopicSubscription> entry : durableSubscriptions.entrySet())
{
             DurableTopicSubscription sub = entry.getValue();
             if (!sub.isActive()) {
-               long offline = sub.getOfflineTimestamp();
+                long offline = sub.getOfflineTimestamp();
                 if (offline != -1 && now - offline >= broker.getBrokerService().getOfflineDurableSubscriberTimeout())
{
                     LOG.info("Destroying durable subscriber due to inactivity: " + sub);
                     try {
@@ -243,6 +243,7 @@ public class TopicRegion extends Abstrac
                     c.setClientId(key.getClientId());
                     c.setConnectionId(consumerInfo.getConsumerId().getParentId().getParentId());
                     sub = (DurableTopicSubscription)createSubscription(c, consumerInfo);
+                    sub.setOfflineTimestamp(System.currentTimeMillis());
                 }
 
                 if (dupChecker.contains(sub)) {
@@ -258,7 +259,7 @@ public class TopicRegion extends Abstrac
             // that would match this destination..
             durableSubscriptions.values();
             for (DurableTopicSubscription sub : durableSubscriptions.values()) {
-                // Skip over subscriptions that we allready added..
+                // Skip over subscriptions that we already added..
                 if (dupChecker.contains(sub)) {
                     continue;
                 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java?rev=1404732&r1=1404731&r2=1404732&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java
Thu Nov  1 19:44:37 2012
@@ -26,9 +26,13 @@ import junit.framework.Test;
 import org.apache.activemq.EmbeddedBrokerTestSupport;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.util.Wait;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class DurableSubscriptionRemoveOfflineTest extends EmbeddedBrokerTestSupport {
 
+    private static final Logger LOG = LoggerFactory.getLogger(DurableSubscriptionRemoveOfflineTest.class);
+
     protected void setUp() throws Exception {
         useTopic = true;
         super.setUp();
@@ -88,16 +92,20 @@ public class DurableSubscriptionRemoveOf
         subscriber.close();
         connection.close();
 
+        LOG.info("Broker restarting, wait for inactive cleanup afterwards.");
+
         restartBroker();
 
+        LOG.info("Broker restarted, wait for inactive cleanup now.");
+
         assertTrue(broker.getAdminView().getInactiveDurableTopicSubscribers().length == 1);
 
-        Wait.waitFor(new Wait.Condition() {
+        assertTrue(Wait.waitFor(new Wait.Condition() {
             @Override
             public boolean isSatisified() throws Exception {
                  return broker.getAdminView().getInactiveDurableTopicSubscribers().length
== 0;
             }
-        }, 20000);
+        }, 20000));
     }
 
     protected boolean isPersistent() {



Mime
View raw message