use of software.amazon.awssdk.services.ec2.model.StopInstancesRequest in project onebusaway-application-modules by camsys.
the class BundleServerServiceImpl method stop.
@Override
public String stop(String instanceId) {
if (!_isAws) {
return LOCAL_HOST;
}
if (LOCAL_HOST.equalsIgnoreCase(instanceId)) {
return instanceId;
}
List<String> instances = new ArrayList<String>();
instances.add(instanceId);
StopInstancesRequest stopInstancesRequest = new StopInstancesRequest(instances);
StopInstancesResult stopInstancesResult = _ec2.stopInstances(stopInstancesRequest);
InstanceStateChange change = null;
if (!stopInstancesResult.getStoppingInstances().isEmpty()) {
change = stopInstancesResult.getStoppingInstances().get(0);
_log.info("from state=" + change.getPreviousState() + " to state=" + change.getCurrentState());
return change.getInstanceId();
}
return null;
}
Aggregations