Litchy
Litchy

Reputation: 363

java.lang.NumberFormatException when trying to connect to HBase

I am setting HBase configuration new HBaseGraphConfiguration().set("hbase.zookeeper.quorum", ZOOKEPER_QORUM_NODE) where

ZOOKEPER_QORUM_NODE = "172.31.17.251:2181,172.31.17.252:2181,172.31.17.253:2181";

However it throws an java.lang.NumberFormatException, the part of the error is

Caused by: java.lang.NumberFormatException: For input string: "2181]"
  at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
  at java.lang.Integer.parseInt(Integer.java:580)
  at java.lang.Integer.parseInt(Integer.java:615)
  at org.apache.zookeeper.client.ConnectStringParser.<init>(ConnectStringParser.java:72)

The console output before the error line is

2018-05-30 14:40:52 INFO  org.apache.zookeeper.ZooKeeper - Initiating client connection, connectString=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181] sessionTimeout=180000 watcher=hconnection-0x25a65b770x0, quorum=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181], baseZNode=/hbase
2018-05-30 14:40:52 INFO  org.apache.zookeeper.ZooKeeper - Initiating client connection, connectString=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181] sessionTimeout=180000 watcher=hconnection-0x25a65b770x0, quorum=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181], baseZNode=/hbase

How to solve it?

Upvotes: 0

Views: 1112

Answers (2)

Litchy
Litchy

Reputation: 363

Thanks for the answer of @VS_FF, I have found the issue and also now posting the whole answer

The short solution of this problem is just set conf.setDelimiterParsingDisabled(true);

First it is suggested to set the hbase.zookeeper.quorum = "ip1,ip2,ip3" (host ip) and hbase.zookeeper.property.clientPort = 2181 (port) separately.

The string of ip addresses are inputted to HBase configuration . Then, it has two sorts of parsing method, controlled by

conf = new PropertiesConfiguration();
conf.setDelimiterParsingDisabled(true);

if this setDelimiterParsingDisabled(true) is applied, then configuration will input the origin string to zookeeper, saying "ip1,ip2,ip3", otherwise setDelimiterParsingDisabled(false) (this is the default setting), in this condition, it will input an array to zookeeper, saying [ip1,ip2,ip3].

However, zookeeper need to get a String variable, so if setDelimiterParsingDisabled(false), it will first convert the array to String, adding the brackets [].

Finally, zookeeper parse the String variable by using split of notation ,, that is why it finally gets ip1 = "[ip1", ip2 = "ip2", ip3 = "ip3]" and throws an NumberFormatException

Upvotes: 1

VS_FF
VS_FF

Reputation: 2373

A few suggestions for you to try to debug around this:

First, there is a separate property that you can supply for the client port specifically, instead of using the IP:port notation: hbase.zookeeper.property.clientPort So try supplying those two parameters separately -- one a comma delimited list of addresses and the second parameter just this one number (I pass it as a string though, so "2181")

Second, IMPORTANT: be careful with supplying IP addresses here in general, as HBase seems very picky in terms of IP addresses and host names. Much better to use host names and to put those IP addresses in /etc/hosts file on your client along with the desired host names

Upvotes: 1

Related Questions