AnsweredAssumed Answered

Failed to connect HBase from Tomcat server

Question asked by Mustafa on Apr 19, 2017
Latest reply on May 10, 2017 by maprcommunity

Trying to connect HBase from Tomcat server using Java API but unable to achive so, using Maven. 

This is my code to create the table in HBase

public static void executeCreate() throws IOException {

Configuration hbaseConf = HBaseConfiguration.create();
hbaseConf.set("hbase.zookeeper.quorum", "host1,host2,host3");
hbaseConf.set("hbase.zookeeper.property.clientPort", "5181");
hbaseConf.setInt("fs.mapr.rpc.timeout", 120000);


TableName table = TableName.valueOf("Employee_Records");
org.apache.hadoop.hbase.client.Connection conn = ConnectionFactory.createConnection(hbaseConf);

Admin admin = conn.getAdmin();

if (admin.isTableAvailable(table)) {

admin.disableTable(table);

admin.deleteTable(table);
}

HTableDescriptor tableDescriptor = new HTableDescriptor(table);
tableDescriptor.addFamily(new HColumnDescriptor("CF1"));
admin.createTable(tableDescriptor);

 

if (admin.isTableDisabled(table)) {
admin.enableTable(table);

}

*host1,host2,host3 are the ip address for hbase connection.

 

This is Pom File.

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop</artifactId>
<version>0.20.2-dev-core</version>
</dependency>

<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>1.1.1-mapr-1602</version>
</dependency>

Outcomes