新增作业并执行
功能介绍
在MRS集群中新增一个作业,并执行作业。该接口不兼容Sahara。
URI
- URI格式
 - 参数说明 
    
表1 URI参数说明 名称
是否必选
说明
project_id
是
项目编号。获取方法,请参见获取项目ID。
 
请求消息
| 
        参数名  | 
      
        是否必选  | 
      
        参数类型  | 
      
        说明  | 
     
|---|---|---|---|
| 
        job_type  | 
      
        是  | 
      
        Integer  | 
      
        作业类型码。  | 
     
| 
        job_name  | 
      
        是  | 
      
        String  | 
      
        作业名称,只能由字母、数字、中划线和下划线组成,并且长度为1~64个字符。 
         说明: 
         不同作业的名称允许相同,但不建议设置相同。  | 
     
| 
        cluster_id  | 
      
        是  | 
      
        String  | 
      
        集群ID。  | 
     
| 
        jar_path  | 
      
        是  | 
      
        String  | 
      
        执行程序Jar包或sql文件地址,需要满足如下要求: 
  | 
     
| 
        arguments  | 
      
        否  | 
      
        String  | 
      
        程序执行的关键参数,该参数由用户程序内的函数指定,MRS只负责参数的传入。 最多为2047字符,不能包含;|&>'<$!\\特殊字符,可为空。 
         说明: 
         用户输入带有敏感信息(如登录密码)的参数时,可通过在参数名前添加“@”的方式,为该参数值加密,以防止敏感信息被明文形式持久化。在查看作业信息时,敏感信息显示为“*”。 例如:username=admin @password=admin_123  | 
     
| 
        input  | 
      
        否  | 
      
        String  | 
      
        数据输入地址,必须以“/”或“s3a://”开头。请配置为正确的OBS路径,OBS路径不支持KMS加密的文件或程序。 最多为1023字符,不能包含;|&>'<$特殊字符,可为空。  | 
     
| 
        output  | 
      
        否  | 
      
        String  | 
      
        数据输出地址,必须以“/”或“s3a://”开头。请配置为正确的OBS路径,如果该路径不存在,系统会自动创建。 最多为1023字符,不能包含;|&>'<$特殊字符,可为空。  | 
     
| 
        job_log  | 
      
        否  | 
      
        String  | 
      
        作业日志存储地址,该日志信息记录作业运行状态。必须以“/”或“s3a://”开头,请配置为正确的OBS路径。 最多为1023字符,不能包含;|&>'<$特殊字符,可为空。  | 
     
| 
        hive_script_path  | 
      
        是  | 
      
        String  | 
      
        sql程序路径,仅Spark Script和Hive Script作业需要使用此参数。需要满足如下要求: 
  | 
     
| 
        参数名  | 
      
        是否必选  | 
      
        参数类型  | 
      
        说明  | 
     
|---|---|---|---|
| 
        job_name  | 
      
        是  | 
      
        String  | 
      
        作业名称,只能由字母、数字、中划线和下划线组成,并且长度为1~64个字符。 
         说明: 
         不同作业的名称允许相同,但不建议设置相同。  | 
     
| 
        input  | 
      
        否  | 
      
        String  | 
      
        数据源路径。 
  | 
     
| 
        output  | 
      
        否  | 
      
        String  | 
      
        接收数据路径。 
  | 
     
| 
        file_action  | 
      
        是  | 
      
        String  | 
      
        文件操作类型,包括: 
  | 
     
| 
        参数名  | 
      
        是否必选  | 
      
        参数类型  | 
      
        说明  | 
     
|---|---|---|---|
| 
        hql  | 
      
        是  | 
      
        String  | 
      
        Spark SQL语句,该语句需要进行Base64编码和解码,“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/”为标准的编码表,MRS使用“ABCDEFGHILKJMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/”进行Base64编码。在编码后所得字符串首位任意加上一个字母,即得到Hql参数的值。后台自动进行解码得到Spark SQL语句。 使用样例: 
  | 
     
| 
        job_name  | 
      
        是  | 
      
        String  | 
      
        作业名称,只能由字母、数字、中划线和下划线组成,并且长度为1~64个字符。 
         说明: 
         不同作业的名称允许相同,但不建议设置相同。  | 
     
响应参数
| 
        参数名  | 
      
        参数类型  | 
      
        说明  | 
     
|---|---|---|
| 
        job_execution  | 
      
        Object  | 
      
        作业详细信息,请参见表6。  | 
     
| 
        参数名  | 
      
        参数类型  | 
      
        说明  | 
     
