From 6365190448c4adbe7250af1dc87c373c22520cbb Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 16 Nov 2011 19:03:46 +0000 Subject: [PATCH] rename/reorder methods/parameters as per review --- .../features/NodeAsyncClient.java | 30 ++++++++-------- .../features/NodeClient.java | 36 +++++++++---------- .../features/NodeAsyncClientTest.java | 32 +++++++++-------- .../features/NodeClientLiveTest.java | 17 ++++----- 4 files changed, 59 insertions(+), 56 deletions(-) diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClient.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClient.java index e04b54d2c2..411ab43d45 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClient.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClient.java @@ -60,25 +60,25 @@ import com.google.common.util.concurrent.ListenableFuture; public interface NodeAsyncClient { /** - * @see NodeClient#addNodes + * @see NodeClient#createNodesInLoadBalancer */ @POST @SelectJson("nodes") @Consumes(MediaType.APPLICATION_JSON) @ExceptionParser(ReturnNullOnNotFoundOr404.class) @Path("/loadbalancers/{lbid}/nodes") - ListenableFuture> addNodes(@PathParam("lbid") int lbid, - @WrapWith("nodes") Set nodes); + ListenableFuture> createNodesInLoadBalancer(@WrapWith("nodes") Set nodes, + @PathParam("lbid") int lbid); /** - * @see NodeClient#modifyNode + * @see NodeClient#updateAttributesForNodeInLoadBalancer */ @PUT @Consumes(MediaType.APPLICATION_JSON) @Path("/loadbalancers/{lbid}/nodes/{nid}") - ListenableFuture modifyNode(@PathParam("lbid") int lbid, + ListenableFuture updateAttributesForNodeInLoadBalancer(@WrapWith("node") NodeAttributes attrs, @PathParam("nid") int nid, - @WrapWith("node") NodeAttributes attrs); + @PathParam("lbid") int lbid); /** * @see NodeClient#listNodes @@ -91,35 +91,35 @@ public interface NodeAsyncClient { ListenableFuture> listNodes(@PathParam("lbid") int lbid); /** - * @see NodeClient#getNode + * @see NodeClient#getNodeInLoadBalancer */ @GET @SelectJson("node") @Consumes(MediaType.APPLICATION_JSON) @Path("/loadbalancers/{lbid}/nodes/{nid}") @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getNode(@PathParam("lbid") int lbid, - @PathParam("nid") int nid); + ListenableFuture getNodeInLoadBalancer(@PathParam("nid") int nid, + @PathParam("lbid") int lbid); /** - * @see NodeClient#removeNode + * @see NodeClient#removeNodeFromLoadBalancer */ @DELETE @Path("/loadbalancers/{lbid}/nodes/{nid}") @ExceptionParser(ReturnVoidOnNotFoundOr404.class) @Consumes("*/*") - ListenableFuture removeNode(@PathParam("lbid") int lbid, - @PathParam("nid") int nid); + ListenableFuture removeNodeFromLoadBalancer(@PathParam("nid") int nid, + @PathParam("lbid") int lbid); /** - * @see NodeClient#removeNode + * @see NodeClient#removeNodesFromLoadBalancer */ @DELETE @Path("/loadbalancers/{lbid}/nodes") @ExceptionParser(ReturnVoidOnNotFoundOr404.class) @Consumes("*/*") - ListenableFuture removeNodes(@PathParam("lbid") int lbid, - @QueryParam("id") Set nids); + ListenableFuture removeNodesFromLoadBalancer(@QueryParam("id") Set nids, + @PathParam("lbid") int lbid); } diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/features/NodeClient.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/features/NodeClient.java index 6de2bc9e22..118553130a 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/features/NodeClient.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/features/NodeClient.java @@ -49,17 +49,17 @@ public interface NodeClient { * Internet and ServiceNet; as a result, nodes can either be internal ServiceNet addresses or addresses * on the public Internet. * - * @param lbid - * loadbalancer on which to create the node - * @param n + * @param nodes * configurations to create + * @param lbid + * loadbalancer on which to create the nodes * @return created nodes * @throws HttpResponseException * If the corresponding request cannot be fulfilled due to insufficient or invalid * data * */ - Set addNodes(int lbid, Set nodes); + Set createNodesInLoadBalancer(Set nodes, int lbid); /** * @@ -71,16 +71,16 @@ public interface NodeClient { * A caller can poll the load balancer with its ID to wait for the changes to be applied and the * load balancer to return to an ACTIVE status. * - * @param lbid - * loadbalancer from which to get the node - * @param nid - * node to get * @param attrs * what to change + * @param nid + * node to get + * @param lbid + * loadbalancer from which to get the node * * @see LoadBalancerAttributes#fromLoadBalancer */ - void modifyNode(int lbid, int nid, NodeAttributes attrs); + void updateAttributesForNodeInLoadBalancer(NodeAttributes attrs, int nid, int lbid); /** * @@ -94,13 +94,13 @@ public interface NodeClient { /** * * - * @param lbid - * loadbalancer from which to get the node * @param nid * node to get + * @param lbid + * loadbalancer from which to get the node * @return details of the specified node, or null if not found */ - Node getNode(int lbid, int nid); + Node getNodeInLoadBalancer(int nid, int lbid); /** * Remove a node from the account. @@ -109,12 +109,12 @@ public interface NodeClient { * configuration from the account. Any and all configuration data is immediately purged and is * not recoverable. * - * @param lbid - * loadbalancer from which to remove the node * @param nid * node to remove + * @param lbid + * loadbalancer from which to remove the node */ - void removeNode(int lbid, int nid); + void removeNodeFromLoadBalancer(int nid, int lbid); /** * Batch-remove nodes from the account. @@ -124,10 +124,10 @@ public interface NodeClient { * cannot be removed due to its current status a 400:BadRequest is returned along with the ids * of the ones the system identified as potential failures for this request * + * @param nids + * nodes to remove * @param lbid * loadbalancer from which to remove the node - * @param nid - * node to remove */ - void removeNodes(int lbid, Set nids); + void removeNodesFromLoadBalancer(Set nids, int lbid); } diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java index 28ba926a26..3a8f43049f 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java @@ -23,7 +23,9 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.io.IOException; import java.lang.reflect.Method; +import java.util.Collections; import java.util.Properties; +import java.util.Set; import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; @@ -72,9 +74,9 @@ public class NodeAsyncClientTest extends BaseCloudLoadBalancersAsyncClientTestsingleton(NodeRequest.builder(). + address("192.168.1.1").port(8080).build()), 3); assertRequestLineEquals(httpRequest, "POST https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234/loadbalancers/3/nodes HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertPayloadEquals( httpRequest, - "{\"node\":{\"address\":\"192.168.1.1\",\"port\":8080,\"condition\":\"ENABLED\"}}", + "{\"nodes\":[{\"address\":\"192.168.1.1\",\"port\":8080,\"condition\":\"ENABLED\"}]}", "application/json", false); assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class); @@ -110,10 +112,10 @@ public class NodeAsyncClientTest extends BaseCloudLoadBalancersAsyncClientTest newNodes = client.getNodeClient(region).addNodes(lb.getId(), Collections.singleton( - NodeRequest.builder().address("192.168.1.2").port(8080).build())); + Set newNodes = client.getNodeClient(region).createNodesInLoadBalancer(Collections.singleton( + NodeRequest.builder().address("192.168.1.2").port(8080).build()), lb.getId()); 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); + assertEquals(client.getNodeClient(region).getNodeInLoadBalancer(n.getId(), lb.getId()).getStatus(), Node.Status.ONLINE); } assert loadBalancerActive.apply(lb) : lb; @@ -125,12 +126,12 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest { for (Entry> entry : nodes.entrySet()) { for (Node n : entry.getValue()) { String region = entry.getKey().getRegion(); - client.getNodeClient(region).modifyNode(entry.getKey().getId(), n.getId(), - NodeAttributes.Builder.weight(23)); + client.getNodeClient(region).updateAttributesForNodeInLoadBalancer(NodeAttributes.Builder.weight(23), + n.getId(), entry.getKey().getId()); assertEquals(client.getNodeClient(region) - .getNode(entry.getKey().getId(), n.getId()).getStatus(), Node.Status.ONLINE); + .getNodeInLoadBalancer(n.getId(), entry.getKey().getId()).getStatus(), Node.Status.ONLINE); - Node newNode = client.getNodeClient(region).getNode(entry.getKey().getId(), n.getId()); + Node newNode = client.getNodeClient(region).getNodeInLoadBalancer(n.getId(), entry.getKey().getId()); assertEquals(newNode.getStatus(), Node.Status.ONLINE); assertEquals(newNode.getWeight(), (Integer)23); }