El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Adding and Executing a Job

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

Function

This API is used to add and submit a job in an MRS cluster.

NOTE:
  • On the Dashboard tab page of the cluster details page, click Click to synchronize on the right side of IAM User Sync to synchronize IAM users. Then submit a job through this API.

URI

  • Format

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

  • Parameter description
    Table 1 URI parameter description

    Parameter

    Mandatory

    Description

    project_id

    Yes

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

    cluster_id

    Yes

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

Request

Table 2 Request parameter description

Parameter

Mandatory

Type

Description

job_type

Yes

String

Type of a job.

  • MapReduce
  • SparkSubmit
  • SparkPython: Example request of a SparkPython job (Jobs of this type will be converted to SparkSubmit jobs for submission. The job type is displayed as SparkSubmit on the MRS console. Select SparkSubmit when you call an API to query the job list.)
  • HiveScript
  • HiveSql
  • DistCp, importing and exporting data
  • SparkScript
  • SparkSql
  • Flink
NOTE:

Spark, Hive, and Flink jobs can be added to only clusters that include Spark, Hive, and Flink components.

job_name

Yes

String

Job name. It contains 1 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.

NOTE:

Identical job names are allowed but not recommended.

arguments

No

Array

Key parameter for program execution. The parameter is specified by the function of the user's program. MRS is only responsible for loading the parameter.

The parameter contains a maximum of 4,096 characters, excluding special characters such as ;|&>'<$, and can be left blank.

NOTE:
  • If you enter a parameter with sensitive information (such as the login password), the parameter may be exposed in the job details display and log printing. Exercise caution when performing this operation.
  • For MRS 3.x or later, a file path on OBS can start with obs://. To use this format to submit HiveScript or HiveSQL jobs, choose Components > Hive > Service Configuration on the cluster details page. Switch Basic to All, and search for core.site.customized.configs. Add the endpoint configuration item (fs.obs.endpoint) of OBS and enter the endpoint corresponding to OBS in Value. Obtain the value from .

properties

No

Object

Program system parameter.

The parameter contains a maximum of 2,048 characters, excluding special characters such as ><|'`&!\, and can be left blank.

Response

Table 3 Response parameter description

Parameter

Type

Description

job_submit_result

Object

Job execution result

job_id

String

Job ID

state

String

Job submission status.

  • COMPLETE: The job is submitted.
  • JOBSTAT_SUBMIT_FAILED: Failed to submit the job.

error_msg

String

Error message

error_code

String

Error code

Example

