hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1452553 - in /hbase/branches/0.95/hbase-server/src: main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java
Date Mon, 04 Mar 2013 21:55:12 GMT
Author: larsh
Date: Mon Mar  4 21:55:12 2013
New Revision: 1452553

URL: http://svn.apache.org/r1452553
Log:
HBASE-7111 hbase zkcli will not start if the zookeeper server chosen to connect to is unavailable
(Zhou wenjian)

Modified:
    hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java
    hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java?rev=1452553&r1=1452552&r2=1452553&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java
(original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java
Mon Mar  4 21:55:12 2013
@@ -19,8 +19,10 @@
 
 package org.apache.hadoop.hbase.zookeeper;
 
-import java.util.Properties;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map.Entry;
+import java.util.Properties;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;
@@ -40,18 +42,26 @@ public class ZooKeeperMainServerArg {
     Properties zkProps = ZKConfig.makeZKProps(c);
     String host = null;
     String clientPort = null;
+    List<String> hosts = new ArrayList<String>();
     for (Entry<Object, Object> entry: zkProps.entrySet()) {
       String key = entry.getKey().toString().trim();
       String value = entry.getValue().toString().trim();
-      if (key.startsWith("server.") && host == null) {
+      if (key.startsWith("server.")) {
         String[] parts = value.split(":");
-        host = parts[0];
+        hosts.add(parts[0]);
       } else if (key.endsWith("clientPort")) {
         clientPort = value;
       }
-      if (host != null && clientPort != null) break;
     }
-    return host != null && clientPort != null? host + ":" + clientPort: null;
+    if (hosts.isEmpty() || clientPort == null)
+      return null;
+    for (int i = 0; i < hosts.size(); i++) {
+      if (i > 0)
+        host += "," + hosts.get(i);
+      else
+        host = hosts.get(i);
+    }
+    return host != null ? host + ":" + clientPort : null;
   }
 
   /**

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java?rev=1452553&r1=1452552&r2=1452553&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java
(original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java
Mon Mar  4 21:55:12 2013
@@ -39,7 +39,8 @@ public class TestZooKeeperMainServerArg 
     c.set("hbase.zookeeper.quorum", "example.com");
     assertEquals("example.com:" + port, parser.parse(c));
     c.set("hbase.zookeeper.quorum", "example1.com,example2.com,example3.com");
-    assertTrue(port, parser.parse(c).matches("example[1-3]\\.com:" + port));
+    assertTrue(port,
+        parser.parse(c).matches("(example[1-3]\\.com,){2}example[1-3]\\.com:" + port));
   }
 
 }



Mime
View raw message