接口
getInstance
参数
参数 | 类型 | 是否必选 | 说明 |
---|---|---|---|
jobId | String | 是 | 作业ID |
taskName | String | 是 | 任务名称 |
instanceId | int | 是 | 实例ID |
返回值
成功后返回一个 GetInstanceResponse
实例, 可以通过这个实例的 getInstance()
方法,获取 Instance
对象;Instance
的具体属性信息参考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 GetInstance {
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";
static String taskName = "javaSdkTask";
static int instanceId = 0;
public static void main(String[] args) {
BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
try{
GetInstanceResponse response = client.getInstance(jobId,taskName, instanceId);
//成功
Instance ins = response.getInstance();
System.out.println("InstanceId: " + ins.getInstanceId());
System.out.println("InstanceState: " + ins.getState());
System.out.println("InstanceIP: " + ins.getNodeIp());
}catch(ClientException e){
e.printStackTrace();
//失败
}
}
}
执行结果:
{
InstanceId: 0
InstanceState: Stopped
InstanceIP: 10.1.98.3
}
文档内容是否对您有帮助?