Flink connector configuration
This topic describes how to configure and use the Flink connector for Graph Compute (igraph).
Prepare the connector
Follow the instructions in Manage custom connectors to upload the igraph connector JAR file.
Once the upload is complete, you can view the configured properties on the connector details page.
Properties
|
Parameter |
Type |
Required |
Description |
|
endpoint |
string |
Yes |
The endpoint of the igraph instance. |
|
username |
string |
Yes |
The username to authenticate with the igraph instance. |
|
password |
string |
Yes |
The password to authenticate with the igraph instance. |
|
graph_name |
string |
Yes |
The name of the target graph in igraph. |
|
label_name |
string |
Yes |
The label of the target node or edge. |
|
pk_field |
string |
Yes |
Specifies the primary key field for the igraph sink. |
|
sk_field |
string |
No |
Specifies the sort key field for the igraph sink. |
|
cmd_field |
string |
Yes |
Specifies the record operation. Valid values: 'add' (for insertion) and 'delete' (for deletion). |
|
request_retry |
int |
No, default 0 |
The number of times to retry a failed request to igraph. |
|
dry_run |
boolean |
No, default false |
Specifies whether to run in test mode. If set to 'true', the connector logs operations but does not write data to igraph. |
|
async |
boolean |
No, default false |
Specifies whether to enable asynchronous mode to improve write performance. |
Flink SQL examples
Node (key-value)
--********************************************************************--
-- Author: jilong.yjl-75179-searchd***@searchdump.onaliyun.com
-- Created Time: 2022-11-09 10:43:36
-- Description: This example shows how to write node data from an SLS source to an igraph sink.
--********************************************************************--
CREATE TEMPORARY TABLE bhv_source (
cmd varchar,
content varchar,
gatewayTime bigint,
instnceId varchar,
pkey varchar
)
WITH (
'connector' = 'sls',
'endPoint' = 'cn-shanghai-intranet.log.aliyuncs.com',
'accessId' = 'xxx',
'accessKey' = 'xxx',
'startTime' = '2022-11-08 23:28:00',
'project' = 'igraph-cn-shanghai',
'logStore' = 'log',
'consumerGroup' = 'xxx',
'batchGetSize' = '1'
);
CREATE TEMPORARY TABLE igraph_sink (
cmd varchar,
content varchar,
gatewayTime bigint,
instnceId varchar,
pkey varchar
) with (
'connector' = 'igraph',
'endpoint' = 'igraph-cn-xxxx.igraph.aliyuncs.com',
'username' = '{igraphUserName}',
'password' = '{igraphPassword}',
'pk_field' = 'pkey',
'cmd_field' = 'cmd',
'graph_name' = '{graphName}',
'label_name' = '{nodeName}',
'dry_run' = 'false'
);
INSERT INTO igraph_sink
select * from bhv_source;
Edge (key-key-value)
--********************************************************************--
-- Author: jilong.yjl-75179-searchd***@searchdump.onaliyun.com
-- Created Time: 2022-11-09 10:43:36
-- Description: This example shows how to write edge data from an SLS source to an igraph sink.
--********************************************************************--
CREATE TEMPORARY TABLE bhv_source (
cmd varchar,
content varchar,
gatewayTime bigint,
instnceId varchar,
pkey varchar,
skey VARCHAR
)
WITH (
'connector' = 'sls',
'endPoint' = 'cn-shanghai-intranet.log.aliyuncs.com',
'accessId' = 'xxx',
'accessKey' = 'xxx',
'startTime' = '2022-11-08 23:28:00',
'project' = 'igraph-cn-shanghai',
'logStore' = 'log',
'consumerGroup' = 'xxx',
'batchGetSize' = '1'
);
CREATE TEMPORARY TABLE igraph_sink (
cmd varchar,
content varchar,
gatewayTime bigint,
instnceId varchar,
pkey varchar,
skey varchar
) with (
'connector' = 'igraph',
'endpoint' = 'igraph-cn-xxxx.igraph.aliyuncs.com',
'username' = '{igraphUserName}',
'password' = '{igraphPassword}',
'pk_field' = 'pkey',
'sk_field' = 'skey',
'cmd_field' = 'add',
'graph_name' = '{graphName}',
'label_name' = '{nodeName}',
'dry_run' = 'false'
);
INSERT INTO igraph_sink
select * from bhv_source;
Keep the following in mind:
-
The 'pk_field' parameter identifies the node or edge to be created, updated, or deleted.
-
By default, 'add' and 'update' operations require all table fields. To perform partial updates, an administrator must first enable this feature.
-
When deleting an edge, specifying only the 'pkey' removes all edges from the source node. Specifying both 'pkey' and 'skey' removes only the specific edge.
-
Use the 'graph_name' parameter to target a specific graph in your igraph instance.
-
Use the 'label_name' parameter to specify the node or edge type within the target graph.
-
Use the 'request_retry' parameter to prevent data loss from temporary network issues by retrying failed write operations.
-
Set 'dry_run' to 'true' to test your configuration. In this mode, the connector logs operations without writing data to igraph.