Java 类com.amazonaws.services.elasticloadbalancing.model.CreateLoadBalancerResult 实例源码

项目:photon-model    文件:AWSLoadBalancerService.java   
private DeferredResult<AWSLoadBalancerContext> createLoadBalancer(
        AWSLoadBalancerContext context) {
    CreateLoadBalancerRequest request = buildCreationRequest(context);

    String message = "Create a new AWS Load Balancer with name ["
            + context.loadBalancerStateExpanded.name + "].";
    AWSDeferredResultAsyncHandler<CreateLoadBalancerRequest, CreateLoadBalancerResult> handler =
            new AWSDeferredResultAsyncHandler<>(this, message);

    context.client.createLoadBalancerAsync(request, handler);

    return handler.toDeferredResult().thenApply(result -> {
        context.loadBalancerStateExpanded.address = result.getDNSName();
        return context;
    });
}
项目:photon-model    文件:TestAWSSetupUtils.java   
public static String provisionAWSLoadBalancerWithEC2Client(VerificationHost host,
        AmazonElasticLoadBalancingAsyncClient client,
        String name, String subnetId, String securityGroupId, List<String> instanceIds) {

    if (name == null) {
        name = LOAD_BALANCER_NAME_PREFIX + System.currentTimeMillis();
    }

    Listener defaultListener = new Listener().withInstancePort(80)
            .withInstanceProtocol("HTTP")
            .withLoadBalancerPort(80)
            .withProtocol("HTTP");

    CreateLoadBalancerRequest request = new CreateLoadBalancerRequest()
            .withLoadBalancerName(name)
            .withSubnets(Collections.singletonList(subnetId))
            .withSecurityGroups(Collections.singleton(securityGroupId))
            .withListeners(Collections.singleton(defaultListener));

    CreateLoadBalancerResult result = null;
    try {
        result = client.createLoadBalancer(request);
    } catch (Exception e) {
        host.log(Level.SEVERE, "Error encountered in provisioning load balancer on AWS: %s",
                Utils.toString(e));
    }
    assertNotNull(result);
    assertNotNull(result.getDNSName());

    if (instanceIds != null) {
        registerAWSInstancesToLoadBalancer(host, client, name, instanceIds);
    }

    return name;
}
项目:cloud-runner    文件:ElasticLoadBalancing.java   
public static String createNewLoadBalancer(String name,
        Listener... listeners) {
    if (name == null || name.trim().length() == 0)
        throw new RuntimeException(
                "The name of the load balancer cannot be empty!");

    connect();

    CreateLoadBalancerRequest req = new CreateLoadBalancerRequest();

    req.setLoadBalancerName(name);

    if (listeners != null && listeners.length > 0) {
        ArrayList<com.amazonaws.services.elasticloadbalancing.model.Listener> actualListeners = new ArrayList<com.amazonaws.services.elasticloadbalancing.model.Listener>();
        for (Listener listener : listeners)
            actualListeners
                    .add(new com.amazonaws.services.elasticloadbalancing.model.Listener(
                            listener.protocol, listener.port, listener.port));
        req.setListeners(actualListeners);
    }

    ArrayList<String> securityGroups = new ArrayList<String>();
    securityGroups.add(AmazonEC2.getSecurityGroupId());
    req.setSecurityGroups(securityGroups);

    req.setAvailabilityZones(AmazonEC2.getAllAvailabilityZones());

    CreateLoadBalancerResult res = client.createLoadBalancer(req);

    return res.getDNSName();
}
项目:sequenceiq-samples    文件:AutoScalingService.java   
CreateLoadBalancerResult createLoadBalancer(AWSCredentials credentials, String name, String... zones);