創建(提交)一個DAG類型的作業。

描述

請求語法樣例

POST /jobs

{
  "Name": "testJob",
  "Description": "BatchCompute demo job",
  "JobFailOnInstanceFail": true,
  "Priority": 1,
  "Type": "DAG",
  "AutoRelease": false,
  "Notification": {
        "Topic": {
            "Name": "test-topic",
            "Endpoint": "http://[UserId].mns.[Region].aliyuncs.com/",
            "Events": [
                    "OnJobWaiting",
                    "OnJobRunning",
                    "OnJobStopped",
                    "OnJobFinished",
                    "OnJobFailed",
                    "OnTaskWaiting",
                    "OnTaskRunning",
                    "OnTaskStopped",
                    "OnTaskFinished",
                    "OnTaskFailed",
                    "OnInstanceWaiting",
                    "OnInstanceRunning",
                    "OnInstanceStopped",
                    "OnInstanceFinished",
                    "OnInstanceFailed",
                    "OnPriorityChange"
                ]
        }
   },
  "DAG": {
    "Dependencies": {},
    "Tasks": {
      "taskA": {
        "AutoCluster": {
          "Configs": {
            "Disks": {
              "DataDisk": {
                "MountPoint": "/home/mydisk/",
                "Size": 0,
                "Type": "ephemeral"
              },
              "SystemDisk": {
                "Size": 40,
                "Type": "ephemeral"
              }
            },
            "Mounts": {
               "Entries": [
                   {
                       "Destination": "/home/admin/mount-dest",
                       "Source": "oss://your-bucket/mount-source",
                       "WriteSupport": false
                    }
                ],
                "Locale": "GBK",
                "Lock": false,
                "CacheSupport": true,
                "NAS": {
                    "AccessGroup": [
                        "group1",
                        "group2"
                    ],
                    "FileSystem": [
                        "filesystem1",
                        "filesystem2"
                    ]
                },
                "OSS": {
                    "AccessKeyId": "",
                    "AccessKeySecret": "",
                    "AccessSecurityToken": ""
                }
             },
             "Networks": {
                 "Classic": {
                     "AllowIpAddress": [],
                     "AllowIpAddressEgress": [],
                     "AllowSecurityGroup": [],
                     "AllowSecurityGroupEgress": []
                 },
                 "VPC": {
                     "CidrBlock": "192.168.0.0/16"
                 }
             }
          },
          "ECSImageId": "",
          "ImageId": "img-ubuntu",
          "InstanceType": "bcs.a2.large",
          "ResourceType": "OnDemand",
          "SpotStrategy": "SpotAsPriceGo",
          "SpotPriceLimit": 0.0,
          "UserData": {},
          "ReserveOnFail": false
        },
        "ClusterId": "cls-6kir9pdp3lg6220g418002",
        "InputMapping": {
          "oss://bucket/tmp/": "/home/mount1/"
        },
        "InstanceCount": 1,
        "LogMapping": {},
        "MaxRetryCount": 0,
        "OutputMapping": {
          "/home/mount1": "oss://bucket/tmp/"
        },
        "Mounts": {
            "Entries": [
                {
                    "Destination": "/home/admin/mount-dest",
                    "Source": "oss://your-bucket/mount-source",
                    "WriteSupport": false
                }
            ],
            "Locale": "GBK",
            "Lock": false,
            "NAS": {
            "AccessGroup": [
                "group1",
                "group2"
            ],
            "FileSystem": [
                "filesystem1",
                "filesystem2"
            ]
            },
            "OSS": {
                "AccessKeyId": "",
                "AccessKeySecret": "",
                "AccessSecurityToken": ""
            }
        },
        "Parameters": {
          "Command": {
            "CommandLine": "python worker.py",
            "EnvVars": {},
            "PackagePath": "oss://bucket/tests/worker.tar.gz"
          },
          "InputMappingConfig": {
            "Locale": "GBK",
            "Lock": false
          },
          "StderrRedirectPath": "oss://bucket/tests/logs/",
          "StdoutRedirectPath": "oss://bucket/tests/logs/"
        },
        "Timeout": 172800,
      }
    }
  }
}

