You can use Realtime Compute for Apache Flink to connect to ApsaraDB for HBase Performance-enhanced Edition. This topic describes how to connect to an ApsaraDB for HBase Performance-enhanced Edition cluster from a Realtime Compute for Apache Flink cluster and create a result table and a dimension table.

Background information

You can use tables that are created in ApsaraDB for HBase Performance-enhanced Edition as dimension tables or result tables in Realtime Compute for Apache Flink. For more information, see Create an ApsaraDB for HBase result table and Create an ApsaraDB for HBase dimension table in the documentation of Realtime Compute for Apache Flink.

Additional considerations

You can execute a DDL statement to create an ApsaraDB for HBase dimension or result table of the Performance-enhanced Edition in Realtime Compute for Apache Flink. When you execute the DDL statement, you must specify an endpoint of the ApsaraDB for HBase Performance-enhanced Edition cluster in the statement. Realtime Compute for Apache Flink connects to an ApsaraDB for HBase Performance-enhanced Edition cluster by using the endpoint that is used by the HBase Java API. If you use a newly created user, make sure that the user is granted the permissions to access Realtime Compute for Apache Flink and the permissions to read and write tables in Realtime Compute for Apache Flink. For more information, see Manage users and ACLs.

Create a dimension table

CREATE TABLE hbase (
   `key` varchar, 
   `name` varchar,
    PRIMARY KEY (`key`), -- The rowkey of the table in the ApsaraDB for HBase Performance-enhanced Edition cluster. 
    PERIOD FOR SYSTEM_TIME --The identifier of a dimension table. 
   ) with (
    TYPE = 'cloudhbase',
    endpoint = 'host:port',-- The endpoint that is used by the HBase Java API to connect to the ApsaraDB for HBase Performance-enhanced Edition cluster.
    columnFamily = 'xxxxxx',
    userName  = 'root', -- The username that is used to connect to the ApsaraDB for HBase Performance-enhanced Edition cluster.
    password = 'root', -- The password that is used to connect to the ApsaraDB for HBase Performance-enhanced Edition cluster.
    tableName = 'xxxxxx'
);

Create a result table

create table liuxd_user_behavior_test_front (
    row_key varchar,
    from_topic varchar,
    origin_data varchar,
    record_create_time varchar,
    primary key (row_key)
) with (
    type = 'cloudhbase',
    endpoint = 'host:port', -- The endpoint that is used by the HBase Java API to connect to the ApsaraDB for HBase Performance-enhanced Edition cluster.
    userName  = 'root', -- The username that is used to connect to the ApsaraDB for HBase Performance-enhanced Edition cluster.
    password = 'root', -- The password that is used to connect to the ApsaraDB for HBase Performance-enhanced Edition cluster.
    columnFamily = '<yourColumnFamily>',
    tableName = '<yourTableName>',
    batchSize = '500'
)

Network connectivity

You can use a Realtime Compute for Apache Flink cluster to connect to an ApsaraDB for HBase Performance-enhanced Edition cluster. If the Realtime Compute for Apache Flink cluster and the ApsaraDB for HBase Performance-enhanced Edition cluster are deployed in the same virtual private cloud (VPC), they can communicate over the VPC. If they are not deployed in the same VPC, you can use a public endpoint to connect to the ApsaraDB for HBase Performance-enhanced Edition cluster. Before you connect to the ApsaraDB for HBase Performance-enhanced Edition cluster, make sure that the local IP addresses within the Realtime Compute for Apache Flink cluster are added to a whitelist of the ApsaraDB for HBase Performance-enhanced Edition cluster. For more information, see Configure a whitelist.