geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [08/46] geode git commit: GEODE-2107: fix the threadleak when a secondary sender is closed
Date Mon, 12 Dec 2016 22:36:11 GMT
GEODE-2107: fix the threadleak when a secondary sender is closed


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/c4ae846a
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/c4ae846a
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/c4ae846a

Branch: refs/heads/feature/GEODE-1930
Commit: c4ae846aa1689e2c5659b6ecc17e38689dd93976
Parents: 30bcdf8
Author: zhouxh <gzhou@pivotal.io>
Authored: Wed Nov 16 17:10:18 2016 -0800
Committer: zhouxh <gzhou@pivotal.io>
Committed: Wed Nov 16 17:10:18 2016 -0800

----------------------------------------------------------------------
 .../AbstractGatewaySenderEventProcessor.java    |  2 ++
 .../cache/wan/GatewaySenderAdvisor.java         | 29 ++++++++++++++------
 2 files changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c4ae846a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
index b41ace4..820cd99 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
@@ -1130,6 +1130,8 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread
{
           // interrupted
         }
       }
+    } else {
+      this.sender.getSenderAdvisor().notifyPrimaryLock();
     }
 
     setIsStopped(true);

http://git-wip-us.apache.org/repos/asf/geode/blob/c4ae846a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java
index 97cfac7..ace780e 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAdvisor.java
@@ -398,13 +398,23 @@ public class GatewaySenderAdvisor extends DistributionAdvisor {
       eventProcessor.removeCacheListener();
     }
 
+    logger.info(LocalizedMessage.create(
+        LocalizedStrings.SerialGatewaySenderImpl_0__BECOMING_PRIMARY_GATEWAYSENDER, this.sender));
+    notifyAndBecomePrimary();
+    new UpdateAttributesProcessor(this.sender).distribute(false);
+  }
+
+  public void notifyAndBecomePrimary() {
+    synchronized (this.primaryLock) {
+      setIsPrimary(true);
+      notifyPrimaryLock();
+    }
+  }
+
+  public void notifyPrimaryLock() {
     synchronized (this.primaryLock) {
-      this.isPrimary = true;
-      logger.info(LocalizedMessage.create(
-          LocalizedStrings.SerialGatewaySenderImpl_0__BECOMING_PRIMARY_GATEWAYSENDER, this.sender));
       this.primaryLock.notifyAll();
     }
-    new UpdateAttributesProcessor(this.sender).distribute(false);
   }
 
   public void makeSecondary() {
@@ -470,11 +480,14 @@ public class GatewaySenderAdvisor extends DistributionAdvisor {
       return;
     }
     synchronized (this.primaryLock) {
+      logger.info(LocalizedMessage.create(
+          LocalizedStrings.GatewayImpl_0__WAITING_TO_BECOME_PRIMARY_GATEWAY, this.sender.getId()));
       while (!isPrimary()) {
-        logger.info(LocalizedMessage.create(
-            LocalizedStrings.GatewayImpl_0__WAITING_TO_BECOME_PRIMARY_GATEWAY,
-            this.sender.getId()));
-        this.primaryLock.wait();
+        this.primaryLock.wait(1000);
+        if (sender.getEventProcessor() != null && sender.getEventProcessor().isStopped())
{
+          logger.info("The event processor is stopped, not to wait for being primary any
more.");
+          return;
+        }
       }
     }
   }


Mime
View raw message