调用ListJobs获取任务列表。
在调用该接口前,需要在POM文件添加以下依赖:
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-schedulerx2</artifactId>
<version>1.0.5</version>
</dependency>
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
Action | String | 是 | ListJobs |
系统规定参数。取值:ListJobs。 |
GroupId | String | 是 | DocTest.Group |
应用ID,在控制台的应用管理页面中获取。 |
Namespace | String | 是 | 1a72ecb1-b4cc-400a-a71b-20cdec9b**** |
命名空间,在控制台的命名空间页面中获取。 |
RegionId | String | 是 | cn-hangzhou |
地域ID。 |
NamespaceSource | String | 否 | schedulerx |
特殊第三方才需要填写。 |
JobName | String | 否 | helloword |
任务名称。 |
Status | String | 否 | 1 |
任务状态。
|
返回数据
示例
请求示例
http(s)://[Endpoint]/?Action=ListJobs
&GroupId=DocTest.Group
&Namespace=1a72ecb1-b4cc-400a-a71b-20cdec9b****
&RegionId=cn-hangzhou
&<公共请求参数>
正常返回示例
XML
格式
<ListJobsResponse>
<Message>namespace can not find namespace: 1a72ecb1-b4cc-400a-a71b-20cdec9b****, namespaceSource:null</Message>
<RequestId>71BCC0E3-64B2-4B63-A870-AFB64EBCB58B</RequestId>
<Data>
<Jobs>
<Status>1</Status>
<MaxAttempt>0</MaxAttempt>
<Parameters>test</Parameters>
<Description>Test</Description>
<Content>echo 'hello'</Content>
<JarUrl>https:doc***.oss-cn-hangzhou.aliyuncs.com/sc-****-D-0.0.2-SNAPSHOT.jar</JarUrl>
<MaxConcurrency>1</MaxConcurrency>
<ClassName>com.alibaba.schedulerx.test.helloworld</ClassName>
<AttemptInterval>30</AttemptInterval>
<ExecuteMode>standalone</ExecuteMode>
<JobId>99341</JobId>
<Name>helloworld</Name>
<MapTaskXAttrs>
<TaskAttemptInterval>0</TaskAttemptInterval>
<QueueSize>10000</QueueSize>
<DispatcherSize>5</DispatcherSize>
<PageSize>100</PageSize>
<TaskMaxAttempt>0</TaskMaxAttempt>
<ConsumerSize>5</ConsumerSize>
</MapTaskXAttrs>
<TimeConfig>
<Calendar>工作日</Calendar>
<TimeExpression>0 0/10 * * * ?</TimeExpression>
<DataOffset>0</DataOffset>
<TimeType>1</TimeType>
</TimeConfig>
<JobMonitorInfo>
<ContactInfo>
<UserName>userA</UserName>
<UserPhone>1381111****</UserPhone>
</ContactInfo>
<MonitorConfig>
<TimeoutEnable>true</TimeoutEnable>
<Timeout>12300</Timeout>
<FailEnable>true</FailEnable>
<SendChannel>sms</SendChannel>
<TimeoutKillEnable>false</TimeoutKillEnable>
</MonitorConfig>
</JobMonitorInfo>
</Jobs>
</Data>
<Code>200</Code>
<Success>true</Success>
</ListJobsResponse>
JSON
格式
{
"Message": "namespace can not find namespace: 1a72ecb1-b4cc-400a-a71b-20cdec9b****, namespaceSource:null",
"RequestId": "71BCC0E3-64B2-4B63-A870-AFB64EBCB58B",
"Data": {
"Jobs": {
"Status": 1,
"MaxAttempt": 0,
"Parameters": "test",
"Description": "Test",
"Content": "echo 'hello'",
"JarUrl": "https:doc***.oss-cn-hangzhou.aliyuncs.com/sc-****-D-0.0.2-SNAPSHOT.jar",
"MaxConcurrency": 1,
"ClassName": "com.alibaba.schedulerx.test.helloworld",
"AttemptInterval": 30,
"ExecuteMode": "standalone",
"JobId": 99341,
"Name": "helloworld",
"MapTaskXAttrs": {
"TaskAttemptInterval": 0,
"QueueSize": 10000,
"DispatcherSize": 5,
"PageSize": 100,
"TaskMaxAttempt": 0,
"ConsumerSize": 5
},
"TimeConfig": {
"Calendar": "工作日",
"TimeExpression": "0 0/10 * * * ?",
"DataOffset": 0,
"TimeType": 1
},
"JobMonitorInfo": {
"ContactInfo": {
"UserName": "userA",
"UserPhone": "1381111****"
},
"MonitorConfig": {
"TimeoutEnable": true,
"Timeout": 12300,
"FailEnable": true,
"SendChannel": "sms",
"TimeoutKillEnable": false
}
}
}
},
"Code": 200,
"Success": true
}
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) {
//OpenAPI的接入点,具体查看支持地域列表以及购买机器地域填写。
String regionId = "cn-hangzhou";
//鉴权使用的AccessKey ID,由阿里云官网控制台获取。
String accessKeyId = "XXXXXXXX";
//鉴权使用的AccessKey Secret,由阿里云官网控制台获取。
String accessKeySecret = "XXXXXXXX";
//产品名称
String productName ="schedulerx2";
//对照支持地域列表选择Domain填写
String domain ="schedulerx.cn.hangzhou.aliyuncs.com";
//构建OpenAPI客户端。
DefaultProfile.addEndpoint(regionId, productName, domain);
DefaultProfile defaultProfile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
DefaultAcsClient client = new DefaultAcsClient(defaultProfile);
ListJobsRequest request = new ListJobsRequest();
//命名空间。
request.setNamespace("433d8b23-06e9-408c-aaaa-90d4d1b****");
//应用ID。
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();
}
}
}