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
| 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. |
| 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:
|
| spuNumber | No | Integer | Number of SPUs selected for a job.
|
| parallelNumber | No | Integer | Number of parallel jobs set by a user.
|
| checkpointEnabled | No | Boolean | Whether to enable the automatic job snapshot function. The default value is true.
|
| checkpointMode | No | String | Snapshot mode. The following two options are available:
|
| 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.
|
| 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. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| updateTime | No | Integer | Job update time, expressed by milliseconds. |
Last Article: Creating a User-Defined Job
Next Article: Updating a User-Defined Job
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.