无法使用Spring';从Hbase查询;s hbase模板

无法使用Spring';从Hbase查询;s hbase模板,hbase,spring-data,Hbase,Spring Data,我正在尝试使用Spring数据模块中的HbaseTemplate通过zookeeper连接到我的HBase集群。会话建立进行得很顺利,但是find方法永远不会返回值。它永远挂在那里 我正在附加配置文件和测试用例。感谢您的帮助 弹簧配置: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://ww

我正在尝试使用Spring数据模块中的HbaseTemplate通过zookeeper连接到我的HBase集群。会话建立进行得很顺利,但是find方法永远不会返回值。它永远挂在那里

我正在附加配置文件和测试用例。感谢您的帮助

弹簧配置:

<?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测试类:

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);

    }
import java.util.List;
导入org.apache.hadoop.hbase.client.HTableInterface;
导入org.apache.hadoop.hbase.client.Put;
导入org.apache.hadoop.hbase.client.Result;
导入org.apache.hadoop.hbase.util.Bytes;
导入org.junit.Test;
导入org.junit.runner.RunWith;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.data.hadoop.hbase.HbaseTemplate;
导入org.springframework.data.hadoop.hbase.RowMapper;
导入org.springframework.data.hadoop.hbase.TableCallback;
导入org.springframework.test.context.ContextConfiguration;
导入org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(“文件:src/main/webapp/WEB-INF/spring/hbase/hbase config.xml”)
公共类HBaseConnectionTest{
@自动连线
私人HbaseTemplate HbaseTemplate;
@试验
公共void testConnection(){
List List=hbaseTemplate.find(“testTab”,
“testcf:testCol”,新的行映射器(){
@凌驾
公共字符串mapRow(结果,int arg1)
抛出异常{
返回result.toString();
}
});
系统输出打印项次(列表);
}
输出:

信息:org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper-此进程的标识符为8916@WINDOWS-8KV8O4B 信息:org.apache.zookeeper.client.ZooKeeperSaslClient-客户端将不会进行SASL身份验证,因为找不到默认JAAS配置节“client”。如果您未使用SASL,则可以忽略此项。另一方面,如果您希望SASL正常工作,请修复JAAS配置。 信息:org.apache.zookeeper.ClientCnxn-已建立到iaps-hadoop-host-2/192.168.111.242:2181的套接字连接,正在启动会话
信息:org.apache.zookeeper.ClientCnxn-在服务器hadoop-host-2/192.168.111.242:2181上完成会话建立,sessionid=0x13c8bcf1cd7000a,协商超时=60000

这是失败的,因为我的客户端无法访问我们hadoop集群中的某些主机。添加主机名和IP正确地修复了该问题

这可能对某人有帮助

干杯
Praveen

详细信息?您需要在哪里添加它们?