This topic describes how to install the Alibaba Cloud SDK for Java and then call the ApsaraDB for HBase API. By using Alibaba Cloud SDK for Java, you can manage ApsaraDB for HBase instances without the need of coding. For example, you can create, upgrade, delete instances, configure whitelists, and manage tags. For more information, see API reference. Note that Alibaba Cloud SDK for Java is different from the SDKs used to develop HBase clients. This topic describes how to install and use Alibaba Cloud SDK for Java.

1. Create an AccessKey pair

Online debugging and SDK demo generation

OpenApi Explorer provides features such as calling APIs of cloud products online, dynamically generating SDK demos, and quickly searching for APIs, which can significantly simplify your work of using APIs. We recommend that you use OpenAPI Explorer. Select ApsaraDB for HBase on the Home page. Alibaba Cloud provides a list of API operations and SDK demos in different languages for your reference.

1. Install Alibaba Cloud SDK for Java

Note: When you use Maven to download the SDK package, make sure that the latest SDK version is downloaded.

2. Demo

1) Set environment parameters.

DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou",
                "LTAI4FnvzUftE**********", "PxPzgelK1XCkWBXW***********");
        // The following parameters are optional. You can use the default settings.
        DefaultProfile.addEndpoint(
                "cn-hangzhou",    // The region ID
                "hbase",    // The product code
                "hbase.aliyuncs.com"    // The endpoint, which is the domain name
        );

2) Initialize the client.

IAcsClient client = new DefaultAcsClient(profile);

3) Construct the request object.

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

4) Initiate a call.

DescribeInstanceResponse response;
        try {
            response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ClientException e) {
            e.printStackTrace();
        }

Examples

DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou",
                "ak******************", "akSecret********************");
        DefaultProfile.addEndpoint(
                "cn-hangzhou",    // The region ID
                "hbase",    // The product code
                "hbase.aliyuncs.com"    // The endpoint, which is the domain name
        );
        IAcsClient client = new DefaultAcsClient(profile);
        DescribeInstanceRequest request = new DescribeInstanceRequest();
        request.setClusterId("ap-******************");
        DescribeInstanceResponse response;
        try {
            response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ClientException e) {
            e.printStackTrace();
        }

Sample responses

{
    "requestId":"2817B189-6927-41E0-879F-*********",
    "instanceId":"ap-****************",
    "instanceName":"myInstanceName",
    "status":"ACTIVATION",
    "payType":"PayAsYouGo",
    "createdTime":"2019-10-31T21:50:14",
    "majorVersion":"2.0",
    "minorVersion":"2.4.3.1",
    "engine":"spark",
    "networkType":"VPC",
    "vpcId":"vpc-****************",
    "vswitchId":"vsw-****************",
    "masterInstanceType":"spark.sn1.medium",
    "masterNodeCount":2,
    "masterDiskType":"",
    "masterDiskSize":0,
    "coreInstanceType":"spark.sn1.large",
    "coreNodeCount":4,
    "coreDiskType":"cloud_efficiency",
    "coreDiskSize":100,
    "regionId":"cn-hangzhou",
    "zoneId":"cn-hangzhou-f",
    "coldStorageStatus":"close",
    "backupStatus":"close",
    "tags":[

    ]
}