Querying the Job List
Sample Code
You can use the API to query the job list. The following parameters are involved in this API: name, status, show_detail, cursor, next, limit, and order. In this example, the query results are displayed in descending order and information about the jobs whose IDs are less than the value of cursor is displayed. Sample code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // 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.
String name = "name_example"; // String | Job name.
String status = "status_example"; // String | Job status code. For details, see CS documentation.
Integer clusterId = 56; // Integer | ID of an exclusive cluster of a user.
Boolean showDetail = false; // Boolean | Whether to return job details.
Long cursor = 789L; // Long | Job ID.
Boolean next = true; // Boolean | Whether to turn to the previous or next page.
Integer limit = 20; // Integer | Number of returned data records.
String order = "desc"; // String | Query result display. The query results can be displayed in ascending or descending order.
Long rootJobId = 789L; // Long | Edge parent job ID, which is used to query sub-jobs of a specified edge job. If this parameter is not specified, all non-edge jobs and edge parent jobs, instead of edge sub-jobs, are queried.
try {
QueryJobListResponse result = apiInstance.getJobs(xProjectId, name, status, clusterId, showDetail, cursor, next, limit, order, rootJobId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling JobApi#getJobs");
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. |
| name | No | String | Job name. |
| status | No | String | Job status code. The options are as follows:
|
| clusterId | No | Integer | ID of an exclusive cluster. |
| showDetail | No | Boolean | Whether to return the job details. The default value is false. |
| cursor | No | String | Job ID. |
| next | No | Boolean | Whether to switch to the next page. The default value is true. |
| limit | No | Integer | Number of returned data records. The default value is 20. |
| order | No | String | Query result display. Value asc indicates that the query results are displayed in ascending order, and value desc indicates that the query results are displayed in descending order. The default value is desc. |
| rootJobId | No | Integer | Edge parent job ID, which is used to query sub-jobs of a specified edge job. If this parameter is not specified, all non-edge jobs and edge parent jobs, instead of edge sub-jobs, are queried. |
| 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 | QueryJobListResponsePayload | For details about parameter types, see Table 3. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| total | No | Integer | Number of records in the query result. |
| jobs | No | Array | For details about parameter types, see Table 4. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| jobId | No | Long | Job ID. |
| name | No | String | Job name. |
| desc | No | String | Job description. |
| username | No | String | Username. This parameter is used only when show_detail is set to false. |
| jobType | No | String | Job type. |
| status | No | String | Job status. |
| statusDesc | No | String | Description of job status. |
| createTime | No | Long | Time when a job is created. |
| startTime | No | Long | Time when a job is enabled. 0 indicates that the job has not been enabled. |
| duration | No | Long | Job running duration, expressed by milliseconds. This parameter is used only when show_detail is set to false. |
| userId | No | String | ID of the user who creates the job. This parameter is used only when show_detail is set to true. |
| clusterId | No | Integer | Resource ID of an exclusive cluster. Ensure that the current user has been authorized to use resources of the exclusive cluster. This parameter is used only when show_detail is set to true. |
| projectId | No | String | ID of the project to which a job belongs. This parameter is used only when show_detail is set to true. |
| sqlBody | No | String | Stream SQL statement. This parameter is used only when show_detail is set to true. |
| runMode | No | RunModeEnum | Job running mode. This parameter is used only when show_detail is set to true.
|
| jobConfig | No | JobConfig | For details about the parameter, see Table 5. |
| jarUrl | No | String | OBS path of the JAR package. This parameter is used only when show_detail is set to true. |
| mainClass | No | String | OBS path where users are authorized to save the snapshot when checkpoint_enabled is set to true. This parameter is used only when show_detail is set to true. |
| args | No | String | Job running parameter of the JAR package. This parameter is used only when show_detail is set to true. |
| executionGraph | No | String | Job execution plan. This parameter is used only when show_detail is set to true. |
| updateTime | No | Long | Job update time. This parameter is used only when show_detail is set to true. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| checkpointEnabled | No | Boolean | Whether to enable the automatic job snapshot function. The default value is false.
|
| checkpointMode | No | String | Snapshot mode. The following two options are available: exactly_once and at_least_once. |
| checkpointInterval | No | Integer | Snapshot interval, expressed by seconds. |
| logEnabled | No | Boolean | Whether to enable the log storage function. |
| obsBucket | No | String | Name of an OBS bucket. |
| smnTopic | No | String | SMN topic name. |
| rootId | No | Integer | Parent job ID. |
| edgeGroupIds | No | String | List of edge computing group IDs that are separated by commas (,). |
| managerSpu | No | Integer | Number of SPUs of the management unit. |
| spuNumber | No | Integer | Number of SPUs selected by a user for a job. This parameter is used only when show_detail is set to true. |
| parallelNumber | No | Integer | Number of parallel jobs set by a user. This parameter is unique when show_detail is set to true. |
Last Article: Updating a User-Defined Job
Next Article: Viewing Job Details
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.