Java 类com.amazonaws.services.ec2.model.CancelSpotInstanceRequestsRequest 实例源码

项目:cloud-runner    文件:Instance.java   
private void terminateSpotRequest() throws AmazonServiceException {
    if (spotRequestId == null)
        return;

    com.amazonaws.services.ec2.AmazonEC2 client = AmazonEC2.connect();

    List<String> spotInstanceRequestIds = new ArrayList<String>();
    spotInstanceRequestIds.add(spotRequestId);

    CancelSpotInstanceRequestsRequest cancelRequest = new CancelSpotInstanceRequestsRequest(
            spotInstanceRequestIds);
    client.cancelSpotInstanceRequests(cancelRequest);
}
项目:dwtc-extractor    文件:Master.java   
public void shutdownInstances() {
    AmazonEC2 ec2 = new AmazonEC2Client(getAwsCredentials());
    ec2.setEndpoint(getOrCry("ec2endpoint"));

    try {
        // cancel spot request, so no new instances will be launched
        DescribeSpotInstanceRequestsRequest describeRequest = new DescribeSpotInstanceRequestsRequest();
        DescribeSpotInstanceRequestsResult describeResult = ec2
                .describeSpotInstanceRequests(describeRequest);
        List<SpotInstanceRequest> describeResponses = describeResult
                .getSpotInstanceRequests();
        List<String> spotRequestIds = new ArrayList<String>();
        List<String> instanceIds = new ArrayList<String>();

        for (SpotInstanceRequest describeResponse : describeResponses) {
            spotRequestIds.add(describeResponse.getSpotInstanceRequestId());
            if ("active".equals(describeResponse.getState())) {
                instanceIds.add(describeResponse.getInstanceId());
            }
        }
        ec2.cancelSpotInstanceRequests(new CancelSpotInstanceRequestsRequest()
                .withSpotInstanceRequestIds(spotRequestIds));
        log.info("Cancelled spot request");

        if (instanceIds.size() > 0) {
            ec2.terminateInstances(new TerminateInstancesRequest(
                    instanceIds));
            log.info("Shut down " + instanceIds.size() + " instances");
        }

    } catch (Exception e) {
        log.warn("Failed to shutdown instances - ", e);
    }
}
项目:scale.cloudpool    文件:CancelSpotInstanceRequests.java   
@Override
public CancelSpotInstanceRequestsResult call() throws AmazonClientException {
    CancelSpotInstanceRequestsRequest request = new CancelSpotInstanceRequestsRequest()
            .withSpotInstanceRequestIds(this.spotRequestIds);
    CancelSpotInstanceRequestsResult result = getClient().getApi().cancelSpotInstanceRequests(request);
    awaitCancellation(this.spotRequestIds);
    return result;
}
项目:incubator-provisionr    文件:CancelSpotRequests.java   
@Override
public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) {
    @SuppressWarnings("unchecked")
    List<String> requests = (List<String>) execution.getVariable(ProcessVariables.SPOT_INSTANCE_REQUEST_IDS);
    checkNotNull(requests, "process variable '{}' not found", ProcessVariables.SPOT_INSTANCE_REQUEST_IDS);
    if (requests.size() > 0) {
        client.cancelSpotInstanceRequests(new CancelSpotInstanceRequestsRequest()
            .withSpotInstanceRequestIds(requests));
    }
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public CancelSpotInstanceRequestsResult cancelSpotInstanceRequests(CancelSpotInstanceRequestsRequest cancelSpotInstanceRequestsRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:dohko    文件:EC2.java   
public void cancelSpotInstanceOffers(String... spotInstanceOfferIds)
{
    ec2_.cancelSpotInstanceRequests(new CancelSpotInstanceRequestsRequest().withSpotInstanceRequestIds(spotInstanceOfferIds));
}