更新时间:2025-05-09 GMT+08:00
分享

重跑作业实例

功能介绍

支持重跑作业实例以及上下游的作业实例。

调用方法

请参见如何调用API

URI

POST /v2/{project_id}/factory/jobs/{job_name}/instances/retry

表1 路径参数

参数

是否必选

参数类型

描述

job_name

String

当前作业名称

project_id

String

项目ID,获取方法请参见项目ID和账号ID

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

IAM Token,通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值),使用Token认证时必选,最小长度:0,最大长度:4096。

workspace

String

工作空间ID,获取方法请参见实例ID和工作空间ID

Content-Type

String

默认值:application/json;charset=UTF-8

可选,有Body体的情况下必选,没有Body体则无需填写和校验。

X-Project-Id

String

project_id,项目编号。获取方法请参见项目ID和账号ID

多project场景采用AK/SK认证的接口请求,则该字段必选。

表3 请求Body参数

参数

是否必选

参数类型

描述

retry_location

String

重跑开始位置,取值有firstNode、errorNode和specifiedNode。

node_name

String

节点名称。

retry_task_version

String

使用的作业参数,取值有original_version和current_version。

ignore_obs_monitor

Boolean

是否忽略obs监听,默认为true。

task_retrys

Array of task_retrys objects

作业实例重跑参数,当重跑当前实例类型时,需要指定该参数的重跑信息,重跑当前作业及其上下游作业实例类型不需要指定该参数。

begin_time

Long

实例开始时间,当重跑当前作业及其上下游作业实例类型时,该参数有效。

end_time

Long

实例结束时间,当重跑当前作业及其上下游作业实例类型时,该参数有效。

jobs

Array of jobs objects

作业实例重跑参数,当重跑当前作业及其上下游作业实例类型时,需要指定该参数的重跑信息,重跑当前实例类型不需要指定该参数。

concurrent

Integer

并行度,当重跑当前作业及其上下游作业实例类型时,该参数有效,默认值为1,取值范围为1到128。

表4 task_retrys

参数

是否必选

参数类型

描述

job_id

Long

作业id,当前重跑实例的作业id。

plan_time

Long

实例计划时间,13位时间戳,可通过查询作业实例列表接口获取。

submit_time

Long

实例提交时间,13位时间戳,可通过查询作业实例列表接口获取。

表5 jobs

参数

是否必选

参数类型

描述

job_name

String

重跑的作业名称。

workspace_id

String

工作空间id

响应参数

状态码:200

作业重跑成功,无响应信息

状态码:400

表6 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误描述。

请求示例

  • 重跑作业为test_job_name的当前实例。

    POST /v2/62099355b894428e8916573ae635f1f9/factory/jobs/test_job_name/instances/retry
    
    {
      "retry_location" : "errorNode",
      "retry_task_version" : "original_version",
      "ignore_obs_monitor" : true,
      "task_retrys" : [ {
        "job_id" : 917567,
        "plan_time" : 1732601580000,
        "submit_time" : 1732239754684
      } ]
    }
  • 重跑作业为test_job_name的当前作业及其上下游作业实例。

    POST /v2/62099355b894428e8916573ae635f1f9/factory/jobs/test_job_name/instances/retry
    
    {
      "retry_location" : "errorNode",
      "retry_task_version" : "current_version",
      "ignore_obs_monitor" : true,
      "begin_time" : 1732608520000,
      "end_time" : 1732612120000,
      "jobs" : [ {
        "job_name" : "job_test_smn2",
        "workspace_id" : "62fbba734e634c5087656fc3ff7adf34"
      } ],
      "concurrent" : 2
    }

响应示例

状态码:400

作业重跑失败的响应信息。

{
  "error_code" : "DLF.1000",
  "error_msg" : "Failed to find the job."
}

SDK代码示例

