Search in sources :

Example 1 with Node

use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node in project legacy-jclouds-examples by jclouds.

the class RemoveNodes method getNodes.

private Set<Node> getNodes(LoadBalancer loadBalancer) {
    NodeApi nodeApi = clb.getNodeApiForZoneAndLoadBalancer(Constants.ZONE, loadBalancer.getId());
    Set<Node> nodes = Sets.newHashSet();
    for (Node node : nodeApi.list().concat()) {
        if (node.getAddress().startsWith("10.180.1")) {
            nodes.add(node);
        }
    }
    return nodes;
}
Also used : Node(org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node) NodeApi(org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi)

Example 2 with Node

use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node in project legacy-jclouds-examples by jclouds.

the class RemoveNodes method removeNodesFromLoadBalancer.

private void removeNodesFromLoadBalancer(Set<Node> nodes, LoadBalancer loadBalancer) throws TimeoutException {
    System.out.println("Remove Nodes");
    NodeApi nodeApi = clb.getNodeApiForZoneAndLoadBalancer(Constants.ZONE, loadBalancer.getId());
    Iterable<Integer> nodeIds = Iterables.transform(nodes, new NodeToInteger());
    nodeApi.remove(nodeIds);
    // /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java
    if (!LoadBalancerPredicates.awaitAvailable(lbApi).apply(loadBalancer)) {
        throw new TimeoutException("Timeout on loadBalancer: " + loadBalancer);
    }
    System.out.println("  " + nodeIds);
}
Also used : NodeApi(org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi) TimeoutException(java.util.concurrent.TimeoutException)

Example 3 with Node

use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node in project legacy-jclouds-examples by jclouds.

the class UpdateNodes method updateNodesInLoadBalancer.

private void updateNodesInLoadBalancer(Set<Node> nodes, LoadBalancer loadBalancer) throws TimeoutException {
    System.out.println("Update Nodes");
    NodeApi nodeApi = clb.getNodeApiForZoneAndLoadBalancer(Constants.ZONE, loadBalancer.getId());
    UpdateNode updateNode = UpdateNode.builder().condition(Node.Condition.ENABLED).weight(20).build();
    for (Node node : nodes) {
        nodeApi.update(node.getId(), updateNode);
        System.out.println("  " + node.getId() + " " + updateNode);
    }
    // /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java
    if (!LoadBalancerPredicates.awaitAvailable(lbApi).apply(loadBalancer)) {
        throw new TimeoutException("Timeout on loadBalancer: " + loadBalancer);
    }
}
Also used : UpdateNode(org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode) Node(org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node) UpdateNode(org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode) NodeApi(org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi) TimeoutException(java.util.concurrent.TimeoutException)

Example 4 with Node

use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node in project legacy-jclouds-examples by jclouds.

the class UpdateNodes method getNodes.

private Set<Node> getNodes(LoadBalancer loadBalancer) {
    NodeApi nodeApi = clb.getNodeApiForZoneAndLoadBalancer(Constants.ZONE, loadBalancer.getId());
    Set<Node> nodes = Sets.newHashSet();
    for (Node node : nodeApi.list().concat()) {
        if (node.getCondition().equals(Node.Condition.DISABLED)) {
            nodes.add(node);
        }
    }
    return nodes;
}
Also used : Node(org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node) UpdateNode(org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode) NodeApi(org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi)

Example 5 with Node

use of org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node in project legacy-jclouds-examples by jclouds.

the class AddNodes method addNodesToLoadBalancer.

/**
    * If you try to visit the IPv4 address of the Load Balancer itself, you will see a "Service Unavailable" message 
    * because the nodes from the createNodeRequests() don't really exist.
    * 
    * To see an example of creating Cloud Servers and a Load Balancer at the same time see 
    * CreateLoadBalancerWithNewServers.  
    */
private void addNodesToLoadBalancer(Set<AddNode> addNodes, LoadBalancer loadBalancer) throws TimeoutException {
    System.out.println("Add Nodes");
    NodeApi nodeApi = clb.getNodeApiForZoneAndLoadBalancer(Constants.ZONE, loadBalancer.getId());
    Set<Node> nodes = nodeApi.add(addNodes);
    // /jclouds-example/rackspace/src/main/java/org/jclouds/examples/rackspace/Logging.java
    if (!LoadBalancerPredicates.awaitAvailable(lbApi).apply(loadBalancer)) {
        throw new TimeoutException("Timeout on loadBalancer: " + loadBalancer);
    }
    for (Node node : nodes) {
        System.out.println("  " + node);
    }
}
Also used : AddNode(org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode) Node(org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node) NodeApi(org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

Node (org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node)6 TimeoutException (java.util.concurrent.TimeoutException)5 NodeApi (org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi)5 UpdateNode (org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode)3 AddNode (org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode)2 LoadBalancer (org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer)2 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)1