HBASE-8766 [WINDOWS] bin/hbase.cmd zkcli is broken

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1494732 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Enis Soztutar 2013-06-19 18:37:26 +00:00
parent becbdfa8d1
commit 559aa12a09
4 changed files with 12 additions and 20 deletions

View File

@ -273,10 +273,7 @@ elif [ "$COMMAND" = "hlog" ] ; then
elif [ "$COMMAND" = "hfile" ] ; then elif [ "$COMMAND" = "hfile" ] ; then
CLASS='org.apache.hadoop.hbase.io.hfile.HFile' CLASS='org.apache.hadoop.hbase.io.hfile.HFile'
elif [ "$COMMAND" = "zkcli" ] ; then elif [ "$COMMAND" = "zkcli" ] ; then
# ZooKeeperMainServerArg returns '-server HOST:PORT' or empty string. CLASS="org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServer"
SERVER_ARG=`"$bin"/hbase org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServerArg`
CLASS="org.apache.zookeeper.ZooKeeperMain ${SERVER_ARG}"
elif [ "$COMMAND" = "master" ] ; then elif [ "$COMMAND" = "master" ] ; then
CLASS='org.apache.hadoop.hbase.master.HMaster' CLASS='org.apache.hadoop.hbase.master.HMaster'
if [ "$1" != "stop" ] ; then if [ "$1" != "stop" ] ; then

View File

@ -337,9 +337,7 @@ goto :eof
goto :eof goto :eof
:zkcli :zkcli
rem ZooKeeperMainServerArg returns '-server HOST:PORT' or empty string. set CLASS=org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServer
set SERVER_ARG=%HADOOP_BIN_PATH%\hbase org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServerArg
set CLASS=org.apache.zookeeper.ZooKeeperMain %SERVER_ARG%
goto :eof goto :eof
:makeServiceXml :makeServiceXml

View File

@ -26,15 +26,13 @@ import java.util.Properties;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.zookeeper.ZooKeeperMain;
/** /**
* Tool for reading a ZooKeeper server from HBase XML configuration producing * Tool for running ZookeeperMain from HBase by reading a ZooKeeper server
* the '-server host:port' argument to pass ZooKeeperMain. This program * from HBase XML configuration.
* emits either '-server HOST:PORT" where HOST is one of the zk ensemble
* members plus zk client port OR it emits '' if no zk servers found (Yes,
* it emits '-server' too).
*/ */
public class ZooKeeperMainServerArg { public class ZooKeeperMainServer {
public String parse(final Configuration c) { public String parse(final Configuration c) {
// Note that we do not simply grab the property // Note that we do not simply grab the property
// HConstants.ZOOKEEPER_QUORUM from the HBaseConfiguration because the // HConstants.ZOOKEEPER_QUORUM from the HBaseConfiguration because the
@ -68,10 +66,10 @@ public class ZooKeeperMainServerArg {
* Run the tool. * Run the tool.
* @param args Command line arguments. First arg is path to zookeepers file. * @param args Command line arguments. First arg is path to zookeepers file.
*/ */
public static void main(String args[]) { public static void main(String args[]) throws Exception {
Configuration conf = HBaseConfiguration.create(); Configuration conf = HBaseConfiguration.create();
String hostport = new ZooKeeperMainServerArg().parse(conf); String hostport = new ZooKeeperMainServer().parse(conf);
System.out.println((hostport == null || hostport.length() == 0)? "": String zkArg = (hostport == null || hostport.length() == 0)? "": "-server " + hostport;
"-server " + hostport); ZooKeeperMain.main(new String[] {zkArg});
} }
} }

View File

@ -27,8 +27,8 @@ import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
@Category(SmallTests.class) @Category(SmallTests.class)
public class TestZooKeeperMainServerArg { public class TestZooKeeperMainServer {
private final ZooKeeperMainServerArg parser = new ZooKeeperMainServerArg(); private final ZooKeeperMainServer parser = new ZooKeeperMainServer();
@Test public void test() { @Test public void test() {
Configuration c = HBaseConfiguration.create(); Configuration c = HBaseConfiguration.create();
@ -42,6 +42,5 @@ public class TestZooKeeperMainServerArg {
assertTrue(port, assertTrue(port,
parser.parse(c).matches("(example[1-3]\\.com,){2}example[1-3]\\.com:" + port)); parser.parse(c).matches("(example[1-3]\\.com,){2}example[1-3]\\.com:" + port));
} }
} }