Example usage for com.amazonaws.services.elasticloadbalancing.model Instance Instance

List of usage examples for com.amazonaws.services.elasticloadbalancing.model Instance Instance

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticloadbalancing.model Instance Instance.

Prototype

public Instance() 

Source Link

Document

Default constructor for Instance object.

Usage

From source file:com.swap.aws.elb.client.AWSHelper.java

License:Apache License

public Instance transformInstace(com.amazonaws.services.ec2.model.Instance ec2Instance) {
    Instance elbInstance = new Instance();
    elbInstance.setInstanceId(ec2Instance.getInstanceId());
    return elbInstance;
}

From source file:org.apache.stratos.aws.extension.AWSLoadBalancer.java

License:Apache License

private Boolean addClusterMembersInfo(Collection<Member> clusterMembers, String loadBalancerName,
        String region) {/*from www.j a  v a  2  s .  co m*/
    Boolean isUpdated = false;
    // Register instances in the cluster to load balancer
    List<Instance> instances = new ArrayList<Instance>();
    List<String> availabilityZones = new ArrayList<String>();

    for (Member member : clusterMembers) {
        isUpdated = true;
        String instanceId = member.getInstanceId();

        if (log.isDebugEnabled()) {
            log.debug("Instance " + awsHelper.getAWSInstanceName(instanceId)
                    + " needs to be registered to load balancer " + loadBalancerName);
        }

        Instance instance = new Instance();
        instance.setInstanceId(awsHelper.getAWSInstanceName(instanceId));

        instances.add(instance);
        // LB Common Member has a property 'EC2_AVAILABILITY_ZONE' which points to the ec2 availability
        // zone for this member. Use the property value to update the LB about the relevant zone
        String availabilityZone = getEC2AvaialbilityZoneOfMember(member);
        if (availabilityZone != null) {
            availabilityZones.add(availabilityZone);
        }

        // add stickiness policy
        if (awsHelper.getAppStickySessionCookie() != null && !awsHelper.getAppStickySessionCookie().isEmpty()) {
            CreateAppCookieStickinessPolicyResult result = awsHelper.createStickySessionPolicy(loadBalancerName,
                    awsHelper.getAppStickySessionCookie(), Constants.STICKINESS_POLICY, region);

            if (result != null) {
                // Take a single port mapping from a member, and apply the policy for
                // the LB Listener port (Proxy port of the port mapping)
                awsHelper.applyPolicyToLBListenerPorts(member.getPorts(), loadBalancerName,
                        Constants.STICKINESS_POLICY, region);
            }
        }

    }

    awsHelper.registerInstancesToLoadBalancer(loadBalancerName, instances, region);

    // update LB with the zones
    if (!availabilityZones.isEmpty() && !AWSExtensionContext.getInstance().isOperatingInVPC()) {
        awsHelper.addAvailabilityZonesForLoadBalancer(loadBalancerName, availabilityZones, region);
    }
    return isUpdated;
}