Bladeren bron

ZOOKEEPER-693. TestObserver stuck in tight notification loop in FLE

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@921509 13f79535-47bb-0310-9956-ffa450edef68
Patrick D. Hunt 15 jaren geleden
bovenliggende
commit
892c491e49

+ 5 - 1
CHANGES.txt

@@ -258,7 +258,11 @@ BUGFIXES:
 
   ZOOKEEPER-685.  Race in LENonTerminateTest (henry via breed)
 
-  ZOOKEEPER-677. c client doesn't allow ipv6 numeric connect string (breed & phunt & mahadev via breed)
+  ZOOKEEPER-677. c client doesn't allow ipv6 numeric connect string
+  (breed & phunt & mahadev via breed)
+
+  ZOOKEEPER-693. TestObserver stuck in tight notification loop in FLE
+  (flavio via phunt)
 
 IMPROVEMENTS:
   ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to

+ 11 - 0
src/java/main/org/apache/zookeeper/server/quorum/AuthFastLeaderElection.java

@@ -808,6 +808,17 @@ public class AuthFastLeaderElection implements Election {
 
     }
 
+    /**
+     * There is nothing to shutdown in this implementation of
+     * leader election, so we simply have an empty method.
+     */
+    public void shutdown(){}
+    
+    /**
+     * Invoked in QuorumPeer to find or elect a new leader.
+     * 
+     * @throws InterruptedException
+     */
     public Vote lookForLeader() throws InterruptedException {
         try {
             self.jmxLeaderElectionBean = new LeaderElectionBean();

+ 1 - 0
src/java/main/org/apache/zookeeper/server/quorum/Election.java

@@ -23,4 +23,5 @@ import org.apache.zookeeper.server.quorum.Vote;
 
 public interface Election {
     public Vote lookForLeader() throws InterruptedException;
+    public void shutdown();
 }

+ 11 - 0
src/java/main/org/apache/zookeeper/server/quorum/LeaderElection.java

@@ -111,6 +111,17 @@ public class LeaderElection implements Election  {
         return result;
     }
 
+    /**
+     * There is nothing to shutdown in this implementation of
+     * leader election, so we simply have an empty method.
+     */
+    public void shutdown(){}
+    
+    /**
+     * Invoked in QuorumPeer to find or elect a new leader.
+     * 
+     * @throws InterruptedException
+     */
     public Vote lookForLeader() throws InterruptedException {
         try {
             self.jmxLeaderElectionBean = new LeaderElectionBean();

+ 4 - 0
src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java

@@ -670,6 +670,10 @@ public class QuorumPeer extends Thread implements QuorumStats.Provider {
         if(udpSocket != null) {
             udpSocket.close();
         }
+        
+        if(getElectionAlg() != null){
+        	getElectionAlg().shutdown();
+        }
     }
 
     /**

+ 1 - 1
src/java/test/org/apache/zookeeper/test/ObserverTest.java

@@ -155,7 +155,7 @@ public class ObserverTest extends QuorumPeerTestBase implements Watcher{
                 lastEvent.getState() + ")",
                 (KeeperState.SyncConnected==lastEvent.getState() ||
                 KeeperState.Expired==lastEvent.getState())); 
-                       
+
         q1.shutdown();
         q2.shutdown();
         q3.shutdown();