Renamed Rackspace Cloud Load Balanacer domain objects with verb first.

This commit is contained in:
Everett Toews 2013-03-18 16:55:53 -05:00
parent 3d6a2a634f
commit d8b82401ea
22 changed files with 263 additions and 212 deletions

View File

@ -49,13 +49,13 @@ import com.google.common.base.Objects.ToStringHelper;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class NodeAdd extends BaseNode<NodeAdd> { public class AddNode extends BaseNode<AddNode> {
// for serialization only // for serialization only
NodeAdd() { AddNode() {
} }
public NodeAdd(String address, int port, Condition condition, Type type, Integer weight) { public AddNode(String address, int port, Condition condition, Type type, Integer weight) {
super(address, port, condition, type, weight); super(address, port, condition, type, weight);
} }
@ -79,18 +79,12 @@ public class NodeAdd extends BaseNode<NodeAdd> {
if (this == obj) return true; if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false; if (obj == null || getClass() != obj.getClass()) return false;
NodeAdd that = NodeAdd.class.cast(obj); AddNode that = AddNode.class.cast(obj);
return Objects.equal(this.address, that.address) return Objects.equal(this.address, that.address)
&& Objects.equal(this.port, that.port); && Objects.equal(this.port, that.port);
} }
public static class Builder extends BaseNode.Builder<NodeAdd> { public static class Builder extends BaseNode.Builder<AddNode> {
@Override
public NodeAdd build() {
return new NodeAdd(address, port, condition, type, weight);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -130,8 +124,14 @@ public class NodeAdd extends BaseNode<NodeAdd> {
public Builder weight(Integer weight) { public Builder weight(Integer weight) {
return Builder.class.cast(super.weight(weight)); return Builder.class.cast(super.weight(weight));
} }
@Override @Override
public Builder from(NodeAdd in) { public AddNode build() {
return new AddNode(address, port, condition, type, weight);
}
@Override
public Builder from(AddNode in) {
return Builder.class.cast(super.from(in)); return Builder.class.cast(super.from(in));
} }
} }

View File

@ -37,30 +37,30 @@ import com.google.common.collect.ImmutableSet;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class LoadBalancerCreate extends BaseLoadBalancer<NodeAdd, LoadBalancerCreate> { public class CreateLoadBalancer extends BaseLoadBalancer<AddNode, CreateLoadBalancer> {
private final Set<Map<String, String>> virtualIps; private final Set<Map<String, String>> virtualIps;
private final Set<AccessRule> accessRules; private final Set<AccessRule> accessRules;
private final Map<String, String> metadata; private final Map<String, String> metadata;
public LoadBalancerCreate(String name, String protocol, @Nullable Integer port, Set<NodeAdd> nodeAdds, public CreateLoadBalancer(String name, String protocol, @Nullable Integer port, Set<AddNode> addNodes,
@Nullable Algorithm algorithm, @Nullable Integer timeout, @Nullable Boolean halfClosed, @Nullable Algorithm algorithm, @Nullable Integer timeout, @Nullable Boolean halfClosed,
@Nullable Map<String, SessionPersistence> sessionPersistenceType, @Nullable Map<String, SessionPersistence> sessionPersistenceType,
@Nullable Map<String, Boolean> connectionLogging, @Nullable ConnectionThrottle connectionThrottle, @Nullable Map<String, Boolean> connectionLogging, @Nullable ConnectionThrottle connectionThrottle,
@Nullable HealthMonitor healthMonitor, @Nullable Set<AccessRule> accessRules, @Nullable HealthMonitor healthMonitor, @Nullable Set<AccessRule> accessRules,
@Nullable Map<String, String> metadata, VirtualIP.Type virtualIPType, Integer virtualIPId) { @Nullable Map<String, String> metadata, VirtualIP.Type virtualIPType, Integer virtualIPId) {
this(name, protocol, port, nodeAdds, algorithm, timeout, halfClosed, sessionPersistenceType, connectionLogging, this(name, protocol, port, addNodes, algorithm, timeout, halfClosed, sessionPersistenceType, connectionLogging,
connectionThrottle, healthMonitor, accessRules, metadata, connectionThrottle, healthMonitor, accessRules, metadata,
getVirtualIPsFromOptions(virtualIPType, virtualIPId)); getVirtualIPsFromOptions(virtualIPType, virtualIPId));
} }
public LoadBalancerCreate(String name, String protocol, @Nullable Integer port, Set<NodeAdd> nodeAdds, public CreateLoadBalancer(String name, String protocol, @Nullable Integer port, Set<AddNode> addNodes,
@Nullable Algorithm algorithm, @Nullable Integer timeout, @Nullable Boolean halfClosed, @Nullable Algorithm algorithm, @Nullable Integer timeout, @Nullable Boolean halfClosed,
@Nullable Map<String, SessionPersistence> sessionPersistenceType, @Nullable Map<String, SessionPersistence> sessionPersistenceType,
@Nullable Map<String, Boolean> connectionLogging, @Nullable ConnectionThrottle connectionThrottle, @Nullable Map<String, Boolean> connectionLogging, @Nullable ConnectionThrottle connectionThrottle,
@Nullable HealthMonitor healthMonitor, @Nullable Set<AccessRule> accessRules, @Nullable HealthMonitor healthMonitor, @Nullable Set<AccessRule> accessRules,
@Nullable Map<String, String> metadata, Set<Map<String, String>> virtualIPsFromOptions) { @Nullable Map<String, String> metadata, Set<Map<String, String>> virtualIPsFromOptions) {
super(name, protocol, port, nodeAdds, algorithm, timeout, halfClosed, sessionPersistenceType, connectionLogging, super(name, protocol, port, addNodes, algorithm, timeout, halfClosed, sessionPersistenceType, connectionLogging,
connectionThrottle, healthMonitor); connectionThrottle, healthMonitor);
this.virtualIps = checkNotNull(virtualIPsFromOptions, "virtualIPsFromOptions"); this.virtualIps = checkNotNull(virtualIPsFromOptions, "virtualIPsFromOptions");
this.accessRules = accessRules; this.accessRules = accessRules;
@ -100,7 +100,7 @@ public class LoadBalancerCreate extends BaseLoadBalancer<NodeAdd, LoadBalancerCr
return string().toString(); return string().toString();
} }
public static class Builder extends BaseLoadBalancer.Builder<NodeAdd, LoadBalancerCreate> { public static class Builder extends BaseLoadBalancer.Builder<AddNode, CreateLoadBalancer> {
private VirtualIP.Type virtualIPType; private VirtualIP.Type virtualIPType;
private Integer virtualIPId; private Integer virtualIPId;
private Set<Map<String, String>> virtualIps; private Set<Map<String, String>> virtualIps;
@ -150,14 +150,14 @@ public class LoadBalancerCreate extends BaseLoadBalancer<NodeAdd, LoadBalancerCr
return this; return this;
} }
public LoadBalancerCreate build() { public CreateLoadBalancer build() {
if (virtualIps == null) { if (virtualIps == null) {
return new LoadBalancerCreate(name, protocol, port, nodes, algorithm, timeout, halfClosed, return new CreateLoadBalancer(name, protocol, port, nodes, algorithm, timeout, halfClosed,
sessionPersistence, connectionLogging, connectionThrottle, healthMonitor, accessRules, metadata, sessionPersistence, connectionLogging, connectionThrottle, healthMonitor, accessRules, metadata,
virtualIPType, virtualIPId); virtualIPType, virtualIPId);
} }
else { else {
return new LoadBalancerCreate(name, protocol, port, nodes, algorithm, timeout, halfClosed, return new CreateLoadBalancer(name, protocol, port, nodes, algorithm, timeout, halfClosed,
sessionPersistence, connectionLogging, connectionThrottle, healthMonitor, accessRules, metadata, sessionPersistence, connectionLogging, connectionThrottle, healthMonitor, accessRules, metadata,
virtualIps); virtualIps);
} }
@ -167,8 +167,8 @@ public class LoadBalancerCreate extends BaseLoadBalancer<NodeAdd, LoadBalancerCr
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public Builder nodes(Iterable<NodeAdd> nodeAdds) { public Builder nodes(Iterable<AddNode> addNodes) {
this.nodes = ImmutableSet.<NodeAdd> copyOf(checkNotNull(nodeAdds, "nodes")); this.nodes = ImmutableSet.<AddNode> copyOf(checkNotNull(addNodes, "nodes"));
return this; return this;
} }
@ -176,7 +176,7 @@ public class LoadBalancerCreate extends BaseLoadBalancer<NodeAdd, LoadBalancerCr
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public Builder node(NodeAdd nodes) { public Builder node(AddNode nodes) {
this.nodes.add(checkNotNull(nodes, "nodes")); this.nodes.add(checkNotNull(nodes, "nodes"));
return this; return this;
} }
@ -217,7 +217,7 @@ public class LoadBalancerCreate extends BaseLoadBalancer<NodeAdd, LoadBalancerCr
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public Builder from(LoadBalancerCreate in) { public Builder from(CreateLoadBalancer in) {
return Builder.class.cast(super.from(in)).virtualIPs(in.virtualIps); return Builder.class.cast(super.from(in)).virtualIPs(in.virtualIps);
} }
} }

View File

@ -27,45 +27,48 @@ import com.google.common.base.Objects.ToStringHelper;
/** /**
* Used to update Load Balancers. * Used to update Load Balancers.
* *
* @author Adrian Cole * @author Everett Toews
*/ */
public class LoadBalancerUpdate { public class UpdateLoadBalancer {
private String name;
protected String name; private String protocol;
protected String protocol; private Integer port;
protected Integer port; private Algorithm algorithm;
protected Algorithm algorithm; private Integer timeout;
protected Integer timeout; private Boolean halfClosed;
protected Boolean halfClosed;
protected UpdateLoadBalancer(String name, String protocol, Integer port, Algorithm algorithm, Integer timeout,
public LoadBalancerUpdate name(String name) { Boolean halfClosed) {
this.name = name; this.name = name;
return this;
}
public LoadBalancerUpdate protocol(String protocol) {
this.protocol = protocol; this.protocol = protocol;
return this;
}
public LoadBalancerUpdate port(Integer port) {
this.port = port; this.port = port;
return this;
}
public LoadBalancerUpdate algorithm(Algorithm algorithm) {
this.algorithm = algorithm; this.algorithm = algorithm;
return this;
}
public LoadBalancerUpdate timeout(Integer timeout) {
this.timeout = timeout; this.timeout = timeout;
return this; this.halfClosed = halfClosed;
} }
public LoadBalancerUpdate halfClosed(Boolean halfClosed) { public String getName() {
this.halfClosed = halfClosed; return name;
return this; }
public String getProtocol() {
return protocol;
}
public Integer getPort() {
return port;
}
public Algorithm getAlgorithm() {
return algorithm;
}
public Integer getTimeout() {
return timeout;
}
public Boolean isHalfClosed() {
return halfClosed;
} }
protected ToStringHelper string() { protected ToStringHelper string() {
@ -90,58 +93,83 @@ public class LoadBalancerUpdate {
if (obj == null || getClass() != obj.getClass()) if (obj == null || getClass() != obj.getClass())
return false; return false;
LoadBalancerUpdate that = LoadBalancerUpdate.class.cast(obj); UpdateLoadBalancer that = UpdateLoadBalancer.class.cast(obj);
return Objects.equal(this.name, that.name) && Objects.equal(this.algorithm, that.algorithm) return Objects.equal(this.name, that.name) && Objects.equal(this.algorithm, that.algorithm)
&& Objects.equal(this.port, that.port) && Objects.equal(this.protocol, that.protocol) && Objects.equal(this.port, that.port) && Objects.equal(this.protocol, that.protocol)
&& Objects.equal(this.timeout, that.timeout) && Objects.equal(this.halfClosed, that.halfClosed); && Objects.equal(this.timeout, that.timeout) && Objects.equal(this.halfClosed, that.halfClosed);
} }
public static class Builder { public static class Builder {
private String name;
private String protocol;
private Integer port;
private Algorithm algorithm;
private Integer timeout;
private Boolean halfClosed;
/** /**
* @see BaseLoadBalancer.Builder#name(String) * @see BaseLoadBalancer.Builder#name(String)
*/ */
public static LoadBalancerUpdate name(String name) { public Builder name(String name) {
return new LoadBalancerUpdate().name(name); this.name = name;
return this;
} }
/** /**
* @see BaseLoadBalancer.Builder#protocol(String) * @see BaseLoadBalancer.Builder#protocol(String)
*/ */
public static LoadBalancerUpdate protocol(String protocol) { public Builder protocol(String protocol) {
return new LoadBalancerUpdate().protocol(protocol); this.protocol = protocol;
return this;
} }
/** /**
* @see BaseLoadBalancer.Builder#port(Integer) * @see BaseLoadBalancer.Builder#port(Integer)
*/ */
public static LoadBalancerUpdate port(Integer port) { public Builder port(Integer port) {
return new LoadBalancerUpdate().port(port); this.port = port;
return this;
} }
/** /**
* @see BaseLoadBalancer.Builder#algorithm(Algorithm) * @see BaseLoadBalancer.Builder#algorithm(Algorithm)
*/ */
public static LoadBalancerUpdate algorithm(Algorithm algorithm) { public Builder algorithm(Algorithm algorithm) {
return new LoadBalancerUpdate().algorithm(algorithm); this.algorithm = algorithm;
return this;
} }
/** /**
* @see BaseLoadBalancer.Builder#timeout(Integer) * @see BaseLoadBalancer.Builder#timeout(Integer)
*/ */
public static LoadBalancerUpdate timeout(Integer timeout) { public Builder timeout(Integer timeout) {
return new LoadBalancerUpdate().timeout(timeout); this.timeout = timeout;
return this;
} }
/** /**
* @see BaseLoadBalancer.Builder#halfClosed(Boolean) * @see BaseLoadBalancer.Builder#halfClosed(Boolean)
*/ */
public static LoadBalancerUpdate halfClosed(Boolean halfClosed) { public Builder halfClosed(Boolean halfClosed) {
return new LoadBalancerUpdate().halfClosed(halfClosed); this.halfClosed = halfClosed;
return this;
}
public UpdateLoadBalancer build() {
return new UpdateLoadBalancer(name, protocol, port, algorithm, timeout, halfClosed);
}
public Builder from(UpdateLoadBalancer lb) {
return this.name(lb.getName()).port(lb.getPort()).protocol(lb.getProtocol()).algorithm(lb.getAlgorithm())
.timeout(lb.getTimeout()).halfClosed(lb.isHalfClosed());
} }
} }
public static <T extends BaseLoadBalancer<?, T>> LoadBalancerUpdate fromLoadBalancer(T lb) { public static Builder builder() {
return Builder.name(lb.getName()).port(lb.getPort()).protocol(lb.getProtocol()).algorithm(lb.getAlgorithm()) return new Builder();
.timeout(lb.getTimeout()).halfClosed(lb.isHalfClosed()); }
public Builder toBuilder() {
return new Builder().from(this);
} }
} }

View File

@ -28,27 +28,29 @@ import com.google.common.base.Objects.ToStringHelper;
/** /**
* Used to update Nodes. * Used to update Nodes.
* *
* @author Dan Lo Bianco * @author Everett Toews
*/ */
public class NodeUpdate { public class UpdateNode {
private Condition condition;
protected Condition condition; private Type type;
protected Type type; private Integer weight;
protected Integer weight;
protected UpdateNode(Condition condition, Type type, Integer weight) {
public NodeUpdate condition(Condition condition) {
this.condition = condition; this.condition = condition;
return this;
}
public NodeUpdate type(Type type) {
this.type = type; this.type = type;
return this; this.weight = weight;
} }
public NodeUpdate weight(Integer weight) { public Condition getCondition() {
this.weight = weight; return condition;
return this; }
public Type getType() {
return type;
}
public Integer getWeight() {
return weight;
} }
protected ToStringHelper string() { protected ToStringHelper string() {
@ -71,36 +73,55 @@ public class NodeUpdate {
if (this == obj) return true; if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false; if (obj == null || getClass() != obj.getClass()) return false;
NodeUpdate that = NodeUpdate.class.cast(obj); UpdateNode that = UpdateNode.class.cast(obj);
return Objects.equal(this.condition, that.condition) return Objects.equal(this.condition, that.condition)
&& Objects.equal(this.type, that.type) && Objects.equal(this.type, that.type)
&& Objects.equal(this.weight, that.weight); && Objects.equal(this.weight, that.weight);
} }
public static class Builder { public static class Builder {
private Condition condition;
private Type type;
private Integer weight;
/** /**
* @see BaseNode.Builder#condition(Condition) * @see BaseNode.Builder#condition(Condition)
*/ */
public static NodeUpdate condition(Condition condition) { public Builder condition(Condition condition) {
return new NodeUpdate().condition(condition); this.condition = condition;
return this;
} }
/** /**
* @see BaseNode.Builder#type(Type) * @see BaseNode.Builder#type(Type)
*/ */
public static NodeUpdate type(Type type) { public Builder type(Type type) {
return new NodeUpdate().type(type); this.type = type;
return this;
} }
/** /**
* @see BaseNode.Builder#weight(Integer) * @see BaseNode.Builder#weight(Integer)
*/ */
public static NodeUpdate weight(Integer weight) { public Builder weight(Integer weight) {
return new NodeUpdate().weight(weight); this.weight = weight;
return this;
}
public UpdateNode build() {
return new UpdateNode(condition, type, weight);
}
public Builder from(UpdateNode in) {
return this.condition(in.getCondition()).type(in.getType()).weight(in.getWeight());
} }
} }
public static <T extends BaseNode<T>> NodeUpdate fromNode(T n) { public static Builder builder() {
return Builder.condition(n.getCondition()).type(n.getType()).weight(n.getWeight()); return new Builder();
}
public Builder toBuilder() {
return new Builder().from(this);
} }
} }

View File

@ -24,8 +24,8 @@ import org.jclouds.collect.IterableWithMarker;
import org.jclouds.collect.PagedIterable; import org.jclouds.collect.PagedIterable;
import org.jclouds.openstack.v2_0.options.PaginationOptions; import org.jclouds.openstack.v2_0.options.PaginationOptions;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerUpdate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
/** /**
@ -43,7 +43,7 @@ public interface LoadBalancerApi {
* identifier, the caller can check on the progress of the operation by performing a * identifier, the caller can check on the progress of the operation by performing a
* {@link LoadBalancerApi#get}. * {@link LoadBalancerApi#get}.
*/ */
LoadBalancer create(LoadBalancerCreate lbCreate); LoadBalancer create(CreateLoadBalancer createLB);
/** /**
* Update the properties of a load balancer. * Update the properties of a load balancer.
@ -52,7 +52,7 @@ public interface LoadBalancerApi {
* identifier, the caller can check on the progress of the operation by performing a * identifier, the caller can check on the progress of the operation by performing a
* {@link LoadBalancerApi#get}. * {@link LoadBalancerApi#get}.
*/ */
void update(int id, LoadBalancerUpdate lbUpdate); void update(int id, UpdateLoadBalancer updateLB);
/** /**
* List the load balancers. * List the load balancers.

View File

@ -44,8 +44,8 @@ import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.openstack.v2_0.options.PaginationOptions; import org.jclouds.openstack.v2_0.options.PaginationOptions;
import org.jclouds.rackspace.cloudloadbalancers.v1.binders.BindMetadataToJsonPayload; import org.jclouds.rackspace.cloudloadbalancers.v1.binders.BindMetadataToJsonPayload;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerUpdate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseLoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseLoadBalancers; import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseLoadBalancers;
@ -72,7 +72,7 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface LoadBalancerAsyncApi { public interface LoadBalancerAsyncApi {
/** /**
* @see LoadBalancerApi#create(LoadBalancerCreate) * @see LoadBalancerApi#create(CreateLoadBalancer)
*/ */
@Named("lb:create") @Named("lb:create")
@POST @POST
@ -80,17 +80,17 @@ public interface LoadBalancerAsyncApi {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class) @Fallback(NullOnNotFoundOr404.class)
@Path("/loadbalancers") @Path("/loadbalancers")
ListenableFuture<LoadBalancer> create(@WrapWith("loadBalancer") LoadBalancerCreate lbCreate); ListenableFuture<LoadBalancer> create(@WrapWith("loadBalancer") CreateLoadBalancer createLB);
/** /**
* @see LoadBalancerApi#update(int, LoadBalancerUpdate) * @see LoadBalancerApi#update(int, UpdateLoadBalancer)
*/ */
@Named("lb:update") @Named("lb:update")
@PUT @PUT
@ResponseParser(ParseLoadBalancer.class) @ResponseParser(ParseLoadBalancer.class)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/loadbalancers/{id}") @Path("/loadbalancers/{id}")
ListenableFuture<Void> update(@PathParam("id") int id, @WrapWith("loadBalancer") LoadBalancerUpdate lbUpdate); ListenableFuture<Void> update(@PathParam("id") int id, @WrapWith("loadBalancer") UpdateLoadBalancer updateLB);
/** /**
* @see LoadBalancerApi#list() * @see LoadBalancerApi#list()

View File

@ -26,8 +26,8 @@ import org.jclouds.collect.PagedIterable;
import org.jclouds.openstack.v2_0.options.PaginationOptions; import org.jclouds.openstack.v2_0.options.PaginationOptions;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeUpdate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
/** /**
* Provides synchronous access to CloudLoadBalancers Node features. * Provides synchronous access to CloudLoadBalancers Node features.
@ -38,14 +38,14 @@ import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd;
*/ */
public interface NodeApi { public interface NodeApi {
/** /**
* Create a new node with the configuration defined by the request. * Add a new node with the configuration defined by the request.
*/ */
Set<Node> add(Iterable<NodeAdd> nodeAdds); Set<Node> add(Iterable<AddNode> addNodes);
/** /**
* Update the attributes of a node. * Update the attributes of a node.
*/ */
void update(int id, NodeUpdate nodeUpdate); void update(int id, UpdateNode updateNode);
/** /**
* List the nodes. * List the nodes.

View File

@ -47,8 +47,8 @@ import org.jclouds.rackspace.cloudloadbalancers.v1.binders.BindMetadataToJsonPay
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeUpdate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseMetadata; import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseMetadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseNode; import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseNodes; import org.jclouds.rackspace.cloudloadbalancers.v1.functions.ParseNodes;
@ -83,16 +83,16 @@ public interface NodeAsyncApi {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class) @Fallback(NullOnNotFoundOr404.class)
@Path("/nodes") @Path("/nodes")
ListenableFuture<Set<Node>> add(@WrapWith("nodes") Iterable<NodeAdd> nodeAdds); ListenableFuture<Set<Node>> add(@WrapWith("nodes") Iterable<AddNode> addNodes);
/** /**
* @see NodeApi#update(int, NodeUpdate) * @see NodeApi#update(int, UpdateNode)
*/ */
@Named("node:update") @Named("node:update")
@PUT @PUT
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/nodes/{id}") @Path("/nodes/{id}")
ListenableFuture<Void> update(@PathParam("id") int id, @WrapWith("node") NodeUpdate nodeUpdate); ListenableFuture<Void> update(@PathParam("id") int id, @WrapWith("node") UpdateNode updateNode);
/** /**
* @see NodeApi#list() * @see NodeApi#list()

View File

@ -34,8 +34,8 @@ import org.jclouds.loadbalancer.strategy.LoadBalanceNodesStrategy;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -67,13 +67,13 @@ public class CloudLoadBalancersLoadBalanceNodesStrategy implements LoadBalanceNo
// TODO need to query and update the LB per current design. // TODO need to query and update the LB per current design.
LoadBalancer lb = client.getLoadBalancerApiForZone(region).create( LoadBalancer lb = client.getLoadBalancerApiForZone(region).create(
LoadBalancerCreate.builder().name(name).protocol(protocol.toUpperCase()).port(loadBalancerPort) CreateLoadBalancer.builder().name(name).protocol(protocol.toUpperCase()).port(loadBalancerPort)
.virtualIPType(Type.PUBLIC).nodes( .virtualIPType(Type.PUBLIC).nodes(
Iterables.transform(nodes, new Function<NodeMetadata, NodeAdd>() { Iterables.transform(nodes, new Function<NodeMetadata, AddNode>() {
@Override @Override
public NodeAdd apply(NodeMetadata arg0) { public AddNode apply(NodeMetadata arg0) {
return NodeAdd.builder().address( return AddNode.builder().address(
Iterables.get(arg0.getPrivateAddresses(), 0)).port(instancePort) Iterables.get(arg0.getPrivateAddresses(), 0)).port(instancePort)
.build(); .build();

View File

@ -30,8 +30,8 @@ import java.util.Map;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRule; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRule;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRuleWithId; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRuleWithId;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
@ -72,12 +72,12 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
} }
public void testCreateLoadBalancer() { public void testCreateLoadBalancer() {
NodeAdd nodeAdd = NodeAdd.builder().address("192.168.1.1").port(8080).build(); AddNode addNode = AddNode.builder().address("192.168.1.1").port(8080).build();
LoadBalancerCreate lbCreate = LoadBalancerCreate.builder() CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeAdd).build(); .name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = "ORD";//Iterables.getFirst(clbApi.getConfiguredZones(), null); zone = "ORD";//Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbCreate); lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
} }

View File

@ -27,8 +27,8 @@ import static org.testng.Assert.assertTrue;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.ConnectionThrottle; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.ConnectionThrottle;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
@ -45,12 +45,12 @@ public class ConnectionApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
private String zone; private String zone;
public void testCreateLoadBalancer() { public void testCreateLoadBalancer() {
NodeAdd nodeAdd = NodeAdd.builder().address("192.168.1.1").port(8080).build(); AddNode addNode = AddNode.builder().address("192.168.1.1").port(8080).build();
LoadBalancerCreate lbCreate = LoadBalancerCreate.builder() CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeAdd).build(); .name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null); zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbCreate); lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
} }

View File

@ -24,8 +24,8 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
@ -42,12 +42,12 @@ public class ContentCachingApiLiveTest extends BaseCloudLoadBalancersApiLiveTest
private String zone; private String zone;
public void testCreateLoadBalancer() { public void testCreateLoadBalancer() {
NodeAdd nodeAdd = NodeAdd.builder().address("192.168.1.1").port(8080).build(); AddNode addNode = AddNode.builder().address("192.168.1.1").port(8080).build();
LoadBalancerCreate lbCreate = LoadBalancerCreate.builder() CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeAdd).build(); .name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null); zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbCreate); lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
} }

View File

@ -24,8 +24,8 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
@ -54,12 +54,12 @@ public class ErrorPageApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
} }
public void testCreateLoadBalancer() { public void testCreateLoadBalancer() {
NodeAdd nodeAdd = NodeAdd.builder().address("192.168.1.1").port(8080).build(); AddNode addNode = AddNode.builder().address("192.168.1.1").port(8080).build();
LoadBalancerCreate lbCreate = LoadBalancerCreate.builder() CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeAdd).build(); .name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null); zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbCreate); lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
} }

View File

@ -26,8 +26,8 @@ import static org.testng.Assert.assertTrue;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.HealthMonitor; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.HealthMonitor;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
@ -44,12 +44,12 @@ public class HealthMonitorApiLiveTest extends BaseCloudLoadBalancersApiLiveTest
private String zone; private String zone;
public void testCreateLoadBalancer() { public void testCreateLoadBalancer() {
NodeAdd nodeAdd = NodeAdd.builder().address("192.168.1.1").port(8080).build(); AddNode addNode = AddNode.builder().address("192.168.1.1").port(8080).build();
LoadBalancerCreate lbCreate = LoadBalancerCreate.builder() CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeAdd).build(); .name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null); zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbCreate); lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
} }

View File

@ -29,10 +29,10 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerUpdate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.LoadBalancerApi; import org.jclouds.rackspace.cloudloadbalancers.v1.features.LoadBalancerApi;
@ -89,30 +89,30 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/loadbalancer-get.json")).build() HttpResponse.builder().statusCode(200).payload(payloadFromResource("/loadbalancer-get.json")).build()
).getLoadBalancerApiForZone("DFW"); ).getLoadBalancerApiForZone("DFW");
NodeAdd nodeAdd1 = NodeAdd.builder() AddNode addNode1 = AddNode.builder()
.address("10.1.1.1") .address("10.1.1.1")
.condition(Node.Condition.ENABLED) .condition(Node.Condition.ENABLED)
.port(80) .port(80)
.build(); .build();
NodeAdd nodeAdd2 = NodeAdd.builder() AddNode addNode2 = AddNode.builder()
.address("10.1.1.2") .address("10.1.1.2")
.condition(Node.Condition.ENABLED) .condition(Node.Condition.ENABLED)
.port(80) .port(80)
.build(); .build();
Set<NodeAdd> nodeAdds = Sets.newHashSet(nodeAdd1, nodeAdd2); Set<AddNode> addNodes = Sets.newHashSet(addNode1, addNode2);
LoadBalancerCreate lbCreate = LoadBalancerCreate.builder() CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name("sample-loadbalancer") .name("sample-loadbalancer")
.protocol("HTTP") .protocol("HTTP")
.port(80) .port(80)
.algorithm(LoadBalancer.Algorithm.RANDOM) .algorithm(LoadBalancer.Algorithm.RANDOM)
.virtualIPType(VirtualIP.Type.PUBLIC) .virtualIPType(VirtualIP.Type.PUBLIC)
.nodes(nodeAdds) .nodes(addNodes)
.build(); .build();
LoadBalancer loadBalancer = api.create(lbCreate); LoadBalancer loadBalancer = api.create(createLB);
assertEquals(loadBalancer, getExpectedLoadBalancer()); assertEquals(loadBalancer, getExpectedLoadBalancer());
} }
@ -126,13 +126,14 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes
HttpResponse.builder().statusCode(202).payload("").build() HttpResponse.builder().statusCode(202).payload("").build()
).getLoadBalancerApiForZone("DFW"); ).getLoadBalancerApiForZone("DFW");
LoadBalancerUpdate lbUpdate = LoadBalancerUpdate.Builder UpdateLoadBalancer updateLB = UpdateLoadBalancer.builder()
.name("foo") .name("foo")
.protocol("HTTPS") .protocol("HTTPS")
.port(443) .port(443)
.algorithm(LoadBalancer.Algorithm.RANDOM); .algorithm(LoadBalancer.Algorithm.RANDOM)
.build();
api.update(2000, lbUpdate); api.update(2000, updateLB);
} }
public void testRemoveLoadBalancer() { public void testRemoveLoadBalancer() {

View File

@ -30,10 +30,10 @@ import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerUpdate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
@ -67,12 +67,12 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
Logger.getAnonymousLogger().info("starting lb in region " + zone); Logger.getAnonymousLogger().info("starting lb in region " + zone);
LoadBalancer lb = clbApi.getLoadBalancerApiForZone(zone).create( LoadBalancer lb = clbApi.getLoadBalancerApiForZone(zone).create(
LoadBalancerCreate.builder() CreateLoadBalancer.builder()
.name(prefix + "-" + zone) .name(prefix + "-" + zone)
.protocol("HTTP") .protocol("HTTP")
.port(80) .port(80)
.virtualIPType(Type.PUBLIC) .virtualIPType(Type.PUBLIC)
.node(NodeAdd.builder() .node(AddNode.builder()
.address("192.168.1.1") .address("192.168.1.1")
.port(8080) .port(8080)
.build()) .build())
@ -96,7 +96,7 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
public void testUpdateLoadBalancer() throws Exception { public void testUpdateLoadBalancer() throws Exception {
for (LoadBalancer lb: lbs) { for (LoadBalancer lb: lbs) {
clbApi.getLoadBalancerApiForZone(lb.getRegion()).update(lb.getId(), clbApi.getLoadBalancerApiForZone(lb.getRegion()).update(lb.getId(),
LoadBalancerUpdate.Builder.name("foo" + "-" + lb.getRegion())); UpdateLoadBalancer.builder().name("foo" + "-" + lb.getRegion()).build());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));

View File

@ -30,8 +30,8 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeUpdate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi; import org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -84,14 +84,14 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nodes-list.json")).build() HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nodes-list.json")).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000); ).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
NodeAdd nodeAdd1 = NodeAdd.builder() AddNode addNode1 = AddNode.builder()
.address("10.1.1.1") .address("10.1.1.1")
.condition(Node.Condition.ENABLED) .condition(Node.Condition.ENABLED)
.port(80) .port(80)
.weight(3) .weight(3)
.build(); .build();
NodeAdd nodeAdd2 = NodeAdd.builder() AddNode addNode2 = AddNode.builder()
.address("10.1.1.2") .address("10.1.1.2")
.condition(Node.Condition.ENABLED) .condition(Node.Condition.ENABLED)
.type(Node.Type.SECONDARY) .type(Node.Type.SECONDARY)
@ -99,16 +99,16 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
.weight(8) .weight(8)
.build(); .build();
NodeAdd nodeAdd3 = NodeAdd.builder() AddNode addNode3 = AddNode.builder()
.address("10.1.1.3") .address("10.1.1.3")
.condition(Node.Condition.DISABLED) .condition(Node.Condition.DISABLED)
.port(80) .port(80)
.weight(12) .weight(12)
.build(); .build();
Set<NodeAdd> nodeAdds = ImmutableSortedSet.<NodeAdd> of(nodeAdd1, nodeAdd2, nodeAdd3); Set<AddNode> addNodes = ImmutableSortedSet.<AddNode> of(addNode1, addNode2, addNode3);
Set<Node> nodes = api.add(nodeAdds); Set<Node> nodes = api.add(addNodes);
assertEquals(nodes, getExpectedNodes()); assertEquals(nodes, getExpectedNodes());
} }
@ -121,12 +121,13 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest<CloudL
HttpResponse.builder().statusCode(200).build() HttpResponse.builder().statusCode(200).build()
).getNodeApiForZoneAndLoadBalancer("DFW", 2000); ).getNodeApiForZoneAndLoadBalancer("DFW", 2000);
NodeUpdate nodeUpdate = NodeUpdate.Builder UpdateNode updateNode = UpdateNode.builder()
.condition(Node.Condition.DISABLED) .condition(Node.Condition.DISABLED)
.type(Node.Type.SECONDARY) .type(Node.Type.SECONDARY)
.weight(20); .weight(20)
.build();
api.update(410, nodeUpdate); api.update(410, updateNode);
} }
public void testRemoveNodeFromLoadBalancer() { public void testRemoveNodeFromLoadBalancer() {

View File

@ -37,11 +37,11 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeUpdate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer.Status; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer.Status;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import org.jclouds.rackspace.cloudloadbalancers.v1.features.LoadBalancerApi; import org.jclouds.rackspace.cloudloadbalancers.v1.features.LoadBalancerApi;
@ -62,8 +62,8 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
for (String zone : clbApi.getConfiguredZones()) { for (String zone : clbApi.getConfiguredZones()) {
Logger.getAnonymousLogger().info("starting lb in zone " + zone); Logger.getAnonymousLogger().info("starting lb in zone " + zone);
LoadBalancer lb = clbApi.getLoadBalancerApiForZone(zone).create( LoadBalancer lb = clbApi.getLoadBalancerApiForZone(zone).create(
LoadBalancerCreate.builder().name(prefix + "-" + zone).protocol("HTTP").port(80).virtualIPType( CreateLoadBalancer.builder().name(prefix + "-" + zone).protocol("HTTP").port(80).virtualIPType(
Type.PUBLIC).node(NodeAdd.builder().address("192.168.1.1").port(8080).build()).build()); Type.PUBLIC).node(AddNode.builder().address("192.168.1.1").port(8080).build()).build());
nodes.put(lb, new HashSet<Node>()); nodes.put(lb, new HashSet<Node>());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
@ -78,7 +78,7 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
String region = lb.getRegion(); String region = lb.getRegion();
Logger.getAnonymousLogger().info("starting node on loadbalancer " + lb.getId() + " in region " + region); Logger.getAnonymousLogger().info("starting node on loadbalancer " + lb.getId() + " in region " + region);
Set<Node> newNodes = clbApi.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).add( Set<Node> newNodes = clbApi.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).add(
ImmutableSet.<NodeAdd> of(NodeAdd.builder().address("192.168.1.2").port(8080).build())); ImmutableSet.<AddNode> of(AddNode.builder().address("192.168.1.2").port(8080).build()));
for (Node n : newNodes) { for (Node n : newNodes) {
assertEquals(n.getStatus(), Node.Status.ONLINE); assertEquals(n.getStatus(), Node.Status.ONLINE);
@ -97,7 +97,7 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
for (Node n : entry.getValue()) { for (Node n : entry.getValue()) {
String region = entry.getKey().getRegion(); String region = entry.getKey().getRegion();
clbApi.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).update(n.getId(), clbApi.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).update(n.getId(),
NodeUpdate.Builder.weight(23)); UpdateNode.builder().weight(23).build());
assertEquals(clbApi.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId()) assertEquals(clbApi.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId())
.getStatus(), Node.Status.ONLINE); .getStatus(), Node.Status.ONLINE);

View File

@ -30,10 +30,10 @@ import java.util.Date;
import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpResponseException;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.HistoricalUsage; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.HistoricalUsage;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerStats; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerStats;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerUsage; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerUsage;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Protocol; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Protocol;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest;
@ -52,12 +52,12 @@ public class ReportApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
private String zone; private String zone;
public void testCreateLoadBalancer() { public void testCreateLoadBalancer() {
NodeAdd nodeAdd = NodeAdd.builder().address("192.168.1.1").port(8080).build(); AddNode addNode = AddNode.builder().address("192.168.1.1").port(8080).build();
LoadBalancerCreate lbCreate = LoadBalancerCreate.builder() CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeAdd).build(); .name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null); zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbCreate); lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
} }

View File

@ -25,8 +25,8 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.SSLTermination; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.SSLTermination;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest;
@ -44,12 +44,12 @@ public class SSLTerminationApiLiveTest extends BaseCloudLoadBalancersApiLiveTest
private String zone; private String zone;
public void testCreateLoadBalancer() { public void testCreateLoadBalancer() {
NodeAdd nodeAdd = NodeAdd.builder().address("192.168.1.1").port(8080).build(); AddNode addNode = AddNode.builder().address("192.168.1.1").port(8080).build();
LoadBalancerCreate lbCreate = LoadBalancerCreate.builder() CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeAdd).build(); .name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null); zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbCreate); lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
} }

View File

@ -25,8 +25,8 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.SessionPersistence; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.SessionPersistence;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancersApiLiveTest;
@ -44,12 +44,12 @@ public class SessionPersistenceApiLiveTest extends BaseCloudLoadBalancersApiLive
private String zone; private String zone;
public void testCreateLoadBalancer() { public void testCreateLoadBalancer() {
NodeAdd nodeAdd = NodeAdd.builder().address("192.168.1.1").port(8080).build(); AddNode addNode = AddNode.builder().address("192.168.1.1").port(8080).build();
LoadBalancerCreate lbCreate = LoadBalancerCreate.builder() CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeAdd).build(); .name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null); zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbCreate); lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
} }

View File

@ -26,8 +26,8 @@ import static org.testng.Assert.assertTrue;
import java.util.List; import java.util.List;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancerCreate; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.CreateLoadBalancer;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.NodeAdd; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIPWithId; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIPWithId;
import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP.Type;
@ -48,12 +48,12 @@ public class VirtualIPApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
private String zone; private String zone;
public void testCreateLoadBalancer() { public void testCreateLoadBalancer() {
NodeAdd nodeAdd = NodeAdd.builder().address("192.168.1.1").port(8080).build(); AddNode addNode = AddNode.builder().address("192.168.1.1").port(8080).build();
LoadBalancerCreate lbCreate = LoadBalancerCreate.builder() CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(nodeAdd).build(); .name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null); zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(lbCreate); lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb)); assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
} }