屬性說明

屬性名稱類型是否必須描述
Namestring作業名稱。
Descriptionstring作業的描述信息。
Priorityint作業優先級,范圍0-1000,數值越高,優先級越高。
Typestring目前僅支持有向無環圖(directed acycline graph,DAG)形式描述任務。
JobFailOnInstanceFailbool取值為true表示Instance失敗會導致Job失敗。
AutoReleasebool取值為true表示Job運行成功后系統會自動刪除改Job。默認false。
Notificationobject消息通知配置,用戶指定消息事件Notification
DAGobjectDAG描述。
Tasksobject任務描述。
Parametersobject任務參數詳情。
Commandobject用戶程序相關命令行參數。
CommandLinestring執行用戶程序的命令。CommandLine不等同于SHELL,僅支持“解釋器 + 腳本”方式,比如“python test.py”或“sh test.sh”
PackagePathstring用戶程序所在OSS路徑。
EnvVarsstring設置用戶程序執行時的環境變量。
InputMappingConfigobjectNFS掛載服務配置項。
LocalestringOSS object掛載到本地時使用的字符集。可選范圍包括GBK、GB2312-80、BIG5、ANSI、EUC-JP、EUC-TW、EUC-KR、SHIFT-JIS、KSC5601等。
LockboolNFS掛載服務是否支持網絡文件鎖。
StdoutRedirectPathstring標準輸出的OSS路徑。
StderrRedirectPathstring標準錯誤的OSS路徑。
InputMappingobjectOSS對本地路徑映射。
OutputMappingobject本地路徑對OSS映射。
LogMappingobject本地日志路徑對OSS映射。OSS是目錄,以斜杠結尾。OSS日志名稱格式:{本地日志名}.{作業ID}.{任務ID}.{實例ID},比如output_log.job-0000000056A6E991000001780000000D.Echo.0
Timeoutint實例最長執行時間。
InstanceCountint實例數量。
MaxRetryCountint最大重試次數,默認為0。
ClusterIdstring集群標識符。該參數與AutoCluster(匿名集群)必須選擇一個
AutoClusterobject匿名集群。Auto集群描述,AutoCluster和ClusterId必須一個是有效的,而且只能有一個是有效的。
Dependenciesobject描述任務之間依賴關系的object結構,其中key為源任務名稱,value為目標任務名稱列表,可以描述一對多的順序關系。

AutoCluster

屬性名稱類型是否必須描述
ImageIdstringBatchCompute鏡像的ID
ECSImageIdstringECS鏡像的ID,必須取值為合法的ECS鏡像ID。ECSImageId和ImageId必須只能一個取合法的值,另外一個必須為空。
InstanceTypestring構建集群的實例類型。目前支持的ECS實例類型
ResourceTypestring資源類型。支持“OnDemand(按需資源)”,“Spot(競價型資源)”。
SpotStrategyString實例的競價策略,只有在ResourceType為Spot的情況下有效。取值范圍:SpotWithPriceLimit:設置上限價格的競價實例;SpotAsPriceGo:系統自動出價,最高按量付費價格。
SpotPriceLimitFloat實例的每小時最高價格(每個實例規格的價格而非每核小時的價格)。支持最大 3 位小數,SpotStrategy 為 SpotWithPriceLimit 生效。
UserDataobject一個KeyValue映射,用戶自定義的信息,使用ECS的metaserver獲取。
Configsobject集群的一些配置信息,比如實例的磁盤配置,由Configs描述。
ReserveOnFailBool任務失敗時不釋放相關的虛擬機,會繼續收取這些資源的費用直到用戶刪除作業,默認為False,僅用于調查問題。
DependencyIsvServicestring執行程序依賴的阿里云提供的ISV服務,目前提供的ISV服務有:“GTX”,默認為””,不依賴任何ISV服務。