You must have prepared the OBS paths, sample files, endpoints, and AKs/SKs when submitting a request.

  • Example request

    The following is an example of a MapReduce job request:

    {
        "job_name":"MapReduceTest",
        "job_type":"MapReduce",
        "arguments":[
            "obs://obs-test/program/hadoop-mapreduce-examples-x.x.x.jar",
            "wordcount",
            "obs://obs-test/input/",
            "obs://obs-test/job/mapreduce/output"
        ],
        "properties":{
            "fs.obs.endpoint":"obs endpoint",
            "fs.obs.access.key":"xxx",
            "fs.obs.secret.key":"yyy"
        }
    }

    The following is an example of a SparkSubmit job request:

    {
        "job_name":"SparkSubmitTest",
        "job_type":"SparkSubmit",
        "arguments":[
            "--master",
            "yarn",
            "--deploy-mode",
            "cluster",
            "--py-files",
            "obs://obs-test/a.py",
            "--conf",
            "spark.yarn.appMasterEnv.PYTHONPATH=/tmp:$PYTHONPATH",
            "--conf",
            "spark.yarn.appMasterEnv.aaa=aaaa",
            "--conf",
            "spark.executorEnv.aaa=executoraaa",
            "--properties-file",
            "obs://obs-test/test-spark.conf",
            "obs://obs-test/pi.py",
            "100000"
        ],
        "properties":{
            "fs.obs.access.key":"xxx",
            "fs.obs.secret.key":"yyy"
        }
    }

    The following is an example of a HiveScript job request:

    {
        "job_name":"HiveScriptTest",
        "job_type":"HiveScript",
        "arguments":[
            "obs://obs-test/sql/test_script.sql"
        ],
        "properties":{
            "fs.obs.endpoint":"obs endpoint",
            "fs.obs.access.key":"xxx",
            "fs.obs.secret.key":"yyy"
        }
    }

    The following is an example of a HiveSQL job request:

    {
        "job_name":"HiveSqlTest",
        "job_type":"HiveSql",
        "arguments": [
    		"DROP TABLE IF EXISTS src_wordcount;\ncreate external table src_wordcount(line string) row format delimited fields terminated by \"\\n\" stored as textfile location \"obs://donotdel-gxc/input/\";\ninsert into src_wordcount values(\"v1\");"
    	],
        "properties":{
            "fs.obs.endpoint":"obs endpoint",
            "fs.obs.access.key":"xxx",
            "fs.obs.secret.key":"yyy"
        }
    }

    The following is an example of a DistCp job request:

    {
        "job_name":"DistCpTest",
        "job_type":"DistCp",
        "arguments":[
            "obs://obs-test/DistcpJob/",
            "/user/test/sparksql/"
        ],
        "properties":{
            "fs.obs.endpoint":"obs endpoint",
            "fs.obs.access.key":"xxx",
            "fs.obs.secret.key":"yyy"
        }
    }

    The following is an example of a SparkScript job request:

    {
        "job_name":"SparkScriptTest",
        "job_type":"SparkScript",
        "arguments":[
            "op-key1",
            "op-value1",
            "op-key2",
            "op-value2",
            "obs://obs-test/sql/test_script.sql"
        ],
        "properties":{
            "fs.obs.access.key":"xxx",
            "fs.obs.secret.key":"yyy"
        }
    } 

    The following is an example of a SparkSQL job request:

    {
        "job_name":"SparkSqlTest",
        "job_type":"SparkSql",
        "arguments":[
            "op-key1",
            "op-value1",
            "op-key2",
            "op-value2",
            "create table student_info3 (id string,name string,gender string,age int,addr string);"
        ],
        "properties":{
            "fs.obs.access.key":"xxx",
            "fs.obs.secret.key":"yyy"
        }
    } 

    The following is an example of a Flink job request:

    {
        "job_name":"FlinkTest",
        "job_type":"Flink",
        "arguments":[
            "run",
            "-d",
            "-ynm",
            "testExcutorejobhdfsbatch",
            "-m",
            "yarn-cluster",
            "hdfs://test/examples/batch/WordCount.jar"
        ],
        "properties":{
            "fs.obs.endpoint":"obs endpoint",
            "fs.obs.access.key":"xxx",
            "fs.obs.secret.key":"yyy"
        }
    }
    The following shows an example request of a SparkPython job (Jobs of this type will be converted to SparkSubmit jobs for submission. The job type is displayed as SparkSubmit on the MRS console. Select SparkSubmit when you call an API to query the job list.)
    POST https://{endpoint}/v2/{project_id}/clusters/{cluster_id}/job-executions
    
    {
      "job_name" : "SparkPythonTest",
      "job_type" : "SparkPython",
      "arguments" : [ "--master", "yarn", "--deploy-mode", "cluster", "--py-files", "obs://obs-test/a.py", "--conf", "spark.yarn.appMasterEnv.PYTHONPATH=/tmp:$PYTHONPATH", "--conf", "spark.yarn.appMasterEnv.aaa=aaaa", "--conf", "spark.executorEnv.aaa=executoraaa", "--properties-file", "obs://obs-test/test-spark.conf", "obs://obs-test/pi.py", "100000" ],
      "properties" : {
        "fs.obs.access.key" : "xxx",
        "fs.obs.secret.key" : "yyy"
      }
    }
  • Example response
    • Example of a successful response
      {
        "job_submit_result":{
            "job_id":"44b37a20-ffe8-42b1-b42b-78a5978d7e40",
            "state":"COMPLETE"
        }
      }
    • Example of a failed response
      {
      "error_msg": Hive jobs cannot be submitted.
      "error_code":"0168"
      }

Status Code

For details about status codes, see Status Codes.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback