0
votes

I am trying to use HbaseTemplate from Spring Data module to connect to my HBase cluster via zookeeper. The session establishment happens just fine but the find method never returns with a value. It just hangs there forever.

I am attaching the config files and test case. Any help is appreciated.

Spring config:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:hdp="http://www.springframework.org/schema/hadoop" xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop-1.0.xsd">


    <bean id="hbaseTemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate"
        p:configuration-ref="hbaseConfiguration" />

        <hdp:configuration>


        </hdp:configuration>


    <hdp:hbase-configuration zk-quorum="hadoop-host-2" zk-port="2181" delete-connection="true">
    </hdp:hbase-configuration>

</beans>

Junit Test Class:

import java.util.List;

import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.hadoop.hbase.HbaseTemplate;
import org.springframework.data.hadoop.hbase.RowMapper;
import org.springframework.data.hadoop.hbase.TableCallback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/hbase/hbase-config.xml")
public class HBaseConnectionTest {

    @Autowired
    private HbaseTemplate hbaseTemplate;

    @Test
    public void testConnection() {

        List<String> list = hbaseTemplate.find("testTab",
                "testcf:testCol", new RowMapper<String>() {

                    @Override
                    public String mapRow(Result result, int arg1)
                            throws Exception {

                        return result.toString();

                    }
                });

        System.out.println(list);

    }

Output:

INFO : org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper - The identifier of this process is 8916@WINDOWS-8KV8O4B INFO : org.apache.zookeeper.client.ZooKeeperSaslClient - Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration. INFO : org.apache.zookeeper.ClientCnxn - Socket connection established to iaps-hadoop-host-2/192.168.111.242:2181, initiating session INFO : org.apache.zookeeper.ClientCnxn - Session establishment complete on server hadoop-host-2/192.168.111.242:2181, sessionid = 0x13c8bcf1cd7000a, negotiated timeout = 60000

1

1 Answers

0
votes

This was failing because some of the hosts in our hadoop cluster were not reachable from my client. Adding hostnames and ips properly fixed the issue.

This could be helpful for somebody.

Cheers Praveen