Updating a User-Defined Job

Sample Code

You can use the API to update user-defined jobs, which currently support the JAR format and run in exclusive clusters. Sample code is as follows:

 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
// Import classes:
import com.huaweicloud.cs.java.v1.client.ApiException;
import com.huaweicloud.cs.java.v1.JobApi;


JobApi apiInstance = new JobApi(apiClient);//apiClient is created when initializing a CS API client.
String xProjectId = "xProjectId_example"; // String | Project ID used for obtaining the token for the project.
Long jobId = 789L; // Long | Job ID.
Integer managerSpu = 56; // Integer | Number of management node SPUs selected by a user for a job. For user-defined Flink jobs, the parameter value is the number of Flink job managers. For user-defined Spark jobs, the parameter value is the number of Spark drivers.
String name = "name_example"; // String | Job name.
String desc = "desc_example"; // String | Job description.
Integer clusterId = 56; // Integer | Resource ID of an exclusive cluster. Ensure that the current user has been authorized to use resources of the exclusive cluster.
Integer spuNumber = 56; // Integer | Number of SPUs selected by a user for a job. You need to set this parameter when submitting a user-defined Flink job, but not when submitting a user-defined Spark job.
Integer parallelNumber = 56; // Integer | Number of parallel tasks selected by a user for a job. You need to set this parameter when submitting a user-defined Flink job, but not when submitting a user-defined Spark job.
Integer executorNumber = 56; // Integer | Number of executors selected by a user for a Spark job. You need to set this parameter when submitting a user-defined Spark job, but not when submitting a user-defined Flink job.
Integer executorSpu = 56; // Integer | Number of SPUs for each executor of a Spark job. You need to set this parameter when submitting a user-defined Spark job, but not when submitting a user-defined Flink job.
Boolean logEnabled = true; // Boolean | Whether to enable the job log function. Value true indicates that the job log function is enabled, and value false indicates that the job log function is disabled.
String obsBucket = "obsBucket_example"; // String | OBS path where users are authorized to save the snapshot. This parameter is valid only when log_enabled is set to true.
String smnTopic = "smnTopic_example"; // String | Whether CS pushes alarm information to the SMN topic if a job fails to work.
File jar = new File("/path/to/file.txt"); // File | JAR file uploaded by the user. This parameter has a higher priority than the jar_url parameter.
String jarUrl = "jarUrl_example"; // String | OBS path of the JAR package uploaded by the user.
File config = new File("/path/to/file.txt"); // File | Configuration file uploaded by the user. This parameter has a higher priority than the config_url parameter.
String configUrl = "configUrl_example"; // String | OBS path of the config package uploaded by the user.
String mainClass = "mainClass_example"; // String | Job main class.
String args = "args_example"; // String | Job main class arguments.
try {
    JobUpdateResponse result = apiInstance.updateJarJob(xProjectId, jobId, managerSpu, name, desc, clusterId, spuNumber, parallelNumber, executorNumber, executorSpu, logEnabled, obsBucket, smnTopic, jar, jarUrl, config, configUrl, mainClass, args);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling JobApi#updateJarJob");
    System.err.println(e.getResponseBody());
    e.printStackTrace();
}

Parameter Description

Table 1 Parameters

Parameter

Mandatory

Type

Description

xProjectId

Yes

String

Project ID. This parameter is used to obtain the token for the project.

jobId

Yes

Integer

Job ID.

name

No

String

Job name.

desc

No

String

Job description.

clusterId

No

Integer

Resource ID of an exclusive cluster. Ensure that the current user has been authorized to use resources of the exclusive cluster.

spuNumber

No

Integer

Number of SPUs selected by a user for a job. You need to set this parameter when submitting a user-defined Flink job, but not when submitting a user-defined Spark job.

  • Minimum value: 2
  • Maximum value: 400

managerSpu

Yes

Integer

Number of management node SPUs selected by a user for a job. For user-defined Flink jobs, the parameter value is the number of Flink job managers. For user-defined Spark jobs, the parameter value is the number of Spark drivers.

  • Minimum value: 1
  • Maximum value: 4

parallelNumber

No

Integer

Number of parallel tasks selected by a user for a job. You need to set this parameter when submitting a user-defined Flink job, but not when submitting a user-defined Spark job.

  • Minimum value: 1
  • Maximum value: 2000

executorNumber

No

Integer

Number of executors selected by a user for a Spark job. You need to set this parameter when submitting a user-defined Spark job, but not when submitting a user-defined Flink job.

  • Minimum value: 1
  • Maximum value: 100

executorSpu

No

Integer

Number of SPUs used by each executor in a job. You need to set this parameter when submitting a user-defined Spark job, but not when submitting a user-defined Flink job.

  • Minimum value: 1
  • Maximum value: 4

logEnabled

No

Boolean

Whether to enable the job log function. The default value is false.

  • true: Enabled.
  • false: Disabled.

obsBucket

No

String

OBS path where users are authorized to save the snapshot. This parameter is used only when log_enabled is set to true.

smnTopic

No

String

SMN topic. If a job fails, the system will send a message to users who have subscribed to the SMN topic.

jar

No

File

JAR file uploaded by the user. This parameter has a higher priority than the jar_url parameter.

jarUrl

No

String

OBS path of the JAR package uploaded by the user.

config

No

File

Configuration file uploaded by the user. This parameter has a higher priority than the config_url parameter.

configUrl

No

String

OBS path of the config package uploaded by the user.

mainClass

No

String

Job main class.

args

No

String

Job main class arguments.

restartWhenException

No

Boolean

Whether to enable restart upon exception. The default value is false.

tags

No

String

Job tag.

sysEnterpriseProjectId

No

String

ID of the enterprise project to which a job belongs.

Table 2 Parameters involved in JobUpdateResponse

Parameter

Mandatory

Type

Description

messageId

No

String

Message type ID.

message

No

String

Message content.

currentTime

No

Long

Current time, expressed by milliseconds.

payload

No

-

For details about parameter types, see Table 3.

Table 3 Parameters involved in JobUpdateTime

Parameter

Mandatory

Type

Description

updateTime

No

Integer

Job update time, expressed by milliseconds.