Updating a SQL Job

Sample Code

You can use the API to update Stream SQL jobs. The Stream SQL syntax is developed based on Apache Flink SQL. For details, see the Cloud Stream Service SQL Syntax Reference. Sample code is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import com.huaweicloud.cs.java.v1.client.ApiException;
import com.huaweicloud.cs.java.v1.JobApi;


JobApi apiInstance = new JobApi(apiClient);//apiClient is created when initializing a CS API client.
String xProjectId = "xProjectId_example"; // String | Project ID used for obtaining the token for the project.
UpdateSqlJobRequest body = new UpdateSqlJobRequest(); // UpdateSqlJobRequest | Submit a request for modifying the SQL job.
try {
    JobUpdateResponse result = apiInstance.updateSqlJob(xProjectId, body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling JobApi#updateSqlJob");
    System.err.println(e.getResponseBody());
    e.printStackTrace();
}

Parameter Description

Table 1 Parameters

Parameter

Mandatory

Type

Description

xProjectId

Yes

String

Project ID. This parameter is used to obtain the token for the project.

body

Yes

-

This parameter is used to submit a request for modifying the SQL job. For details about parameter types, see Table 2.

Table 2 Parameters involved in UpdateSqlJobRequest

Parameter

Mandatory

Type

Description

jobId

Yes

Integer

Job ID.

name

No

String

Job name.

desc

No

String

Job description.

clusterId

No

Integer

Resource ID of an exclusive cluster. Ensure that the current user has been authorized to use resources of the exclusive cluster.

sqlBody

No

String

Stream SQL statement, which includes at least the following three parts: source, query, and sink.

runMode

No

RunModeEnum

Job running mode. The options are as follows:

  • shared_cluster: A job is running on a shared cluster.
  • exclusive_cluster: A job is running on an exclusive cluster.
  • edge_node: A job is running on an edge node.

spuNumber

No

Integer

Number of SPUs selected for a job.

  • Minimum value: 2
  • Maximum value: 400
  • Default value: 5

parallelNumber

No

Integer

Number of parallel jobs set by a user.

  • Minimum value: 1
  • Maximum value: 2000
  • Default value: 1

checkpointEnabled

No

Boolean

Whether to enable the automatic job snapshot function. The default value is true.

  • true: The job log function is enabled.
  • false: The job log function is disabled.

checkpointMode

No

String

Snapshot mode. The following two options are available:

  • exactly_once
  • at_least_once

checkpointInterval

No

Integer

Snapshot interval, expressed by seconds. The default value is 10.

obsBucket

No

String

OBS path where users are authorized to save the snapshot. This parameter is valid only when checkpoint_enabled is set to true.

logEnabled

No

Boolean

Whether to enable the function of uploading job logs to users' OBS buckets. The default value is false.

smnTopic

No

String

SMN topic. If a job fails, the system will send a message to users who have subscribed to the SMN topic.

restartWhenException

No

Boolean

Whether to enable the function of restart upon exceptions. The default value is false.

idleStateRetention

No

Integer

Maximum retention duration for the idle state, which defines for how long the state of a key is retained without being updated before it is removed. The parameter value is expressed by seconds. The default value is 3600.

edgeGroupIds

No

String

List of edge computing group IDs that are separated by commas (,).

tags

No

String

Job tag.

sysEnterpriseProjectId

No

String

ID of the enterprise project to which a job belongs.

udfJarUrl

No

String

OBS address where the SQL job UDF JAR file is stored.

dirtyDataStrategy

No

String

Dirty data policy of a job.

  • 2:obs-wan-wulan3/jobs: Save.
  • 1: Trigger a job exception.
  • 0: Ignore.
Table 3 Parameters involved in JobUpdateResponse

Parameter

Mandatory

Type

Description

messageId

No

String

Message type ID.

message

No

String

Message content.

currentTime

No

Long

Current time, expressed by milliseconds.

payload

No

-

For details about parameter types, see Table 3.

Table 4 Parameters involved in JobUpdateTime

Parameter

Mandatory

Type

Description

updateTime

No

Integer

Job update time, expressed by milliseconds.