I have VM where habse is installed. IP:192.168.20.10 I want to try to connect to hbase from my desktop: Here is what I am trying>
public static void main(String[] args) throws IOException {
AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/hbase-beans.xml", HBaseConnection.class);
context.registerShutdownHook();
UserRepository userRepository = context.getBean(UserRepository.class);
List<User> users = userRepository.findAll();
System.out.println("Number of users = " + users.size());
System.out.println(users);
}
public List<User> findAll() {
return hbaseTemplate.find(tableName, "cfInfo", new RowMapper<User>() {
public User mapRow(Result result, int rowNum) throws Exception {
return new User(Bytes.toString(result.getValue(CF_INFO, qUser)),
Bytes.toString(result.getValue(CF_INFO, qEmail)),
Bytes.toString(result.getValue(CF_INFO, qPassword))
);
}
});
}
And this is my bean.xml
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:hadoop="http://www.springframework.org/schema/hadoop" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<context:component-scan base-package="com.hbase.dao"/>
<context:component-scan base-package="com.hbase.object"/>
<hadoop:configuration id="hadoopConfiguration">fs.default.name=hdfs://192.168.20.10:9000</hadoop:configuration>
<hadoop:hbase-configuration configuration-ref="hadoopConfiguration" zk-port="2181" zk-quorum="192.168.20.10"></hadoop:hbase-configuration>
<bean id="hbaseTemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate">
<property name="configuration" ref="hbaseConfiguration" />
</bean>
</beans>
This code works fine when I run directly in remote machine.When I am running same code from my windows machine by providing ip of hbase .,it doesnot return any value.