use of com.amazonaws.services.ec2.model.DescribeSpotInstanceRequestsRequest in project cloudbreak by hortonworks.
the class ASGroupStatusCheckerTask method checkForSpotRequest.
private void checkForSpotRequest(Activity activity, AmazonEC2 amazonEC2Client) {
if (WAIT_FOR_SPOT_INSTANCES_STATUS_CODE.equals(activity.getStatusCode())) {
Pattern pattern = Pattern.compile(SPOT_ID_PATTERN);
Matcher matcher = pattern.matcher(activity.getStatusMessage());
if (matcher.find()) {
String spotId = matcher.group(0);
DescribeSpotInstanceRequestsResult spotResult = amazonEC2Client.describeSpotInstanceRequests(new DescribeSpotInstanceRequestsRequest().withSpotInstanceRequestIds(spotId));
Optional<SpotInstanceRequest> request = spotResult.getSpotInstanceRequests().stream().findFirst();
if (request.isPresent()) {
if (LOW_SPOT_PRICE_STATUS_CODE.equals(request.get().getStatus().getCode())) {
throw new CloudConnectorException(request.get().getStatus().getMessage());
}
}
}
}
}
Aggregations