返回信息

返回成功

返回201狀態碼以及Job的id,如下。

{
    "Id":"job-xxx"
}

屬性說明

屬性名稱類型是否必須描述
Idstring作業標識符。

錯誤信息

狀態碼錯誤碼錯誤信息語義
400IdempotentTokenMismatchSpecified idempotent token mismatch.說明該token已經被使用過,并且該請求參數與之前的請求不一樣。
400InvalidJsonFormatThe request body has an invalid json format.請求body是一個非法的JSON格式。
400InvalidHttpBodySpecified parameter HttpBody is not valid. Its type must be object.http body必須是一個object。
400MissingNameName is mandatory for this action.缺少Name參數。
400InvalidNameSpecified parameter Name is not valid. Its type must be string.Name必須是一個string。
400InvalidNameSpecified parameter Name is not valid. Its length must be in [1, 64].Name的長度必須在1與64之間。
400InvalidNameSpecified parameter Name is not valid. It must only contain characters within [a-zA-Z0-9_-], and must not start with [0-9].Name中只能包括字母數字和_-,但不能以數字開頭。
400InvalidDescriptionSpecified parameter Description is not valid. Its type must be string.Description必須是一個string。
400InvalidDescriptionSpecified parameter Description is not valid. Its length must be in [0, 1024].Description的長度必須在0與1024之間。
400InvalidPrioritySpecified parameter Priority is not valid. Its type must be integer.Priority必須是一個integer。
400InvalidPrioritySpecified parameter Priority is not valid. It must be in [0, 1000].Priority的大小必須在0與1000之間。
400InvalidJobFailOnInstanceFailSpecified parameter JobFailOnInstanceFail is not valid. Its type must be boolean.JobFailOnInstanceFail必須是一個布爾類型。
400MissingTypeType is mandatory for this action.缺少Type參數。
400InvalidTypeSpecified parameter Type is not valid.Type參數取值不合法。
400MissingDAGDAG is mandatory for this action.缺少DAG參數。
400InvalidDAGSpecified parameter DAG is not valid. Its type must be object.DAG必須是一個object。
400MissingTasksTasks is mandatory for this action.缺少Tasks參數。
400InvalidTasksSpecified parameter Tasks is not valid. Its type must be object.Tasks必須是一個object。
400InvalidTasksSpecified parameter Tasks is not valid. Its size must be in [1, 16].UserData的大小必須在1與16之間。
400InvalidTasks.{key}Specified parameter Tasks.{key} is not valid. Its length must be in [1, 64].Tasks.{key}的大小必須在1與64之間。
400InvalidTasks.{key}Specified parameter Tasks.{key} is not valid. It must only contain characters within [a-zA-Z0-9_-], and must not start with [0-9]..Tasks.{key}中只能包括字母數字和_-,但不能以數字開頭。
403QuotaExhausted.MaxJobCountThe MaxJobCount ({value}) quota is exhausted.Job數量不能超過{value}。
403QuotaExhausted.MaxJobTaskCountThe MaxJobTaskCount ({value}) quota is exhausted.一個Job中的Task的數量不能超過{value}。
403QuotaExhausted.MaxTaskInstanceCountThe MaxTaskInstanceCount ({value}) quota is exhausted.一個Task的InstanceCount不能超過{value}。
403QuotaExhausted.MaxInstanceTimeoutThe MaxInstanceTimeout ({value}) quota is exhausted.一個Instance的Timeout不能超過{value}。
400MissingParametersParameters is mandatory for this action.缺少Parameters參數。
400InvalidParametersSpecified parameter Parameters is not valid. Its type must be object.Parameters必須是一個object。
400MissingCommandCommand is mandatory for this action.缺少Command參數。
400InvalidCommandSpecified parameter Command is not valid. Its type must be object.Command必須是一個object。
400MissingCommandLineCommandLine is mandatory for this action.缺少CommandLine參數。
400InvalidCommandLineSpecified parameter CommandLine is not valid. Its type must be string.CommandLine必須是一個string。
400InvalidCommandLineSpecified parameter CommandLine is not valid. Its length must be in [0, 1024].CommandLine的長度必須在0與1024之間。
400InvalidPackagePathSpecified parameter PackagePath is not valid. Its type must be string.PackagePath必須是一個string。
400InvalidPackagePathSpecified parameter PackagePath is not valid. Its length must be in [0, 1024].PackagePath的長度必須在0與1024之間。
400InvalidPackagePathSpecified parameter PackagePath is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file.PackagePath必須是一個合法的OSS路徑。
400InvalidEnvVarsSpecified parameter EnvVars is not valid. Its type must be object.EnvVars必須是一個object。
400InvalidEnvVarsSpecified parameter EnvVars is not valid. Its size must be in [0, 64].EnvVars的大小必須在0與64之間。
400InvalidEnvVars.{key}Specified parameter EnvVars.{key} is not valid. Its length must be in [1, 128].EnvVars.{key}的大小必須在1與128之間。
400InvalidEnvVars.{key}.valueSpecified parameter EnvVars.{key}.value is not valid. Its type must be string.EnvVars.{key}對應的Value必須是一個string。
400InvalidEnvVars.{key}.valueSpecified parameter EnvVars.{key}.value is not valid. Its length must be in [0, 1024].EnvVars.{key}對應的value的長度必須在0與1024之間。
400InvalidInputMappingConfigSpecified parameter InputMappingConfig is not valid. Its type must be object.InputMappingConfig必須是一個object。
400InvalidLocaleSpecified parameter Locale is not valid.Locale參數取值不合法。
400InvalidLockSpecified parameter Lock is not valid. Its type must be boolean.Lock必須是一個布爾類型。
400InvalidStdoutRedirectPathSpecified parameter StdoutRedirectPath is not valid. Its type must be string.StdoutRedirectPath必須是一個string。
400InvalidStdoutRedirectPathSpecified parameter StdoutRedirectPath is not valid. Its length must be in [0, 1024].StdoutRedirectPath的長度必須在0與1024之間。
400InvalidStdoutRedirectPathSpecified parameter StdoutRedirectPath is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file.StdoutRedirectPath必須是一個合法的OSS路徑。
400InvalidStderrRedirectPathSpecified parameter StderrRedirectPath is not valid. Its type must be string.StderrRedirectPath必須是一個string。
400InvalidStderrRedirectPathSpecified parameter StderrRedirectPath is not valid. Its length must be in [0, 1024].StderrRedirectPath的長度必須在0與1024之間。
400InvalidStderrRedirectPathSpecified parameter StderrRedirectPath is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file.StderrRedirectPath必須是一個合法的OSS路徑。
400InvalidInputMappingSpecified parameter InputMapping is not valid. Its type must be object.InputMapping必須是一個object。
400InvalidInputMappingSpecified parameter InputMapping is not valid. Its size must be in [0, 16].InputMapping的Key的個數必須在0與16之間。
400InvalidInputMapping.{key}Specified parameter InputMapping.{key} is not valid. Its length must be in [1, 1024].InputMapping.{key}的大小必須在1與1024之間。
400InvalidInputMapping.{key}Specified parameter InputMapping.{key} is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file.InputMapping.{key}必須是一個合法的OSS路徑。
400InvalidInputMapping.{key}.valueSpecified parameter InputMapping.{key}.value is not valid. Its type must be string.InputMapping.{key}對應的Value必須是一個string。
400InvalidInputMapping.{key}.valueSpecified parameter InputMapping.{key}.value is not valid. Its length must be in [0, 1024].InputMapping.{key}對應的value的長度必須在0與1024之間。
400InvalidInputMapping.{key}.valueSpecified parameter InputMapping.{key}.value is not valid. Local path must be an absolute path on linux, and an drive letter on windows.InputMapping.{key}對應的value必須是一個合法的本地路徑。
400InvalidOutputMappingSpecified parameter OutputMapping is not valid. Its type must be object.OutputMapping必須是一個object。
400InvalidOutputMappingSpecified parameter OutputMapping is not valid. Its size must be in [0, 16].OutputMapping的Key的個數必須在0與16之間。
400InvalidOutputMapping.{key}Specified parameter OutputMapping.{key} is not valid. Its length must be in [1, 1024].OutputMapping.{key}的大小必須在1與1024之間。
400InvalidOutputMapping.{key}Specified parameter OutputMapping.{key} is not valid. Local path must be an absolute path.OutputMapping.{key}必須是一個合法的本地路徑。
400InvalidOutputMapping.{key}.valueSpecified parameter OutputMapping.{key}.value is not valid. Its type must be string.OutputMapping.{key}對應的Value必須是一個string
400InvalidOutputMapping.{key}.valueSpecified parameter OutputMapping.{key}.value is not valid. Its length must be in [0, 1024].OutputMapping.{key}對應的value的長度必須在0與1024之間。
400InvalidOutputMapping.{key}.valueSpecified parameter OutputMapping.{key}.value is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file.OutputMapping.{key}對應的value的大小必須在1與1024之間。
400InvalidLogMappingSpecified parameter LogMapping is not valid. Its type must be object.LogMapping必須是一個object。
400InvalidLogMappingSpecified parameter LogMapping is not valid. Its size must be in [0, 16].LogMapping的Key的個數必須在0與16之間。
400InvalidLogMapping.{key}Specified parameter LogMapping.{key} is not valid. Its length must be in [1, 1024].LogMapping.{key}的大小必須在1與1024之間。
400InvalidLogMapping.{key}Specified parameter LogMapping.{key} is not valid. Local path must be an absolute path.LogMapping.{key}必須是一個合法的本地路徑。
400InvalidLogMapping.{key}.valueSpecified parameter LogMapping.{key}.value is not valid. Its type must be string.LogMapping.{key}對應的Value必須是一個string。
400InvalidLogMapping.{key}.valueSpecified parameter LogMapping.{key}.value is not valid. Its length must be in [0, 1024].LogMapping.{key}對應的value的長度必須在0與1024之間。
400InvalidLogMapping.{key}.valueSpecified parameter LogMapping.{key}.value is not valid. OSS path must start with ‘oss://‘, must end with ‘/‘ if it is a folder, and must not end with ‘/‘ if it is a file.LogMapping.{key}對應的value的大小必須在1與1024之間。
400InvalidTimeoutSpecified parameter Timeout is not valid. Its type must be integer.Timeout必須是一個integer。
400MissingInstanceCountInstanceCount is mandatory for this action.缺少InstanceCount參數。
400InvalidInstanceCountSpecified parameter InstanceCount is not valid. Its type must be integer.InstanceCount必須是一個integer。
400InvalidMaxRetryCountSpecified parameter MaxRetryCount is not valid. Its type must be integer.MaxRetryCount必須是一個integer。
400MissingClusterIdClusterId is mandatory for this action.缺少ClusterId參數。
400InvalidClusterIdSpecified parameter ClusterId is not valid. Its type must be string.ClusterId必須是一個string。
400InvalidClusterIdSpecified parameter ClusterId is not valid. Its length must be in [1, 64].ClusterId的長度必須在1與64之間。
400InvalidClusterIdSpecified parameter ClusterId is not valid. It must only contain characters within [a-zA-Z0-9_-], and must not start with [0-9].ClusterId中只能包括字母數字和_-,但不能以數字開頭。
400InvalidDependenciesSpecified parameter Dependencies is not valid. Its type must be object.Dependencies必須是一個object。
400InvalidDependencies.{key}.valueSpecified parameter Dependencies.{key}.value is not valid. Its type must be array.Dependencies.{key}對應的Value必須是一個array。
400Invalid{Parameter}Specified parameter {Parameter} is not valid.{Parameter}參數不合法。