hbase rest没有重新调整mapr db的输出

7z5jn7bk  于 2021-06-09  发布在  Hbase
关注(0)|答案(2)|浏览(321)

我正在尝试使用hbase restapi查询mapr表。我使用 ./hbase-daemon.sh 并编写了一个小程序来查询我的表,但它似乎不工作。但当我使用curl工具从mapr表中获取数据时,它会给我正确的输出。
下面是我正在使用的java代码:

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

下面是curl命令,它将返回正确的输出。。

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

不知道这里怎么了?有人猜吗?
提前谢谢。

svgewumm

svgewumm1#

我使用的命令是,
userdetails=用户名+“:”+密码
“curl-k-u”+userdetails+“https://“+ip+”:“+port+”/rest/table/create?path=“+path+tablename”

5lwkijsr

5lwkijsr2#

mapr将使用warden启动自己的hbase rest服务器,您不需要手动启动它。它将在8080端口(默认端口)上运行。确保您的hbase rest服务;您可以检查mapr集群管理ui。

相关问题