|---|---|---|
| 
        templated  | 
      
        Bool  | 
      
        作业执行对象是否由作业模板生成。  | 
     
| 
        created_at  | 
      
        Integer  | 
      
        作业创建时间,十位时间戳。  | 
     
| 
        updated_at  | 
      
        Integer  | 
      
        作业更新时间,十位时间戳。  | 
     
| 
        id  | 
      
        String  | 
      
        作业ID。  | 
     
| 
        tenant_id  | 
      
        String  | 
      
        项目编号。获取方法,请参见获取项目ID。  | 
     
| 
        job_id  | 
      
        String  | 
      
        作业应用ID。  | 
     
| 
        job_name  | 
      
        String  | 
      
        作业名称。  | 
     
| 
        input_id  | 
      
        String  | 
      
        数据输入ID。  | 
     
| 
        output_id  | 
      
        String  | 
      
        数据输出ID。  | 
     
| 
        start_time  | 
      
        Integer  | 
      
        作业执行开始时间,十位时间戳。  | 
     
| 
        end_time  | 
      
        Integer  | 
      
        作业执行结束时间,十位时间戳。  | 
     
| 
        cluster_id  | 
      
        String  | 
      
        集群ID。  | 
     
| 
        engine_job_id  | 
      
        String  | 
      
        Oozie工作流ID。  | 
     
| 
        return_code  | 
      
        Integer  | 
      
        运行结果返回码。  | 
     
| 
        is_public  | 
      
        Bool  | 
      
        是否公开。 
 当前版本不支持该功能。  | 
     
| 
        is_protected  | 
      
        Bool  | 
      
        是否受保护。 
 当前版本不支持该功能。  | 
     
| 
        group_id  | 
      
        String  | 
      
        作业执行组ID。  | 
     
| 
        jar_path  | 
      
        String  | 
      
        执行程序jar包地址。  | 
     
| 
        input  | 
      
        String  | 
      
        数据输入地址。  | 
     
| 
        output  | 
      
        String  | 
      
        数据输出地址。  | 
     
| 
        job_log  | 
      
        String  | 
      
        作业日志存储地址。  | 
     
| 
        job_type  | 
      
        Integer  | 
      
        作业类型码。 
  | 
     
| 
        file_action  | 
      
        String  | 
      
        导入导出数据。  | 
     
| 
        arguments  | 
      
        String  | 
      
        程序执行的关键参数,该参数由用户程序内的函数指定,MRS只负责参数的传入。该参数可为空。  | 
     
| 
        job_state  | 
      
        Integer  | 
      
        作业状态码。 
  | 
     
| 
        job_final_status  | 
      
        Integer  | 
      
        作业最终状态码。 
  | 
     
| 
        hive_script_path  | 
      
        String  | 
      
        Hive脚本地址。  | 
     
| 
        create_by  | 
      
        String  | 
      
        创建作业的用户ID。 为兼容历史版本,保留此参数。  | 
     
| 
        finished_step  | 
      
        Integer  | 
      
        当前已完成的步骤数。 为兼容历史版本,保留此参数。  | 
     
| 
        job_main_id  | 
      
        String  | 
      
        作业主ID。 为兼容历史版本,保留此参数。  | 
     
| 
        job_step_id  | 
      
        String  | 
      
        作业步骤ID。 为兼容历史版本,保留此参数。  | 
     
| 
        postpone_at  | 
      
        Integer  | 
      
        延迟时间,十位时间戳。 为兼容历史版本,保留此参数。  | 
     
| 
        step_name  | 
      
        String  | 
      
        作业步骤名。 为兼容历史版本,保留此参数。  | 
     
| 
        step_num  | 
      
        Integer  | 
      
        步骤数量 为兼容历史版本,保留此参数。  | 
     
| 
        task_num  | 
      
        Integer  | 
      
        任务数量。 为兼容历史版本,保留此参数。  | 
     
| 
        update_by  | 
      
        String  | 
      
        更新作业的用户ID。  | 
     
| 
        credentials  | 
      
        String  | 
      
        令牌,当前版本不支持。  | 
     
| 
        user_id  | 
      
        String  | 
      
        创建作业的用户ID。 历史版本兼容,不再使用。  | 
     
| 
        job_configs  | 
      
        String  | 
      
        键值对集合,用于保存作业运行配置。  | 
     
| 
        extra  | 
      
        String  | 
      
        认证信息,当前版本不支持。  | 
     
| 
        data_source_urls  | 
      
        String  | 
      
        数据源URL。  | 
     
| 
        info  | 
      
        String  | 
      
        键值对集合,包含oozie返回的作业运行信息。  | 
     
