You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2013/03/04 22:54:26 UTC
svn commit: r1452552 - in /hbase/branches/0.94/src:
main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java
test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java
Author: larsh
Date: Mon Mar 4 21:54:26 2013
New Revision: 1452552
URL: http://svn.apache.org/r1452552
Log:
HBASE-7111 hbase zkcli will not start if the zookeeper server chosen to connect to is unavailable (Zhou wenjian)
Modified:
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java
hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java?rev=1452552&r1=1452551&r2=1452552&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperMainServerArg.java Mon Mar 4 21:54:26 2013
@@ -20,8 +20,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;
@@ -41,18 +43,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.94/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java?rev=1452552&r1=1452551&r2=1452552&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperMainServerArg.java Mon Mar 4 21:54:26 2013
@@ -40,7 +40,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));
}
@org.junit.Rule