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;
}
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);
}
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);
}
}
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;
}
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);
}
}
Aggregations