示例
- 请求示例
    
    
{ "job_type": 1, "job_name": "mrs_test_jobone_20170602_141106", "cluster_id": "e955a7a3-d334-4943-a39a-994976900d56", "jar_path": "s3a://mrs-opsadm/jarpath/hadoop-mapreduce-examples-2.7.2.jar", "arguments": "wordcount", "input": "s3a://mrs-opsadm/input/", "output": "s3a://mrs-opsadm/output/", "job_log": "s3a://mrs-opsadm/log/", "file_action": "", "hql": "", "hive_script_path": "" }Spark作业请求示例:
{ "job_type": 2, "job_name": "mrs_test_sparkjob_20170602_141106", "cluster_id": "e955a7a3-d334-4943-a39a-994976900d56", "jar_path": "s3a://mrs-opsadm/jarpath/spark-test.jar", "arguments": "org.apache.spark.examples.SparkPi 10", "input": "", "output": "s3a://mrs-opsadm/output/", "job_log": "s3a://mrs-opsadm/log/", "file_action": "", "hql": "", "hive_script_path": "" }Hive Script作业请求示例:
{ "job_type": 3, "job_name": "mrs_test_SparkScriptJob_20170602_141106", "cluster_id": "e955a7a3-d334-4943-a39a-994976900d56", "jar_path": "s3a://mrs-opsadm/jarpath/Hivescript.sql", "arguments": "", "input": "s3a://mrs-opsadm/input/", "output": "s3a://mrs-opsadm/output/", "job_log": "s3a://mrs-opsadm/log/", "file_action": "", "hql": "", "hive_script_path": "s3a://mrs-opsadm/jarpath/Hivescript.sql" }DistCp导入作业请求示例:
{ "job_type": 5, "job_name": "mrs_test_importjob_20170602_141106", "cluster_id": "e955a7a3-d334-4943-a39a-994976900d56", "input": "s3a://mrs-opsadm/jarpath/hadoop-mapreduce-examples-2.7.2.jar", "output": "/user", "file_action": "import" }DistCp导出作业请求示例:
{ "job_type": 5, "job_name": "mrs_test_exportjob_20170602_141106", "cluster_id": "e955a7a3-d334-4943-a39a-994976900d56", "input": "/user/hadoop-mapreduce-examples-2.7.2.jar", "output": "s3a://mrs-opsadm/jarpath/", "file_action": "export" }Spark Script作业请求示例:
{ "job_type": 6, "job_name": "mrs_test_sparkscriptjob_20170602_141106", "cluster_id": "e955a7a3-d334-4943-a39a-994976900d56", "jar_path": "s3a://mrs-opsadm/jarpath/sparkscript.sql", "arguments": "", "input": "s3a://mrs-opsadm/input/", "output": "s3a://mrs-opsadm/output/", "job_log": "s3a://mrs-opsadm/log/", "file_action": "", "hql": "", "hive_script_path": "s3a://mrs-opsadm/jarpath/sparkscript.sql" } - 响应示例
    
{ "job_execution": { "templated": false, "created_at": 1496387588, "updated_at": 1496387588, "id": "12ee9ae4-6ee1-48c6-bb84-fb0b4f76cf03", "tenant_id": "c71ad83a66c5470496c2ed6e982621cc", "job_id": "", "job_name": "mrs_test_jobone_20170602_141106", "input_id": null, "output_id": null, "start_time": 1496387588, "end_time": null, "cluster_id": "e955a7a3-d334-4943-a39a-994976900d56", "engine_job_id": null, "return_code": null, "is_public": null, "is_protected": false, "group_id": "12ee9ae4-6ee1-48c6-bb84-fb0b4f76cf03", "jar_path": "s3a://mrs-opsadm/jarpath/hadoop-mapreduce-examples-2.7.2.jar", "input": "s3a://mrs-opsadm/input/", "output": "s3a://mrs-opsadm/output/", "job_log": "s3a://mrs-opsadm/log/", "job_type": 1, "file_action": "", "arguments": "wordcount", "hql": "", "job_state": 2, "job_final_status": 0, "hive_script_path": "", "create_by": "b67132be2f054a45b247365647e05af0", "finished_step": 0, "job_main_id": "", "job_step_id": "", "postpone_at": 1496387588, "step_name": "", "step_num": 0, "task_num": 0, "update_by": "b67132be2f054a45b247365647e05af0", "credentials": "", "user_id": "b67132be2f054a45b247365647e05af0", "job_configs": null, "extra": null, "data_source_urls": null, "info": null } }