Browse Source

ZOOKEEPER-785. Zookeeper 3.3.1 shouldn't infinite loop if someone creates a server.0 line

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@995845 13f79535-47bb-0310-9956-ffa450edef68
Benjamin Reed 15 years ago
parent
commit
46c1493fac

+ 1 - 0
CHANGES.txt

@@ -88,6 +88,7 @@ BUGFIXES:
 
 
   ZOOKEEPER-867. ClientTest is failing on hudson - fd cleanup (phunt)
   ZOOKEEPER-867. ClientTest is failing on hudson - fd cleanup (phunt)
 
 
+  ZOOKEEPER-785. Zookeeper 3.3.1 shouldn't infinite loop if someone creates a server.0 line (phunt and Andrei Savu via breed)
 
 
 IMPROVEMENTS:
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   ZOOKEEPER-724. Improve junit test integration - log harness information 

+ 8 - 1
src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java

@@ -243,7 +243,14 @@ public class QuorumPeerConfig {
             throw new IllegalArgumentException(
             throw new IllegalArgumentException(
                     "minSessionTimeout must not be larger than maxSessionTimeout");
                     "minSessionTimeout must not be larger than maxSessionTimeout");
         }
         }
-        if (servers.size() > 1) {
+        if (servers.size() == 1) {
+            LOG.error("Invalid configuration, only one server specified (ignoring)");
+            servers.clear();
+        } else if (servers.size() > 1) {
+            if (servers.size() == 2) {
+                LOG.warn("No server failure will be tolerated. " +
+                    "You need at least 3 servers.");
+            }
             if (initLimit == 0) {
             if (initLimit == 0) {
                 throw new IllegalArgumentException("initLimit is not set");
                 throw new IllegalArgumentException("initLimit is not set");
             }
             }