use of software.amazon.awssdk.services.ec2.model.InstanceStateChange 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;
}
use of software.amazon.awssdk.services.ec2.model.InstanceStateChange in project onebusaway-application-modules by camsys.
the class BundleServerServiceImpl method start.
@Override
public String start(String instanceId) {
if (!_isAws) {
return LOCAL_HOST;
}
if (LOCAL_HOST.equalsIgnoreCase(instanceId)) {
return instanceId;
}
List<String> instances = new ArrayList<String>();
instances.add(instanceId);
StartInstancesRequest startInstancesRequest = new StartInstancesRequest(instances);
StartInstancesResult startInstancesResult = _ec2.startInstances(startInstancesRequest);
InstanceStateChange change = null;
if (!startInstancesResult.getStartingInstances().isEmpty()) {
change = startInstancesResult.getStartingInstances().get(0);
_log.info("from state=" + change.getPreviousState() + " to state=" + change.getCurrentState());
return change.getInstanceId();
}
return null;
}
Aggregations