All Products
Search
Document Center

SchedulerX:ListJobs

Last Updated:Dec 10, 2024

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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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.
OperationAccess levelResource typeCondition keyAssociated operation
edas:ReadSchedulerxJobQueryget
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
GroupIdstringYes

The ID of the application. You can obtain the application ID on the Application Management page in the SchedulerX console.

DocTest.Group
NamespacestringYes

The ID of the namespace. You can obtain the namespace ID on the Namespace page in the SchedulerX console.

1a72ecb1-b4cc-400a-a71b-20cdec9b****
NamespaceSourcestringNo

The source of the namespace. This parameter is required only for a special third party.

schedulerx
RegionIdstringYes

The ID of the region.

cn-hangzhou
JobNamestringNo

The name of the job.

helloword
StatusstringNo

Specifies whether to enable the job. Valid values:

  • 0: disables the job.
  • 1: enables the job.
1

Response parameters

ParameterTypeDescriptionExample
object
Codeinteger

The HTTP status code that is returned.

200
Messagestring

The error message that is returned if an error occurs.

namespace can not find namespace: 1a72ecb1-b4cc-400a-a71b-20cdec9b****, namespaceSource:null
RequestIdstring

The ID of the request.

71BCC0E3-64B2-4B63-A870-AFB64EBCB58B
Successboolean

Indicates whether the call is successful. Valid values:

  • true: The call is successful.
  • false: The call fails.
true
Dataobject

The information about the jobs.

Jobsarray<object>

The jobs and their details.

Jobobject
Statusinteger

Indicates whether the job is enabled. Valid values:

  • 1: The job is enabled and can be triggered.
  • 0: The job is disabled and cannot be triggered.
1
JarUrlstring

The full path to which a JAR package is uploaded in Object Storage Service (OSS).

https:doc***.oss-cn-hangzhou.aliyuncs.com/sc-****-D-0.0.2-SNAPSHOT.jar
MaxAttemptinteger

The maximum number of retries after a job failure. This parameter is specified based on your business requirements. Default value: 0.

0
Parametersstring

The user-defined parameters. These parameters can be obtained when the job is running.

test
Descriptionstring

The description of the job.

Test
JobIdlong

The ID of the job.

99341
ExecuteModestring

The execution mode of the job. Valid values:

  • standalone: The job runs in standalone mode.
  • broadcast: The job runs in broadcast mode.
  • parallel: The job runs in parallel computing mode.
  • grid: The job runs in memory grid mode.
  • batch: The job runs in grid computing mode.
  • shard: The job runs in multipart mode.
standalone
MaxConcurrencystring

The maximum number of instances that can concurrently run for the job. Default value: 1. A value of 1 indicates that if the last triggered instance is running, the next instance is not triggered even if the scheduled point in time for running the instance is reached.

1
Namestring

The name of the job.

helloworld
ClassNamestring

The full path of the job interface class. This parameter is returned only for a Java job.

com.alibaba.schedulerx.test.helloworld
Contentstring

The script of the job. This parameter is returned only for a Python, Shell, or Go job.

echo 'hello'
JobTypestring

The type of the job.

java
AttemptIntervalinteger

The interval at which the system retries to run the job after a job failure. Unit: seconds. Default value: 30.

30
MapTaskXAttrsobject

The advanced configurations of the job. The parameters are returned only if the value of the ExecuteMode parameter is parallel, grid, or batch.

TaskMaxAttemptinteger

The number of retries after a task failure.

0
TaskAttemptIntervalinteger

The interval at which the system retries to run the task after a task failure.

0
ConsumerSizeinteger

The number of threads that are triggered by a standalone job at a time. Default value: 5.

5
QueueSizeinteger

The maximum number of task queues that can be cached. Default value: 10000.

10000
DispatcherSizeinteger

The number of task distribution threads. Default value: 5.

5
PageSizeinteger

The number of tasks that are pulled by a parallel job at a time. Default value: 100.

100
TimeConfigobject

The time configurations.

Calendarstring

If the TimeType parameter is set to cron, you can specify custom calendar days.

Business days
TimeTypeinteger

The method that is used to specify the time when to schedule the job. Valid values:

  • 1: cron
  • 3: fix_rate
  • 4: second_delay
  • 100: api
1
DataOffsetinteger

The time offset if the TimeType parameter is set to cron. Unit: seconds.

0
TimeExpressionstring

The time expression. Valid values:

  • api: indicates that no time expression is used to specify the time when to schedule the job.
  • fix_rate: indicates that the job is triggered at a fixed frequency. For example, a value of 30 indicates that the job is triggered every 30 seconds.
  • cron: indicates that a standard CRON expression is used to specify the time when to schedule the job.
  • second_delay: indicates that the job is triggered after a fixed delay. Valid values: 1 to 60. Unit: seconds.
0 0/10 * * * ?
JobMonitorInfoobject

The monitoring information of the job.

ContactInfoarray<object>

The contact information.

ContactInfoobject
UserPhonestring

The mobile number of the user.

1381111****
UserNamestring

The username.

userA
Dingstring

The webhook URL of the DingTalk chatbot.

https://oapi.dingtalk.com/robot/send?access_token=**********
UserMailstring

The email address of the user.

user@mail.com
MonitorConfigobject

The configurations of the alerting feature and the alert threshold.

Timeoutlong

The timeout threshold. Unit: seconds. Default value: 7200.

12300
SendChannelstring

The method that is used to send an alert notification. Only Short Message Service (SMS) is supported.

sms
TimeoutKillEnableboolean

Indicates whether the feature of stopping job triggering upon a timeout is enabled. By default, the feature is disabled.

  • true: The feature is enabled.
  • false: The feature is disabled.
false
TimeoutEnableboolean

Indicates whether the feature of generating an alert upon a timeout is enabled. Valid values:

  • true: The feature is enabled.
  • false: The feature is disabled.
true
FailEnableboolean

Indicates whether the feature of generating an alert upon a failure is enabled. Valid values:

  • true: The feature is enabled.
  • false: The feature is disabled.
true
MissWorkerEnableboolean

Indicates whether the feature of generating an alert when no machine is available for running the job is enabled.

true
XAttrsstring

The extended fields.

{"pageSize":5,"queueSize":10,"consumerSize":5,"dispatcherSize":5,"taskMaxAttempt":0,"taskAttemptInterval":0,"globalConsumerSize":1000,"taskDispatchMode":"push"}

Examples

Sample success responses

JSONformat

{
  "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 timeSummary of changesOperation
2024-10-18The response structure of the API has changedView Change Details
2022-12-26The internal configuration of the API is changed, but the call is not affectedView Change Details
2022-11-02The response structure of the API has changedView 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();
        }
    }
    
}