Updated on 2022-12-14 GMT+08:00

Querying a List of Jobs

Function

This API is used to query the job list in a specified MRS cluster.

URI

  • Format

    GET /v2/{project_id}/clusters/{cluster_id}/job-executions

  • Parameter description
    Table 1 URI parameters

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    The project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

    cluster_id

    Yes

    String

    The cluster ID. For details about how to obtain the cluster ID, see Obtaining a Cluster ID.

Request Parameters

Table 2 Request parameters

Parameter

Mandatory

Type

Description

job_name

No

String

The job name. The value can contain 1 to 128 characters. Only letters, numbers, hyphens (-), and underscores (_) are allowed.

job_id

No

String

The job ID. The value can contain 1 to 64 characters. Only letters, numbers, and hyphens (-) are allowed.

user

No

String

The username. The value can contain 1 to 32 characters. Only letters, numbers, hyphens (-), underscores (_), and periods (.) are allowed, but the value cannot start with a number.

job_type

No

String

The job type. Possible values:

  • MapReduce
  • SparkSubmit
  • SparkSubmit: Select this value when you call an API to query SparkPython jobs.
  • HiveScript
  • HiveSql
  • DistCp: imports and exports data.
  • SparkScript
  • SparkSql
  • Flink

job_state

No

String

The job execution status. Possible values:

  • FAILED: indicates that the job fails to be executed.
  • KILLED: indicates that the job is terminated.
  • New: indicates that the job is created.
  • NEW_SAVING: indicates that the job has been created and is being saved.
  • SUBMITTED: indicates that the job is submitted.
  • ACCEPTED: indicates that the job is accepted.
  • RUNNING: indicates that the job is running.
  • FINISHED: indicates that the job is completed.

job_result

No

String

The job execution result. Possible values:

  • FAILED: indicates that the job fails to be executed.
  • KILLED: indicates that the job is manually terminated during execution.
  • UNDEFINED: indicates that the job is being executed.
  • SUCCEEDED: indicates that the job has been successfully executed.

queue

No

String

The type of the resource queue used by a job. The value can contain 1 to 64 characters. Only letters, numbers, and hyphens (-) are allowed.

limit

No

String

The number of records displayed on each page in the returned result. The default value is 10.

offset

No

String

The default offset from which the job list starts to be queried is 1.

sort_by

No

String

The sorting mode of returned results. The default value is desc. Possible values:

  • asc: indicates that the returned results are ranked in ascending order.
  • desc: indicates that the returned results are ranked in descending order.

submitted_time_begin

No

Long

The UTC timestamp after which a job is submitted, in milliseconds, for example, 1562032041362.

submitted_time_end

No

Long

The UTC timestamp before which a job is submitted, in milliseconds, for example, 1562032041362.

Response Parameters

Status code: 202

Table 3 Response parameter

Parameter

Type

Description

job_list

Array of JobQueryBean objects

The job list. For details about the parameters, see Table 4.

Table 4 Job parameters

Parameter

Type

Description

job_id

String

The job ID.

user

String

The name of the user who submits a job.

job_name

String

The job name.

job_result

String

The final result of a job. Possible values:

  • FAILED: indicates that the job fails to be executed.
  • KILLED: indicates that the job is manually terminated during execution.
  • UNDEFINED: indicates that the job is being executed.
  • SUCCEEDED: indicates that the job has been successfully executed.

job_state

String

The job execution status. Possible values:

  • FAILED: indicates that the job fails to be executed.
  • KILLED: indicates that the job is terminated.
  • New: indicates that the job is created.
  • NEW_SAVING: indicates that the job has been created and is being saved.
  • SUBMITTED: indicates that the job is submitted.
  • ACCEPTED: indicates that the job is accepted.
  • RUNNING: indicates that the job is running.
  • FINISHED: indicates that the job is completed.

job_progress

Float

The job execution progress.

job_type

String

The job type. Possible values:

  • MapReduce
  • SparkSubmit: Select this value when you call an API to query SparkPython jobs.
  • HiveScript
  • HiveSql
  • DistCp: imports and exports data.
  • SparkScript
  • SparkSql
  • Flink

started_time

Long

The time when a job starts to execute, in milliseconds.

submitted_time

Long

The time when a job is submitted, in milliseconds.

finished_time

Long

The time when a job execution is completed, in milliseconds.

elapsed_time

Long

The job execution duration, in milliseconds.

arguments

String

The running parameters.

properties

String

The configuration parameter, which is used to configure -d parameters. The value can contain a maximum of 2,048 characters. Special characters (;|&>'<$!\\) are not allowed. This parameter can be left blank.

launcher_id

String

The actual job ID.

app_id

String

The actual job ID.

tracking_url

String

The URL for accessing logs. Currently, only SparkSubmit jobs support this parameter. This parameter accesses the Yarn Web UI via the EIP bound to the cluster. If the EIP is unbound from the cluster on the VPC console, the MRS service data is not updated in a timely manner and the access fails. In this case, you can bind the EIP to the cluster again to rectify the fault.

queue

String

The type of the resource queue used by a job.

Status code: 500

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

The error code.

error_msg

String

The error message.

Example

  • Example request

    Querying a list of jobs

    GET https://{endpoint}/v2/{project_id}/clusters/{cluster_id}/job-executions
  • Example response
    • Example of a successful response
      {
      
      	"job_list": [{
      			"job_id": "981374c1-85da-44ee-be32-edfb4fba776c",
      			"user": "xxxx",
      			"job_name": "SparkSubmitTset",
      			"job_result": "UNDEFINED",
      			"job_state": "ACCEPTED",
      			"job_progress": "0",
      			"job_type": "SparkSubmit",
      			"started_time": "0",
      			"submitted_time": 1564714763119,
      			"finished_time": "0",
      			"elapsed_time": "0",
      			"queue": "default",
      			"arguments": "[--class, --driver-memory, --executor-cores, --master, yarn-cluster, obs://obs-test/hadoop-mapreduce-examples-3.1.1.jar, dddd]",
      			"launcher_id": "application_1564622673393_0613",
      			"properties": "{}"
      		},
      		{
      			"job_id": "c54c8aa0-c277-4f83-8acc-521d85cfa32b",
      			"user": "xxxx",
      			"job_name": "SparkSubmitTset2",
      			"job_result": "UNDEFINED",
      			"job_state": "ACCEPTED",
      			"job_progress": "0",
      			"job_type": "SparkSubmit",
      			"started_time": "0",
      			"submitted_time": 1564714020099,
      			"finished_time": "0",
      			"elapsed_time": "0",
      			"queue": "default",
      			"arguments": "[--conf, yujjsjhe, --driver-memory, yueujdjjd, --master, yarn-cluster, obs://obs-test/hadoop-mapreduce-examples-3.1.1.jar]",
      			"launcher_id": "application_1564622673393_0611",
      			"properties": "{}"
      		}
      	]
      }
    • Example of a failed response
      {
      "error_msg": "Failed to query the job list."
      "error_code":"0166"
      }

Status Codes

See Status Codes.

Error Codes

See Error Codes.