Example usage for com.amazonaws.services.elasticbeanstalk.model EnvironmentDescription getTier

List of usage examples for com.amazonaws.services.elasticbeanstalk.model EnvironmentDescription getTier

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticbeanstalk.model EnvironmentDescription getTier.

Prototype


public EnvironmentTier getTier() 

Source Link

Document

Describes the current tier of this environment.

Usage

From source file:br.com.ingenieux.jenkins.plugins.awsebdeployment.cmd.ZeroDowntime.java

License:Apache License

private EnvironmentDescription lookupEnvironmentIds(List<String> environmentNames)
        throws InvalidEnvironmentsSizeException, InvalidDeploymentTypeException {
    DescribeEnvironmentsResult environments = getAwseb().describeEnvironments(new DescribeEnvironmentsRequest()
            .withApplicationName(getApplicationName()).withIncludeDeleted(false));

    for (EnvironmentDescription env : environments.getEnvironments()) {
        if (environmentNames.contains(env.getEnvironmentName())) {
            if (WORKER_ENVIRONMENT_TYPE.equals(env.getTier().getName())) {
                throw new InvalidDeploymentTypeException();
            }//from   w  w w.j  a v  a  2  s  .  c om

            return env;
        }
    }

    throw new InvalidEnvironmentsSizeException(getApplicationName(), environmentNames.get(0),
            environments.getEnvironments().size());
}

From source file:br.com.ingenieux.mojo.beanstalk.bg.BluegreenDeploymentMojo.java

License:Apache License

@Override
protected Object executeInternal() throws Exception {
    versionLabel = lookupVersionLabel(applicationName, versionLabel);

    getLog().info(format("Using version %s", versionLabel));

    Collection<EnvironmentDescription> envs = new WaitForEnvironmentCommand(this)
            .lookupInternal(new WaitForEnvironmentContextBuilder().withApplicationName(applicationName)
                    .withEnvironmentRef(environmentNamePrefix + "*").build());

    if (envs.size() > 2) {
        final Collection<String> environmentList = Collections2.transform(envs,
                new Function<EnvironmentDescription, String>() {
                    @Override/* w w w . j a v  a2  s  .  c om*/
                    public String apply(EnvironmentDescription input) {
                        return format("%s[%s]", input.getEnvironmentId(), input.getEnvironmentName());
                    }
                });

        String message = "Ooops. There are multiple environments matching the lookup spec: " + environmentList;

        getLog().warn(message);
        getLog().warn("Will pick one at random anyway as long as it uses WebServer tier name");
    }

    String otherEnvId = null;
    for (EnvironmentDescription e : envs) {
        if (!e.getEnvironmentId().equals(curEnv.getEnvironmentId())
                && "WebServer".equals(e.getTier().getName())) {
            otherEnvId = e.getEnvironmentId();
            break;
        }
    }

    getLog().info(
            format("(Green) Environment with environmentId['%s'] will be prepared once its ready to update",
                    curEnv.getEnvironmentId()));

    new WaitForEnvironmentCommand(this).execute(new WaitForEnvironmentContextBuilder()
            .withStatusToWaitFor("Ready").withApplicationName(applicationName)
            .withEnvironmentRef(curEnv.getEnvironmentId()).build());

    getLog().info(
            format("(Blue) Environment with environmentId['%s'] will be prepared once its ready to update",
                    otherEnvId));

    new WaitForEnvironmentCommand(this)
            .execute(new WaitForEnvironmentContextBuilder().withStatusToWaitFor("Ready")
                    .withApplicationName(applicationName).withEnvironmentRef(otherEnvId).build());

    getLog().info(format("(Blue) Updating environmentId to version %s", versionLabel));

    new UpdateEnvironmentCommand(this).execute(new UpdateEnvironmentContextBuilder()
            .withEnvironmentId(otherEnvId).withVersionLabel(versionLabel).build());

    getLog().info(format("(Blue) Waiting for environmentId['%s'] to get ready and green prior to switching",
            otherEnvId));

    new WaitForEnvironmentCommand(this).execute(new WaitForEnvironmentContextBuilder()
            .withStatusToWaitFor("Ready").withApplicationName(applicationName).withHealth("Green")
            .withEnvironmentRef(otherEnvId).build());

    getLog().info(format("Ok. Switching"));

    getService().swapEnvironmentCNAMEs(new SwapEnvironmentCNAMEsRequest()
            .withDestinationEnvironmentId(curEnv.getEnvironmentId()).withSourceEnvironmentId(otherEnvId));

    getLog().info(format("Done."));

    return null; //To change body of implemented methods use File | Settings | File Templates.
}

From source file:br.com.ingenieux.mojo.beanstalk.cmd.dns.BindDomainsCommand.java

License:Apache License

protected boolean isSingleInstance(EnvironmentDescription env) {
    Validate.isTrue("WebServer".equals(env.getTier().getName()), "Not a Web Server environment!");

    final DescribeConfigurationSettingsResult describeConfigurationSettingsResult = parentMojo.getService()
            .describeConfigurationSettings(
                    new DescribeConfigurationSettingsRequest().withApplicationName(env.getApplicationName())
                            .withEnvironmentName(env.getEnvironmentName()));

    Validate.isTrue(1 == describeConfigurationSettingsResult.getConfigurationSettings().size(),
            "There should be one environment");

    final List<ConfigurationOptionSetting> optionSettings = describeConfigurationSettingsResult
            .getConfigurationSettings().get(0).getOptionSettings();

    for (ConfigurationOptionSetting optionSetting : optionSettings) {
        if (ConfigUtil.optionSettingMatchesP(optionSetting, "aws:elasticbeanstalk:environment",
                "EnvironmentType")) {
            return "SingleInstance".equals(optionSetting.getValue());
        }//from   ww  w  .  j  a  v  a2s  .c  o m
    }

    throw new IllegalStateException("Unreachable code!");
}