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

View File

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

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.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<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
.put(LoadBalancerClient.class, LoadBalancerAsyncClient.class)//
.put(NodeClient.class, NodeAsyncClient.class)//
.build();
public CloudLoadBalancersRestClientModule() {

View File

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

View File

@ -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<Void> removeNode(@PathParam("lbid") int lbid,
ListenableFuture<Void> removeNodes(@PathParam("lbid") int lbid,
@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
* 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);
/**
*

View File

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