knowone
knowone

Reputation: 840

Hbase REST is not retuning output from MapR DB

I am trying to query a Mapr table using Hbase rest API. I started hbase rest services using ./hbase-daemon.sh and wrote a small programm to query my table but it does not seems to be working. But when I am using curl tool to get data from MapR table then it is giving me proper output.

Here is my java code that I am using:

 import java.io.IOException;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.HTableInterface;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.rest.client.Client;
 import org.apache.hadoop.hbase.rest.client.Cluster;
 import org.apache.hadoop.hbase.rest.client.RemoteHTable;

 public class GetRequest
 {
 public static void main(String[] args) throws IOException
 {


         Cluster cluster = new Cluster();
         cluster.add(hostname, 8081);
         Client client = new Client(cluster);
         RemoteHTable table = new RemoteHTable(client, "/mytesttable");   //Remove forward slash to query in hbase table

         Get request = new Get(Bytes.toBytes("metric"));
         request.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("c"));
         Result result = table.get(request);
         System.out.println("Output Returned from Table--->  "+ Bytes.toString( result.getValue(Bytes.toBytes("cf"), Bytes.toBytes("c"))));
     }
 }

Here is the curl command which is returning me a proper output..

curl -H "Accept: text/xml" http://hostname:8081/%2Fmytesttable/metric/cf:c

Not sure what is wrong here? Any guesses, anyone?

Thanks in advance.

Upvotes: 1

Views: 415

Answers (2)

Chitral Verma
Chitral Verma

Reputation: 2853

The command that I use is,

userDetails=username+":"+password

"curl -k -u " + userDetails + " https://" + ip + ":" + port + "/rest/table/create?path=" + path + tableName

Upvotes: 0

Shashi
Shashi

Reputation: 2714

MapR will start its own hbase rest server using warden , you don't need to start it manually.It will be running at 8080 port(default port). Make sure your hbase rest service;you can check mapr cluster management UI.

Upvotes: 1

Related Questions