mirror of https://github.com/apache/jclouds.git
naming + correct parameter/return type for addNodes
This commit is contained in:
parent
f851271ae3
commit
d44bf5d23e
|
@ -171,7 +171,7 @@ public class Node extends BaseNode<Node> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[id=%s, address=%s, condition=%s, port=%s, weight=%s,status=%s]", id, address, condition,
|
||||
return String.format("[id=%s, address=%s, condition=%s, port=%s, weight=%s, status=%s]", id, address, condition,
|
||||
port, weight, status);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,15 +62,15 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
public interface NodeAsyncClient {
|
||||
|
||||
/**
|
||||
* @see NodeClient#createNode
|
||||
* @see NodeClient#addNodes
|
||||
*/
|
||||
@POST
|
||||
@ResponseParser(UnwrapNode.class)
|
||||
@ResponseParser(UnwrapNodes.class)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
@Path("/loadbalancers/{lbid}/nodes")
|
||||
ListenableFuture<Node> createNode(@PathParam("lbid") int lbid,
|
||||
@WrapWith("node") NodeRequest n);
|
||||
ListenableFuture<Set<Node>> addNodes(@PathParam("lbid") int lbid,
|
||||
@WrapWith("nodes") Set<NodeRequest> nodes);
|
||||
|
||||
/**
|
||||
* @see NodeClient#modifyNode
|
||||
|
|
|
@ -52,14 +52,14 @@ public interface NodeClient {
|
|||
* @param lbid
|
||||
* loadbalancer on which to create the node
|
||||
* @param n
|
||||
* configuration to create
|
||||
* @return
|
||||
* configurations to create
|
||||
* @return created nodes
|
||||
* @throws HttpResponseException
|
||||
* If the corresponding request cannot be fulfilled due to insufficient or invalid
|
||||
* data
|
||||
*
|
||||
*/
|
||||
Node createNode(int lbid, NodeRequest n);
|
||||
Set<Node> addNodes(int lbid, Set<NodeRequest> nodes);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -107,22 +107,24 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
public void testCreateNode() throws Exception {
|
||||
public void testAddNodes() throws Exception {
|
||||
for (LoadBalancer lb : nodes.keySet()) {
|
||||
String region = lb.getRegion();
|
||||
Logger.getAnonymousLogger().info("starting node on loadbalancer "+lb.getId()+" in region "+region);
|
||||
Node n = client.getNodeClient(region).createNode(lb.getId(),
|
||||
NodeRequest.builder().address("192.168.1.1").port(8080).build());
|
||||
assertEquals(lb.getStatus(), Node.Status.ONLINE);
|
||||
nodes.get(lb).add(n);
|
||||
assertEquals(client.getNodeClient(region).getNode(lb.getId(), n.getId()).getStatus(), Node.Status.ONLINE);
|
||||
|
||||
Node newNode = client.getNodeClient(region).getNode(lb.getId(), n.getId());
|
||||
assertEquals(newNode.getStatus(), Node.Status.ONLINE);
|
||||
Set<Node> newNodes = client.getNodeClient(region).addNodes(lb.getId(), Collections.<NodeRequest>singleton(
|
||||
NodeRequest.builder().address("192.168.1.2").port(8080).build()));
|
||||
|
||||
for (Node n : newNodes) {
|
||||
assertEquals(n.getStatus(), Node.Status.ONLINE);
|
||||
nodes.get(lb).add(n);
|
||||
assertEquals(client.getNodeClient(region).getNode(lb.getId(), n.getId()).getStatus(), Node.Status.ONLINE);
|
||||
}
|
||||
|
||||
assert loadBalancerActive.apply(lb) : lb;
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateNode")
|
||||
@Test(dependsOnMethods = "testAddNodes")
|
||||
public void testModifyNode() throws Exception {
|
||||
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
|
||||
for (Node n : entry.getValue()) {
|
||||
|
|
Loading…
Reference in New Issue