Queries jobs.
Operation description
Before you call this operation, you must add the following dependency to the pom.xml file:
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-schedulerx2</artifactId>
<version>1.0.5</version>
</dependency>
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
edas:ReadSchedulerxJobQuery | get | *All Resources * |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
GroupId | string | Yes | The ID of the application. You can obtain the application ID on the Application Management page in the SchedulerX console. | DocTest.Group |
Namespace | string | Yes | The ID of the namespace. You can obtain the namespace ID on the Namespace page in the SchedulerX console. | 1a72ecb1-b4cc-400a-a71b-20cdec9b**** |
NamespaceSource | string | No | The source of the namespace. This parameter is required only for a special third party. | schedulerx |
RegionId | string | Yes | The ID of the region. | cn-hangzhou |
JobName | string | No | The name of the job. | helloword |
Status | string | No | Specifies whether to enable the job. Valid values:
| 1 |
Response parameters
Examples
Sample success responses
JSON
format
{
"Code": 200,
"Message": "namespace can not find namespace: 1a72ecb1-b4cc-400a-a71b-20cdec9b****, namespaceSource:null",
"RequestId": "71BCC0E3-64B2-4B63-A870-AFB64EBCB58B",
"Success": true,
"Data": {
"Jobs": [
{
"Status": 1,
"JarUrl": "https:doc***.oss-cn-hangzhou.aliyuncs.com/sc-****-D-0.0.2-SNAPSHOT.jar",
"MaxAttempt": 0,
"Parameters": "test",
"Description": "Test",
"JobId": 99341,
"ExecuteMode": "standalone",
"MaxConcurrency": "1",
"Name": "helloworld",
"ClassName": "com.alibaba.schedulerx.test.helloworld",
"Content": "echo 'hello'",
"JobType": "java",
"AttemptInterval": 30,
"MapTaskXAttrs": {
"TaskMaxAttempt": 0,
"TaskAttemptInterval": 0,
"ConsumerSize": 5,
"QueueSize": 10000,
"DispatcherSize": 5,
"PageSize": 100
},
"TimeConfig": {
"Calendar": "Business days\n",
"TimeType": 1,
"DataOffset": 0,
"TimeExpression": "0 0/10 * * * ?"
},
"JobMonitorInfo": {
"ContactInfo": [
{
"UserPhone": "1381111****",
"UserName": "userA",
"Ding": "https://oapi.dingtalk.com/robot/send?access_token=**********",
"UserMail": "user@mail.com"
}
],
"MonitorConfig": {
"Timeout": 12300,
"SendChannel": "sms",
"TimeoutKillEnable": false,
"TimeoutEnable": true,
"FailEnable": true,
"MissWorkerEnable": true
}
},
"XAttrs": "{\"pageSize\":5,\"queueSize\":10,\"consumerSize\":5,\"dispatcherSize\":5,\"taskMaxAttempt\":0,\"taskAttemptInterval\":0,\"globalConsumerSize\":1000,\"taskDispatchMode\":\"push\"}"
}
]
}
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-10-18 | The response structure of the API has changed | View Change Details |
2022-12-26 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
2022-11-02 | The response structure of the API has changed | View Change Details |
Demo
package com.alibaba.schedulerx.pop;
import java.util.List;
import com.alibaba.schedulerx.common.util.JsonUtil;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.schedulerx2.model.v20190430.ListJobsRequest;
import com.aliyuncs.schedulerx2.model.v20190430.ListJobsResponse;
import com.aliyuncs.schedulerx2.model.v20190430.ListJobsResponse.Data.Job;
public class TestListJobs {
public static void main(String[] args) {
// The ID of the region. Enter a value by referring to the Endpoints topic or based on the region in which you purchased the service.
String regionId = "cn-hangzhou";
// The AccessKey ID that is used for authentication. You can obtain the AccessKey ID in the Resource Access Management (RAM) console.
String accessKeyId = "XXXXXXXX";
// The AccessKey secret that is used for authentication. You can obtain the AccessKey secret in the RAM console.
String accessKeySecret = "XXXXXXXX";
// The name of the service.
String productName ="schedulerx2";
// The domain. Enter a domain by referring to the Endpoints topic.
String domain ="schedulerx.cn.hangzhou.aliyuncs.com";
// Build an API client.
DefaultProfile.addEndpoint(regionId, productName, domain);
DefaultProfile defaultProfile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
DefaultAcsClient client = new DefaultAcsClient(defaultProfile);
ListJobsRequest request = new ListJobsRequest();
// The ID of the namespace.
request.setNamespace("433d8b23-06e9-408c-aaaa-90d4d1b****");
// The ID of the application.
request.setGroupId("DocTest.Group");
ListJobsResponse response;
try {
response = client.getAcsResponse(request);
if (!response.getSuccess()) {
System.out.println(JsonUtil.toJson(response));
System.out.println(response.getCode());
} else {
System.out.println(JsonUtil.toJson(response));
List<Job> jobs = response.getData().getJobs();
for (Job job : jobs) {
System.out.println("jobId:" + job.getJobId() + ", name:" + job.getName() + ", status=" + job.getStatus());
}
}
} catch (ServerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}