Search in sources :

Example 1 with InstanceStateName

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;
}
Also used : InstanceState(com.amazonaws.services.ec2.model.InstanceState) Instance(com.amazonaws.services.ec2.model.Instance)

Aggregations

Instance (com.amazonaws.services.ec2.model.Instance)1 InstanceState (com.amazonaws.services.ec2.model.InstanceState)1