/** * Constructs a new TerminateInstancesRequest object. Callers should use the setter or fluent setter (with...) * methods to initialize any additional object members. * * @param instanceIds * One or more instance IDs.</p> * <p> * Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches. */ public TerminateInstancesRequest(java.util.List<String> instanceIds) { setInstanceIds(instanceIds); }
/** * <p> * One or more instance IDs. * </p> * <p> * Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches. * </p> * * @param instanceIds * One or more instance IDs.</p> * <p> * Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches. * @return Returns a reference to this object so that method calls can be chained together. */ public TerminateInstancesRequest withInstanceIds(java.util.Collection<String> instanceIds) { setInstanceIds(instanceIds); return this; }
/** * <p> * One or more instance IDs. * </p> * <p> * Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setInstanceIds(java.util.Collection)} or {@link #withInstanceIds(java.util.Collection)} if you want to * override the existing values. * </p> * * @param instanceIds * One or more instance IDs.</p> * <p> * Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches. * @return Returns a reference to this object so that method calls can be chained together. */ public TerminateInstancesRequest withInstanceIds(String... instanceIds) { if (this.instanceIds == null) { setInstanceIds(new com.amazonaws.internal.SdkInternalList<String>(instanceIds.length)); } for (String ele : instanceIds) { this.instanceIds.add(ele); } return this; }
/** * Constructs a new TerminateInstancesRequest object. * Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param instanceIds One or more instance IDs. */ public TerminateInstancesRequest(java.util.List<String> instanceIds) { setInstanceIds(instanceIds); }
/** * One or more instance IDs. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param instanceIds One or more instance IDs. * * @return A reference to this updated object so that method calls can be chained * together. */ public TerminateInstancesRequest withInstanceIds(String... instanceIds) { if (getInstanceIds() == null) setInstanceIds(new java.util.ArrayList<String>(instanceIds.length)); for (String value : instanceIds) { getInstanceIds().add(value); } return this; }
/** * Constructs a new TerminateInstancesRequest object. Callers should use the setter or fluent setter (with...) * methods to initialize any additional object members. * * @param instanceIds * One or more instance IDs.</p> * <p> * Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches. */ public TerminateInstancesRequest(java.util.List<String> instanceIds) { setInstanceIds(instanceIds); }
/** * <p> * One or more instance IDs. * </p> * <p> * Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches. * </p> * * @param instanceIds * One or more instance IDs.</p> * <p> * Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches. * @return Returns a reference to this object so that method calls can be chained together. */ public TerminateInstancesRequest withInstanceIds(java.util.Collection<String> instanceIds) { setInstanceIds(instanceIds); return this; }
public void terminateEc2Instance(AmazonEC2Client ec2Client, String instanceId) throws Exception { try { TerminateInstancesRequest termReq = new TerminateInstancesRequest(); List<String> instanceIds = new ArrayList<String>(); instanceIds.add(instanceId); termReq.setInstanceIds(instanceIds); logger.debug("Terminating EC2 instances...." + Arrays.toString(instanceIds.toArray(new String[]{}))); ec2Client.terminateInstances(termReq); } catch(Exception e) { logger.error("Unexpected error terminating: " + instanceId + " "+ e.getMessage(),e); } }
@Override public void stop(String providerInstanceId) { List<String> instanceIds = getIdList(providerInstanceId); TerminateInstancesRequest request = new TerminateInstancesRequest(); request.setInstanceIds(instanceIds); ec2Client.terminateInstances(request); }
/** * <p> * One or more instance IDs. * </p> * <p> * Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches. * </p> * <p> * <b>NOTE:</b> This method appends the values to the existing list (if any). Use * {@link #setInstanceIds(java.util.Collection)} or {@link #withInstanceIds(java.util.Collection)} if you want to * override the existing values. * </p> * * @param instanceIds * One or more instance IDs.</p> * <p> * Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches. * @return Returns a reference to this object so that method calls can be chained together. */ public TerminateInstancesRequest withInstanceIds(String... instanceIds) { if (this.instanceIds == null) { setInstanceIds(new com.amazonaws.internal.SdkInternalList<String>(instanceIds.length)); } for (String ele : instanceIds) { this.instanceIds.add(ele); } return this; }
@Override public void terminateInstance(String instanceId) { checkNotBlank(instanceId, "instanceId"); TerminateInstancesRequest request = new TerminateInstancesRequest(); request.setInstanceIds(singletonList(instanceId)); client.terminateInstances(request); WaitContext waitContext = getWaitContext(context.getTerminationTimeoutMillis()); Object[] args = { FormatUtils.getTime(waitContext.getTimeoutMillis()), instanceId, TERMINATED.getValue() }; logger.info("Waiting up to {} for [{}] to terminate", args); Condition condition = new InstanceStateCondition(this, instanceId, TERMINATED); WaitResult result = service.wait(waitContext, condition); Object[] resultArgs = { instanceId, getTime(result.getElapsed()) }; logger.info("[{}] has been terminated - {}", resultArgs); }