mirror of https://github.com/apache/jclouds.git
reverted an accidental commit of several files; added editing to load balancer
This commit is contained in:
parent
86471b0a5a
commit
d8d88c3321
|
@ -58,17 +58,6 @@ public interface GridLoadBalancerAsyncClient {
|
|||
@Path("/grid/loadbalancer/list")
|
||||
ListenableFuture<Set<LoadBalancer>> getLoadBalancerList();
|
||||
|
||||
/**
|
||||
* @see GridLoadBalancerClient#addLoadBalancer
|
||||
*/
|
||||
@GET
|
||||
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
|
||||
@Path("/grid/loadbalancer/add")
|
||||
ListenableFuture<LoadBalancer> addLoadBalancer(@QueryParam("name") String name,
|
||||
@BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp,
|
||||
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps,
|
||||
AddLoadBalancerOptions... options);
|
||||
|
||||
/**
|
||||
* @see GridLoadBalancerClient#getLoadBalancersByName
|
||||
*/
|
||||
|
@ -85,6 +74,26 @@ public interface GridLoadBalancerAsyncClient {
|
|||
@Path("/grid/loadbalancer/get")
|
||||
ListenableFuture<Set<LoadBalancer>> getLoadBalancersById(@BinderParam(BindIdsToQueryParams.class) Long... ids);
|
||||
|
||||
/**
|
||||
* @see GridLoadBalancerClient#addLoadBalancer
|
||||
*/
|
||||
@GET
|
||||
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
|
||||
@Path("/grid/loadbalancer/add")
|
||||
ListenableFuture<LoadBalancer> addLoadBalancer(@QueryParam("name") String name,
|
||||
@BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp,
|
||||
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps,
|
||||
AddLoadBalancerOptions... options);
|
||||
|
||||
/**
|
||||
* @see GridLoadBalancerClient#editLoadBalancer
|
||||
*/
|
||||
@GET
|
||||
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
|
||||
@Path("/grid/loadbalancer/edit")
|
||||
ListenableFuture<LoadBalancer> editLoadBalancer(@QueryParam("loadbalancer") String idOrName,
|
||||
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
|
||||
|
||||
/**
|
||||
* @see GridLoadBalancerClient#
|
||||
*/
|
||||
|
|
|
@ -39,26 +39,6 @@ public interface GridLoadBalancerClient {
|
|||
*/
|
||||
Set<LoadBalancer> getLoadBalancerList();
|
||||
|
||||
/**
|
||||
* Creates a load balancer with given properties.
|
||||
*
|
||||
* @param name name of the load balancer
|
||||
* @param virtualIp virtual IP with IP address set in
|
||||
* {@link org.jclouds.gogrid.domain.Ip#ip} and
|
||||
* port set in {@link IpPortPair#port}
|
||||
* @param realIps real IPs to bind the virtual IP to, with
|
||||
* IP address set in
|
||||
* {@link org.jclouds.gogrid.domain.Ip#ip} and
|
||||
* port set in {@link IpPortPair#port}
|
||||
* @param options options that specify load balancer's type (round robin,
|
||||
* least load), persistence strategy, or description.
|
||||
* @return created load balancer object
|
||||
*/
|
||||
LoadBalancer addLoadBalancer(String name,
|
||||
IpPortPair virtualIp,
|
||||
List<IpPortPair> realIps,
|
||||
AddLoadBalancerOptions... options);
|
||||
|
||||
/**
|
||||
* Returns the load balancer(s) by unique name(s).
|
||||
*
|
||||
|
@ -79,6 +59,40 @@ public interface GridLoadBalancerClient {
|
|||
*/
|
||||
Set<LoadBalancer> getLoadBalancersById(Long... ids);
|
||||
|
||||
/**
|
||||
* Creates a load balancer with given properties.
|
||||
*
|
||||
* @param name name of the load balancer
|
||||
* @param virtualIp virtual IP with IP address set in
|
||||
* {@link org.jclouds.gogrid.domain.Ip#ip} and
|
||||
* port set in {@link IpPortPair#port}
|
||||
* @param realIps real IPs to bind the virtual IP to, with
|
||||
* IP address set in
|
||||
* {@link org.jclouds.gogrid.domain.Ip#ip} and
|
||||
* port set in {@link IpPortPair#port}
|
||||
* @param options options that specify load balancer's type (round robin,
|
||||
* least load), persistence strategy, or description.
|
||||
* @return created load balancer object
|
||||
*/
|
||||
LoadBalancer addLoadBalancer(String name,
|
||||
IpPortPair virtualIp,
|
||||
List<IpPortPair> realIps,
|
||||
AddLoadBalancerOptions... options);
|
||||
|
||||
/**
|
||||
* Edits the existing load balancer to change the real
|
||||
* IP mapping.
|
||||
*
|
||||
* @param idOrName id or name of the existing load balancer
|
||||
* @param realIps real IPs to bind the virtual IP to, with
|
||||
* IP address set in
|
||||
* {@link org.jclouds.gogrid.domain.Ip#ip} and
|
||||
* port set in {@link IpPortPair#port}
|
||||
* @return edited object
|
||||
*/
|
||||
LoadBalancer editLoadBalancer(String idOrName,
|
||||
List<IpPortPair> realIps);
|
||||
|
||||
/**
|
||||
* Deletes the load balancer by Id
|
||||
*
|
||||
|
|
|
@ -186,11 +186,12 @@ public class GoGridLiveTest {
|
|||
GetIpListOptions ipOptions = new GetIpListOptions.Builder().unassignedPublicIps();
|
||||
Set<Ip> availableIps = client.getIpServices().getIpList(ipOptions);
|
||||
|
||||
if(availableIps.size() < 3) throw new SkipException("Not enough available IPs (3 needed) to run the test");
|
||||
if(availableIps.size() < 4) throw new SkipException("Not enough available IPs (4 needed) to run the test");
|
||||
Iterator<Ip> ipIterator = availableIps.iterator();
|
||||
Ip vip = ipIterator.next();
|
||||
Ip realIp1 = ipIterator.next();
|
||||
Ip realIp2 = ipIterator.next();
|
||||
Ip realIp3 = ipIterator.next();
|
||||
|
||||
AddLoadBalancerOptions options = new AddLoadBalancerOptions.Builder().
|
||||
create(LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SOURCE_ADDRESS);
|
||||
|
@ -206,10 +207,17 @@ public class GoGridLiveTest {
|
|||
assert (response.size() == 1);
|
||||
createdLoadBalancer = Iterables.getOnlyElement(response);
|
||||
assertNotNull(createdLoadBalancer.getRealIpList());
|
||||
assert createdLoadBalancer.getRealIpList().size() == 2;
|
||||
assertEquals(createdLoadBalancer.getRealIpList().size(), 2);
|
||||
assertNotNull(createdLoadBalancer.getVirtualIp());
|
||||
assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp());
|
||||
|
||||
LoadBalancer editedLoadBalancer = client.getLoadBalancerServices().
|
||||
editLoadBalancer(nameOfLoadBalancer, Arrays.asList(new IpPortPair(realIp3, 8181)));
|
||||
assert loadBalancerLatestJobCompleted.apply(editedLoadBalancer);
|
||||
assertNotNull(editedLoadBalancer.getRealIpList());
|
||||
assertEquals(editedLoadBalancer.getRealIpList().size(), 1);
|
||||
assertEquals(Iterables.getOnlyElement(editedLoadBalancer.getRealIpList()).getIp().getIp(), realIp3.getIp());
|
||||
|
||||
int lbCountAfterAddingOneServer = client.getLoadBalancerServices().getLoadBalancerList().size();
|
||||
assert lbCountAfterAddingOneServer == lbCountBeforeTest + 1 :
|
||||
"There should be +1 increase in the number of load balancers since the test started";
|
||||
|
|
|
@ -118,6 +118,38 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
|||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditLoadBalancer() throws NoSuchMethodException, IOException {
|
||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer",
|
||||
String.class, List.class);
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"BalanceIt", Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080),
|
||||
new IpPortPair(new Ip("127.0.0.1"), 9090)));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||
"edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&" +
|
||||
"realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||
"edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&" +
|
||||
"realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLoadBalancersByName() throws NoSuchMethodException, IOException {
|
||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("getLoadBalancersByName", String[].class);
|
||||
|
|
Loading…
Reference in New Issue