SDK代码示例如下。

  • 重跑作业为test_job_name的当前实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.dataartsstudio.v1.region.DataArtsStudioRegion;
    import com.huaweicloud.sdk.dataartsstudio.v1.*;
    import com.huaweicloud.sdk.dataartsstudio.v1.model.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class RetryFactoryJobInstanceSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            DataArtsStudioClient client = DataArtsStudioClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(DataArtsStudioRegion.valueOf("<YOUR REGION>"))
                    .build();
            RetryFactoryJobInstanceRequest request = new RetryFactoryJobInstanceRequest();
            request.withJobName("{job_name}");
            RetryFactoryJobInstanceBody body = new RetryFactoryJobInstanceBody();
            List<RetryFactoryJobInstanceBodyTaskRetrys> listbodyTaskRetrys = new ArrayList<>();
            listbodyTaskRetrys.add(
                new RetryFactoryJobInstanceBodyTaskRetrys()
                    .withJobId(917567L)
                    .withPlanTime(1732601580000L)
                    .withSubmitTime(1732239754684L)
            );
            body.withTaskRetrys(listbodyTaskRetrys);
            body.withIgnoreObsMonitor(true);
            body.withRetryTaskVersion("original_version");
            body.withRetryLocation("errorNode");
            request.withBody(body);
            try {
                RetryFactoryJobInstanceResponse response = client.retryFactoryJobInstance(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • 重跑作业为test_job_name的当前作业及其上下游作业实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    package com.huaweicloud.sdk.test;
    
    import com.huaweicloud.sdk.core.auth.ICredential;
    import com.huaweicloud.sdk.core.auth.BasicCredentials;
    import com.huaweicloud.sdk.core.exception.ConnectionException;
    import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
    import com.huaweicloud.sdk.core.exception.ServiceResponseException;
    import com.huaweicloud.sdk.dataartsstudio.v1.region.DataArtsStudioRegion;
    import com.huaweicloud.sdk.dataartsstudio.v1.*;
    import com.huaweicloud.sdk.dataartsstudio.v1.model.*;
    
    import java.util.List;
    import java.util.ArrayList;
    
    public class RetryFactoryJobInstanceSolution {
    
        public static void main(String[] args) {
            // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
            // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
            String ak = System.getenv("CLOUD_SDK_AK");
            String sk = System.getenv("CLOUD_SDK_SK");
            String projectId = "{project_id}";
    
            ICredential auth = new BasicCredentials()
                    .withProjectId(projectId)
                    .withAk(ak)
                    .withSk(sk);
    
            DataArtsStudioClient client = DataArtsStudioClient.newBuilder()
                    .withCredential(auth)
                    .withRegion(DataArtsStudioRegion.valueOf("<YOUR REGION>"))
                    .build();
            RetryFactoryJobInstanceRequest request = new RetryFactoryJobInstanceRequest();
            request.withJobName("{job_name}");
            RetryFactoryJobInstanceBody body = new RetryFactoryJobInstanceBody();
            List<RetryFactoryJobInstanceBodyJobs> listbodyJobs = new ArrayList<>();
            listbodyJobs.add(
                new RetryFactoryJobInstanceBodyJobs()
                    .withJobName("job_test_smn2")
                    .withWorkspaceId("62fbba734e634c5087656fc3ff7adf34")
            );
            body.withConcurrent(2);
            body.withJobs(listbodyJobs);
            body.withEndTime(1732612120000L);
            body.withBeginTime(1732608520000L);
            body.withIgnoreObsMonitor(true);
            body.withRetryTaskVersion("current_version");
            body.withRetryLocation("errorNode");
            request.withBody(body);
            try {
                RetryFactoryJobInstanceResponse response = client.retryFactoryJobInstance(request);
                System.out.println(response.toString());
            } catch (ConnectionException e) {
                e.printStackTrace();
            } catch (RequestTimeoutException e) {
                e.printStackTrace();
            } catch (ServiceResponseException e) {
                e.printStackTrace();
                System.out.println(e.getHttpStatusCode());
                System.out.println(e.getRequestId());
                System.out.println(e.getErrorCode());
                System.out.println(e.getErrorMsg());
            }
        }
    }
    
  • 重跑作业为test_job_name的当前实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkdataartsstudio.v1.region.dataartsstudio_region import DataArtsStudioRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkdataartsstudio.v1 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = DataArtsStudioClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(DataArtsStudioRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = RetryFactoryJobInstanceRequest()
            request.job_name = "{job_name}"
            listTaskRetrysbody = [
                RetryFactoryJobInstanceBodyTaskRetrys(
                    job_id=917567,
                    plan_time=1732601580000,
                    submit_time=1732239754684
                )
            ]
            request.body = RetryFactoryJobInstanceBody(
                task_retrys=listTaskRetrysbody,
                ignore_obs_monitor=True,
                retry_task_version="original_version",
                retry_location="errorNode"
            )
            response = client.retry_factory_job_instance(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • 重跑作业为test_job_name的当前作业及其上下游作业实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    # coding: utf-8
    
    import os
    from huaweicloudsdkcore.auth.credentials import BasicCredentials
    from huaweicloudsdkdataartsstudio.v1.region.dataartsstudio_region import DataArtsStudioRegion
    from huaweicloudsdkcore.exceptions import exceptions
    from huaweicloudsdkdataartsstudio.v1 import *
    
    if __name__ == "__main__":
        # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak = os.environ["CLOUD_SDK_AK"]
        sk = os.environ["CLOUD_SDK_SK"]
        projectId = "{project_id}"
    
        credentials = BasicCredentials(ak, sk, projectId)
    
        client = DataArtsStudioClient.new_builder() \
            .with_credentials(credentials) \
            .with_region(DataArtsStudioRegion.value_of("<YOUR REGION>")) \
            .build()
    
        try:
            request = RetryFactoryJobInstanceRequest()
            request.job_name = "{job_name}"
            listJobsbody = [
                RetryFactoryJobInstanceBodyJobs(
                    job_name="job_test_smn2",
                    workspace_id="62fbba734e634c5087656fc3ff7adf34"
                )
            ]
            request.body = RetryFactoryJobInstanceBody(
                concurrent=2,
                jobs=listJobsbody,
                end_time=1732612120000,
                begin_time=1732608520000,
                ignore_obs_monitor=True,
                retry_task_version="current_version",
                retry_location="errorNode"
            )
            response = client.retry_factory_job_instance(request)
            print(response)
        except exceptions.ClientRequestException as e:
            print(e.status_code)
            print(e.request_id)
            print(e.error_code)
            print(e.error_msg)
    
  • 重跑作业为test_job_name的当前实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        dataartsstudio "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := dataartsstudio.NewDataArtsStudioClient(
            dataartsstudio.DataArtsStudioClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.RetryFactoryJobInstanceRequest{}
    	request.JobName = "{job_name}"
    	var listTaskRetrysbody = []model.RetryFactoryJobInstanceBodyTaskRetrys{
            {
                JobId: int64(917567),
                PlanTime: int64(1732601580000),
                SubmitTime: int64(1732239754684),
            },
        }
    	ignoreObsMonitorRetryFactoryJobInstanceBody:= true
    	request.Body = &model.RetryFactoryJobInstanceBody{
    		TaskRetrys: &listTaskRetrysbody,
    		IgnoreObsMonitor: &ignoreObsMonitorRetryFactoryJobInstanceBody,
    		RetryTaskVersion: "original_version",
    		RetryLocation: "errorNode",
    	}
    	response, err := client.RetryFactoryJobInstance(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    
  • 重跑作业为test_job_name的当前作业及其上下游作业实例。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    package main
    
    import (
    	"fmt"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
        dataartsstudio "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1"
    	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/model"
        region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/region"
    )
    
    func main() {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        ak := os.Getenv("CLOUD_SDK_AK")
        sk := os.Getenv("CLOUD_SDK_SK")
        projectId := "{project_id}"
    
        auth := basic.NewCredentialsBuilder().
            WithAk(ak).
            WithSk(sk).
            WithProjectId(projectId).
            Build()
    
        client := dataartsstudio.NewDataArtsStudioClient(
            dataartsstudio.DataArtsStudioClientBuilder().
                WithRegion(region.ValueOf("<YOUR REGION>")).
                WithCredential(auth).
                Build())
    
        request := &model.RetryFactoryJobInstanceRequest{}
    	request.JobName = "{job_name}"
    	var listJobsbody = []model.RetryFactoryJobInstanceBodyJobs{
            {
                JobName: "job_test_smn2",
                WorkspaceId: "62fbba734e634c5087656fc3ff7adf34",
            },
        }
    	concurrentRetryFactoryJobInstanceBody:= int32(2)
    	endTimeRetryFactoryJobInstanceBody:= int64(1732612120000)
    	beginTimeRetryFactoryJobInstanceBody:= int64(1732608520000)
    	ignoreObsMonitorRetryFactoryJobInstanceBody:= true
    	request.Body = &model.RetryFactoryJobInstanceBody{
    		Concurrent: &concurrentRetryFactoryJobInstanceBody,
    		Jobs: &listJobsbody,
    		EndTime: &endTimeRetryFactoryJobInstanceBody,
    		BeginTime: &beginTimeRetryFactoryJobInstanceBody,
    		IgnoreObsMonitor: &ignoreObsMonitorRetryFactoryJobInstanceBody,
    		RetryTaskVersion: "current_version",
    		RetryLocation: "errorNode",
    	}
    	response, err := client.RetryFactoryJobInstance(request)
    	if err == nil {
            fmt.Printf("%+v\n", response)
        } else {
            fmt.Println(err)
        }
    }
    

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

作业重跑成功,无响应信息

400

作业重跑失败的响应信息。

相关文档

    OSZAR »