minor bug fixes plus wiring up

This commit is contained in:
danikov 2011-11-16 09:54:46 +00:00
parent 074f5ffbe7
commit f851271ae3
8 changed files with 68 additions and 7 deletions

View File

@ -21,6 +21,7 @@ package org.jclouds.cloudloadbalancers;
import java.util.Set; import java.util.Set;
import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient; import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient;
import org.jclouds.cloudloadbalancers.features.NodeAsyncClient;
import org.jclouds.location.Region; import org.jclouds.location.Region;
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
@ -55,4 +56,11 @@ public interface CloudLoadBalancersAsyncClient {
LoadBalancerAsyncClient getLoadBalancerClient( LoadBalancerAsyncClient getLoadBalancerClient(
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region); @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
/**
* Provides asynchronous access to Node features.
*/
@Delegate
NodeAsyncClient getNodeClient(
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
} }

View File

@ -22,6 +22,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.cloudloadbalancers.features.LoadBalancerClient; import org.jclouds.cloudloadbalancers.features.LoadBalancerClient;
import org.jclouds.cloudloadbalancers.features.NodeClient;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.location.Region; import org.jclouds.location.Region;
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
@ -57,4 +58,11 @@ public interface CloudLoadBalancersClient {
LoadBalancerClient getLoadBalancerClient( LoadBalancerClient getLoadBalancerClient(
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region); @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
/**
* Provides synchronous access to Node features.
*/
@Delegate
NodeClient getNodeClient(
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) String region);
} }

View File

@ -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 {
}

View File

@ -32,6 +32,8 @@ import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient; import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient;
import org.jclouds.cloudloadbalancers.features.LoadBalancerClient; 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.handlers.ParseCloudLoadBalancersErrorFromHttpResponse;
import org.jclouds.cloudloadbalancers.reference.RackspaceConstants; import org.jclouds.cloudloadbalancers.reference.RackspaceConstants;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
@ -74,6 +76,7 @@ public class CloudLoadBalancersRestClientModule extends
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()// public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
.put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)// .put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)//
.put(NodeClient.class, NodeAsyncClient.class)//
.build(); .build();
public CloudLoadBalancersRestClientModule() { public CloudLoadBalancersRestClientModule() {

View File

@ -19,6 +19,7 @@
package org.jclouds.cloudloadbalancers.domain; package org.jclouds.cloudloadbalancers.domain;
import org.jclouds.cloudloadbalancers.domain.internal.BaseNode; import org.jclouds.cloudloadbalancers.domain.internal.BaseNode;
import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition;
/** /**
* *
@ -42,12 +43,12 @@ public class NodeAttributes {
} }
public static <T extends BaseNode<T>> NodeAttributes fromNode(T n) { public static <T extends BaseNode<T>> 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 class Builder {
public static NodeAttributes condition(String condition) { public static NodeAttributes condition(Condition condition) {
return new NodeAttributes().condition(condition); return new NodeAttributes().condition(condition.name());
} }
public static NodeAttributes weight(int weight) { public static NodeAttributes weight(int weight) {

View File

@ -33,6 +33,8 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.Node;
import org.jclouds.cloudloadbalancers.domain.NodeAttributes; import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
import org.jclouds.cloudloadbalancers.domain.NodeRequest; 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.openstack.filters.AuthenticateRequest;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
@ -118,7 +120,7 @@ public interface NodeAsyncClient {
@Path("/loadbalancers/{lbid}/nodes") @Path("/loadbalancers/{lbid}/nodes")
@ExceptionParser(ReturnVoidOnNotFoundOr404.class) @ExceptionParser(ReturnVoidOnNotFoundOr404.class)
@Consumes("*/*") @Consumes("*/*")
ListenableFuture<Void> removeNode(@PathParam("lbid") int lbid, ListenableFuture<Void> removeNodes(@PathParam("lbid") int lbid,
@QueryParam("id") Set<Integer> nids); @QueryParam("id") Set<Integer> nids);

View File

@ -49,7 +49,8 @@ public interface NodeClient {
* Internet and ServiceNet; as a result, nodes can either be internal ServiceNet addresses or addresses * Internet and ServiceNet; as a result, nodes can either be internal ServiceNet addresses or addresses
* on the public Internet. * on the public Internet.
* *
* * @param lbid
* loadbalancer on which to create the node
* @param n * @param n
* configuration to create * configuration to create
* @return * @return
@ -58,7 +59,7 @@ public interface NodeClient {
* data * data
* *
*/ */
Node createNode(NodeRequest n); Node createNode(int lbid, NodeRequest n);
/** /**
* *

View File

@ -40,7 +40,6 @@ public class UnwrapNodes implements Function<HttpResponse, Set<Node>>,
InvocationContext<UnwrapNodes> { InvocationContext<UnwrapNodes> {
private final ParseJson<Map<String, Set<Node>>> json; private final ParseJson<Map<String, Set<Node>>> json;
private ConvertLB convertLB;
@Inject @Inject
UnwrapNodes(ParseJson<Map<String, Set<Node>>> json) { UnwrapNodes(ParseJson<Map<String, Set<Node>>> json) {