In hbase shell code, the following *HMasterCommandLine#startMaster* code
logic has been in the code forever :-). I just wonder what is the logic
behind it & why it is the case for the error message ("shell will not be
able to find this ZK quorum").
- start zookeeper cluster and return the active ZK server port
- *the return port has to be the same as the default port in the config;
otherwise, throw exception*
- set the default port in configuration to be the return port (why, looks
redundant to me? - if this is not redundant, then after updating the
config, should SHELL be able to find the ZK quorum? - my testing show not,
but I could not figure out reason behind it.)
Here is the code:
int zkClientPort = conf.getInt(HConstants.ZOOKEEPER_CLIENT_PORT, 0);
if (zkClientPort == 0) {
throw new IOException("No config value for " +
HConstants.ZOOKEEPER_CLIENT_PORT);
}
...
int clientPort = zooKeeperCluster.startup(zkDataPath);
if (clientPort != zkClientPort) {
String errorMsg = "*Could not start ZK at requested port of " +*
* zkClientPort + ". ZK was started at port: " + clientPort +*
* ". Aborting as clients (e.g. shell) will not be able to find
" +*
* "this ZK quorum.*";
System.err.println(errorMsg);
throw new IOException(errorMsg);
}
conf.set(HConstants.ZOOKEEPER_CLIENT_PORT,
Integer.toString(clientPort));