全部產品
Search
文件中心

:擷取作業資訊

更新時間:Jul 06, 2024

介面

getJob

參數

參數 類型 是否必需 說明
jobId String 作業ID

傳回值

成功後返回一個 GetJobResponse 執行個體,可以通過這個執行個體的 getJob() 方法擷取 Job 對象;Job 對象的具體屬性參考API文檔。如果失敗,拋出異常: ClientException

例子

Java 源碼

import com.aliyuncs.batchcompute.main.v20151111.*;
import com.aliyuncs.batchcompute.model.v20151111.*;
import com.aliyuncs.batchcompute.pojo.v20151111.*;
import com.aliyuncs.exceptions.ClientException;

public class GetJob {
    static String ACCESS_KEY_ID = "xxx";  //這裡填寫您的 AccessKeyId
    static String ACCESS_KEY_SECRET = "xxx"; //這裡填寫您的 AccessKeySecret
    static String REGION_ID = "cn-xxx";   //這裡填寫 region
    static String jobId = "job-000000005BE3E897000007FA00114EE9";

    public static void main(String[] args) {
        BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
        try{
            GetJobResponse response = client.getJob(jobId);
            //成功
            Job job = response.getJob();

            System.out.println("jobId: " + job.getId());
            System.out.println("jobNameId: " + job.getName());
            System.out.println("jobState: " + job.getState());
            System.out.println("RequestId: " + response.getRequestId());
            System.out.println("StatusCode: " + response.getStatusCode());
        }catch(ClientException e){
            e.printStackTrace();
            //失敗
        }
    }
}

執行結果:

{
  jobId: job-000000005BE3E897000007FA00114EE9
  jobNameId: javaSdkJob
  jobState: Waiting
  RequestId: null
  StatusCode: 200
}