com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentsRequest Java Examples

The following examples show how to use com.amazonaws.services.elasticbeanstalk.model.DescribeEnvironmentsRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestSuccessfulBeanstalkDeploymentTask.java    From aws-ant-tasks with Apache License 2.0 6 votes vote down vote up
public void execute() {
    checkParams();
    AWSElasticBeanstalkClient bcClient = getOrCreateClient(AWSElasticBeanstalkClient.class);
    DescribeEnvironmentsRequest deRequest = new DescribeEnvironmentsRequest()
            .withEnvironmentNames(environmentName);
    DescribeEnvironmentsResult result = bcClient
            .describeEnvironments(deRequest);
    if (result.getEnvironments().size() < 1) {
        throw new BuildException(
                "No environments found with the specified name "
                        + environmentName);
    }
    try {
        AWSTestUtils.waitForEnvironmentToTransitionToStateAndHealth(
                environmentName, EnvironmentStatus.Ready, null, bcClient);
    } catch (InterruptedException e) {
        throw new BuildException(e.getMessage());
    }
}
 
Example #2
Source File: AWSTestUtils.java    From aws-ant-tasks with Apache License 2.0 5 votes vote down vote up
public static void waitForEnvironmentToTransitionToStateAndHealth(
        String environmentName, EnvironmentStatus state,
        EnvironmentHealth health, AWSElasticBeanstalkClient bcClient)
        throws InterruptedException {
    System.out.println("Waiting for instance " + environmentName
            + " to transition to " + state + "/" + health);

    int count = 0;
    while (true) {
        Thread.sleep(1000 * 30);
        if (count++ > 100) {
            throw new RuntimeException("Environment " + environmentName
                    + " never transitioned to " + state + "/" + health);
        }

        List<EnvironmentDescription> environments = bcClient
                .describeEnvironments(
                        new DescribeEnvironmentsRequest()
                                .withEnvironmentNames(environmentName))
                .getEnvironments();

        if (environments.size() == 0) {
            System.out
                    .println("No environments with that name were found.");
            return;
        }

        EnvironmentDescription environment = environments.get(0);
        System.out.println(" - " + environment.getStatus() + "/"
                + environment.getHealth());
        if (environment.getStatus().equalsIgnoreCase(state.toString()) == false)
            continue;
        if (health != null
                && environment.getHealth().equalsIgnoreCase(
                        health.toString()) == false)
            continue;
        return;
    }
}