From f851271ae3d56d1549e62cd3723ad6207ced97f1 Mon Sep 17 00:00:00 2001 From: danikov Date: Wed, 16 Nov 2011 09:54:46 +0000 Subject: [PATCH] minor bug fixes plus wiring up --- .../CloudLoadBalancersAsyncClient.java | 8 ++++ .../CloudLoadBalancersClient.java | 8 ++++ .../org/jclouds/cloudloadbalancers/Node.java | 39 +++++++++++++++++++ .../CloudLoadBalancersRestClientModule.java | 3 ++ .../domain/NodeAttributes.java | 7 ++-- .../features/NodeAsyncClient.java | 4 +- .../features/NodeClient.java | 5 ++- .../functions/UnwrapNodes.java | 1 - 8 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/Node.java diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClient.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClient.java index 9e7a3c241b..c2b8dfbceb 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClient.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersAsyncClient.java @@ -21,6 +21,7 @@ package org.jclouds.cloudloadbalancers; import java.util.Set; import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient; +import org.jclouds.cloudloadbalancers.features.NodeAsyncClient; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; import org.jclouds.rest.annotations.Delegate; @@ -54,5 +55,12 @@ public interface CloudLoadBalancersAsyncClient { @Delegate LoadBalancerAsyncClient getLoadBalancerClient( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region); + + /** + * Provides asynchronous access to Node features. + */ + @Delegate + NodeAsyncClient getNodeClient( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region); } diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersClient.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersClient.java index 2c4eb444d9..4d879a153b 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersClient.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersClient.java @@ -22,6 +22,7 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.cloudloadbalancers.features.LoadBalancerClient; +import org.jclouds.cloudloadbalancers.features.NodeClient; import org.jclouds.concurrent.Timeout; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; @@ -56,5 +57,12 @@ public interface CloudLoadBalancersClient { @Delegate LoadBalancerClient getLoadBalancerClient( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region); + + /** + * Provides synchronous access to Node features. + */ + @Delegate + NodeClient getNodeClient( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region); } diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/Node.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/Node.java new file mode 100644 index 0000000000..4b477b5b5b --- /dev/null +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/Node.java @@ -0,0 +1,39 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudloadbalancers; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * Represents a Node endpoint + * + * @author Dan Lo Bianco + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface Node { + +} \ No newline at end of file diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java index 902c4f6669..b5550ded5e 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java @@ -32,6 +32,8 @@ import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient; import org.jclouds.cloudloadbalancers.features.LoadBalancerClient; +import org.jclouds.cloudloadbalancers.features.NodeAsyncClient; +import org.jclouds.cloudloadbalancers.features.NodeClient; import org.jclouds.cloudloadbalancers.handlers.ParseCloudLoadBalancersErrorFromHttpResponse; import org.jclouds.cloudloadbalancers.reference.RackspaceConstants; import org.jclouds.http.HttpErrorHandler; @@ -74,6 +76,7 @@ public class CloudLoadBalancersRestClientModule extends public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// .put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)// + .put(NodeClient.class, NodeAsyncClient.class)// .build(); public CloudLoadBalancersRestClientModule() { diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/NodeAttributes.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/NodeAttributes.java index df8dc50e39..5b6ad863b7 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/NodeAttributes.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/domain/NodeAttributes.java @@ -19,6 +19,7 @@ package org.jclouds.cloudloadbalancers.domain; import org.jclouds.cloudloadbalancers.domain.internal.BaseNode; +import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition; /** * @@ -42,12 +43,12 @@ public class NodeAttributes { } public static > NodeAttributes fromNode(T n) { - return Builder.condition(n.getCondition().name()).weight(n.getWeight()); + return Builder.condition(n.getCondition()).weight(n.getWeight()); } public static class Builder { - public static NodeAttributes condition(String condition) { - return new NodeAttributes().condition(condition); + public static NodeAttributes condition(Condition condition) { + return new NodeAttributes().condition(condition.name()); } public static NodeAttributes weight(int weight) { 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 6546b34414..028c7dff94 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 @@ -33,6 +33,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.NodeAttributes; import org.jclouds.cloudloadbalancers.domain.NodeRequest; +import org.jclouds.cloudloadbalancers.functions.UnwrapNode; +import org.jclouds.cloudloadbalancers.functions.UnwrapNodes; import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; @@ -118,7 +120,7 @@ public interface NodeAsyncClient { @Path("/loadbalancers/{lbid}/nodes") @ExceptionParser(ReturnVoidOnNotFoundOr404.class) @Consumes("*/*") - ListenableFuture removeNode(@PathParam("lbid") int lbid, + ListenableFuture removeNodes(@PathParam("lbid") int lbid, @QueryParam("id") Set nids); 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 9996fd3404..2e0e1c1081 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,7 +49,8 @@ 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 * configuration to create * @return @@ -58,7 +59,7 @@ public interface NodeClient { * data * */ - Node createNode(NodeRequest n); + Node createNode(int lbid, NodeRequest n); /** * diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/UnwrapNodes.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/UnwrapNodes.java index 62b3a98198..ebb7a538ec 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/UnwrapNodes.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/UnwrapNodes.java @@ -40,7 +40,6 @@ public class UnwrapNodes implements Function>, InvocationContext { private final ParseJson>> json; - private ConvertLB convertLB; @Inject UnwrapNodes(ParseJson>> json) {