use of com.amazonaws.services.ec2.model.InstanceStateName in project openvidu-loadtest by OpenVidu.
the class Ec2Client method waitUntilInstanceState.
private Instance waitUntilInstanceState(String instanceId, InstanceStateName finalState) {
Instance instance = getInstanceFromId(instanceId);
InstanceState instanceState = instance.getState();
boolean needsWait = true;
if (instanceState.getName().equals(finalState.toString())) {
needsWait = finalState.equals(InstanceStateName.Running) && instance.getPublicDnsName().isBlank();
}
if (needsWait) {
log.info("{} ... Waiting until instance will be {} ... ", instanceState.getName(), finalState);
sleep(WAIT_RUNNING_STATE_MS);
return waitUntilInstanceState(instanceId, finalState);
}
log.info("Instance {} is {}", instance.getPublicDnsName(), finalState);
return instance;
}
Aggregations