全部产品
云市场

Java SDK for HBase OpenApi使用参考

更新时间:2019-11-21 20:25:49

欢迎使用阿里云开发者工具套件(Alibaba Cloud SDK for Java)。Alibaba Cloud SDK for Java让您不用复杂编程即可访问云数据库HBase版。本教程介绍如何安装并开始使用Alibaba Cloud SDK for Java。

前置条件

1、创建AccessKey

在线调试和生成SDK示例

OpenAPI Explorer提供在线调用云产品API、动态生成 SDK示例代码和快速检索接口等功能,能显著降低使用API的难度,推荐您使用,进入页面后,选择HBase产品,提供了接口列表,且包含了各个语言的调试demo,供大家参考。

1、安装下载Alibaba Cloud SDK for Java

注意:通过maven引用sdk包时,请下载最新的版本。

2、示例demo

1)设置环境参数

  1. DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou",
  2. "LTAI4FnvzUftE**********", "PxPzgelK1XCkWBXW***********");
  3. // 以下非必选项,可默认
  4. DefaultProfile.addEndpoint(
  5. "cn-hangzhou", // 地域ID
  6. "hbase", // 产品编码
  7. "hbase.aliyuncs.com" // 接入地址,即域名
  8. );

2)初始化客户端

  1. IAcsClient client = new DefaultAcsClient(profile);

3)构造请求对象

  1. DescribeInstanceRequest request = new DescribeInstanceRequest();
  2. request.setClusterId("ap-*****************");

4)请求调用

  1. DescribeInstanceResponse response;
  2. try {
  3. response = client.getAcsResponse(request);
  4. System.out.println(new Gson().toJson(response));
  5. } catch (ClientException e) {
  6. e.printStackTrace();
  7. }

参考示例

  1. DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou",
  2. "ak******************", "akSecret********************");
  3. DefaultProfile.addEndpoint(
  4. "cn-hangzhou", // 地域ID
  5. "hbase", // 产品编码
  6. "hbase.aliyuncs.com" // 接入地址,即域名
  7. );
  8. IAcsClient client = new DefaultAcsClient(profile);
  9. DescribeInstanceRequest request = new DescribeInstanceRequest();
  10. request.setClusterId("ap-******************");
  11. DescribeInstanceResponse response;
  12. try {
  13. response = client.getAcsResponse(request);
  14. System.out.println(new Gson().toJson(response));
  15. } catch (ClientException e) {
  16. e.printStackTrace();
  17. }

响应示例

  1. {
  2. "requestId":"2817B189-6927-41E0-879F-*********",
  3. "instanceId":"ap-****************",
  4. "instanceName":"myInstanceName",
  5. "status":"ACTIVATION",
  6. "payType":"PayAsYouGo",
  7. "createdTime":"2019-10-31T21:50:14",
  8. "majorVersion":"2.0",
  9. "minorVersion":"2.4.3.1",
  10. "engine":"spark",
  11. "networkType":"VPC",
  12. "vpcId":"vpc-****************",
  13. "vswitchId":"vsw-****************",
  14. "masterInstanceType":"spark.sn1.medium",
  15. "masterNodeCount":2,
  16. "masterDiskType":"",
  17. "masterDiskSize":0,
  18. "coreInstanceType":"spark.sn1.large",
  19. "coreNodeCount":4,
  20. "coreDiskType":"cloud_efficiency",
  21. "coreDiskSize":100,
  22. "regionId":"cn-hangzhou",
  23. "zoneId":"cn-hangzhou-f",
  24. "coldStorageStatus":"close",
  25. "backupStatus":"close",
  26. "tags":[
  27. ]
  28. }