Stopping a Job

Sample Code

You can use the API to stop a running job. Sample code is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
// Import classes:
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.
Long jobId = 789L; // Long | Job ID.
Boolean triggerSavePoint = false; // Boolean | 
try {
    GlobalResponse result = apiInstance.stopJob(xProjectId, jobId, triggerSavePoint);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling JobApi#stopJob");
    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.

jobId

Yes

Integer

Job ID.

triggerSavePoint

No

Boolean

Whether to create a savepoint for a job to store the job status information before stopping it.

  • If this parameter is set to true, a savepoint is created.
  • If this parameter is set to false, no savepoint is created. The default value is false.
Table 2 Parameters involved in GlobalResponse

Parameter

Mandatory

Type

Description

messageId

No

String

Message type ID.

message

No

String

Message content.

currentTime

No

Long

Current time, expressed by milliseconds.