全部产品
云市场

获取实例信息

更新时间:2018-11-19 21:03:26

接口

getInstance

参数

参数 类型 是否必选 说明
jobId String 作业ID
taskName String 任务名称
instanceId int 实例ID

返回值

成功后返回一个 GetInstanceResponse 实例, 可以通过这个实例的 getInstance() 方法,获取 Instance 对象;Instance的具体属性信息参考API文档。如果失败,抛出异常: ClientException

例子

Java 源码

  1. import com.aliyuncs.batchcompute.main.v20151111.*;
  2. import com.aliyuncs.batchcompute.model.v20151111.*;
  3. import com.aliyuncs.batchcompute.pojo.v20151111.*;
  4. import com.aliyuncs.exceptions.ClientException;
  5. public class GetInstance {
  6. static String ACCESS_KEY_ID = "xxx"; //这里填写您的 AccessKeyId
  7. static String ACCESS_KEY_SECRET = "xxx"; //这里填写您的 AccessKeySecret
  8. static String REGION_ID = "cn-xxx"; //这里填写 region
  9. static String jobId = "job-000000005BE3E897000007FA00114EE9";
  10. static String taskName = "javaSdkTask";
  11. static int instanceId = 0;
  12. public static void main(String[] args) {
  13. BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
  14. try{
  15. GetInstanceResponse response = client.getInstance(jobId,taskName, instanceId);
  16. //成功
  17. Instance ins = response.getInstance();
  18. System.out.println("InstanceId: " + ins.getInstanceId());
  19. System.out.println("InstanceState: " + ins.getState());
  20. }catch(ClientException e){
  21. e.printStackTrace();
  22. //失败
  23. }
  24. }
  25. }

执行结果:

  1. {
  2. InstanceId: 0
  3. InstanceState: Stopped
  4. }