Package org.jclouds.rackspace.cloudloadbalancers.v1.domain

Examples of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer


            responseWithAccess,
            authenticatedGET().endpoint(endpoint).build(),
            HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/loadbalancer-get.json")).build()
      ).getLoadBalancerApi("DFW");

      LoadBalancer loadBalancer = api.get(2000);
      assertEquals(loadBalancer, getExpectedLoadBalancer());
   }
View Full Code Here


            .algorithm(LoadBalancer.Algorithm.RANDOM)
            .virtualIPType(VirtualIP.Type.PUBLIC)
            .nodes(addNodes)
            .build();
     
      LoadBalancer loadBalancer = api.create(createLB);
     
      assertEquals(loadBalancer, getExpectedLoadBalancer());
   }
View Full Code Here

   public LoadBalancerMetadata createLoadBalancerInLocation(Location location, String name, String protocol,
            int loadBalancerPort, final int instancePort, Iterable<? extends NodeMetadata> nodes) {
      String region = checkNotNull(location, "location").getId();

      // TODO need to query and update the LB per current design.
      LoadBalancer lb = client.getLoadBalancerApi(region).create(
               CreateLoadBalancer.builder().name(name).protocol(protocol.toUpperCase()).port(loadBalancerPort)
                        .virtualIPType(Type.PUBLIC).nodes(
                                 Iterables.transform(nodes, new Function<NodeMetadata, AddNode>() {

                                    @Override
                                    public AddNode apply(NodeMetadata arg0) {
                                       return AddNode.builder().address(
                                                Iterables.get(arg0.getPrivateAddresses(), 0)).port(instancePort)
                                                .build();

                                    }

                                 })).build());
      return getLB.getLoadBalancer(region + "/" + lb.getId());
   }
View Full Code Here

   public void testCreateLoadBalancers() {
      assertTrue(!api.getConfiguredRegions().isEmpty(), "Need to have some regions!");
      Logger.getAnonymousLogger().info("running against regions " + api.getConfiguredRegions());
      for (String region : api.getConfiguredRegions()) {
         Logger.getAnonymousLogger().info("starting lb in region " + region);
         LoadBalancer lb = api.getLoadBalancerApi(region).create(
                  CreateLoadBalancer.builder().name(prefix + "-" + region).protocol("HTTP").port(80).virtualIPType(
                           Type.PUBLIC).node(AddNode.builder().address("192.168.1.1").port(8080).build()).build());
         nodes.put(lb, new HashSet<Node>());

         assertTrue(awaitAvailable(api.getLoadBalancerApi(lb.getRegion())).apply(lb));
      }
   }
View Full Code Here

   }

   @Test(dependsOnMethods = "testCreateLoadBalancers")
   public void testAddNodes() throws Exception {
      for (Map.Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
         LoadBalancer lb = entry.getKey();
         Set<Node> nodeSet = entry.getValue();
         String region = lb.getRegion();
         Logger.getAnonymousLogger().info("starting node on loadbalancer " + lb.getId() + " in region " + region);
         Set<Node> newNodes = api.getNodeApi(region, lb.getId()).add(
                  ImmutableSet.<AddNode> of(AddNode.builder().address("192.168.1.2").port(8080).build()));

         for (Node n : newNodes) {
            assertEquals(n.getStatus(), Node.Status.ONLINE);
            nodeSet.add(n);
            assertEquals(api.getNodeApi(region, lb.getId()).get(n.getId()).getStatus(),
                     Node.Status.ONLINE);
         }

         assertTrue(awaitAvailable(api.getLoadBalancerApi(lb.getRegion())).apply(lb));
      }
   }
View Full Code Here

   }

   @Test(dependsOnMethods = "testListNodes")
   public void testNodeMetadata() throws Exception {
      for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
         LoadBalancer lb = entry.getKey();
         Node node = entry.getValue().iterator().next();
         Map<String, String> metadataMap = ImmutableMap.<String, String> of(
               "key1", "value1",
               "key2", "value2",
               "key3", "value3");

         Metadata metadata = api.getNodeApi(lb.getRegion(), lb.getId()).createMetadata(node.getId(), metadataMap);
         assertEquals(metadata, getExpectedMetadata());
         assertTrue(awaitAvailable(api.getLoadBalancerApi(lb.getRegion())).apply(lb));

         metadata = api.getNodeApi(lb.getRegion(), lb.getId()).getMetadata(node.getId());
         assertEquals(metadata, getExpectedMetadata());

         assertTrue(api.getNodeApi(lb.getRegion(), lb.getId()).updateMetadatum(node.getId(), metadata.getId("key1"), "key1-updated"));
         assertTrue(awaitAvailable(api.getLoadBalancerApi(lb.getRegion())).apply(lb));
         metadata = api.getNodeApi(lb.getRegion(), lb.getId()).getMetadata(node.getId());
         assertEquals(metadata.get("key1"), "key1-updated");

         assertTrue(api.getNodeApi(lb.getRegion(), lb.getId()).deleteMetadatum(node.getId(), metadata.getId("key1")));
         assertTrue(awaitAvailable(api.getLoadBalancerApi(lb.getRegion())).apply(lb));
         metadata = api.getNodeApi(lb.getRegion(), lb.getId()).getMetadata(node.getId());
         assertNull(metadata.get("key1"));

         assertTrue(api.getNodeApi(lb.getRegion(), lb.getId()).deleteMetadata(node.getId(),
               ImmutableList.<Integer> of(metadata.getId("key2"), metadata.getId("key3"))));
         assertTrue(awaitAvailable(api.getLoadBalancerApi(lb.getRegion())).apply(lb));
         metadata = api.getNodeApi(lb.getRegion(), lb.getId()).getMetadata(node.getId());
         assertEquals(metadata.size(), 0);
      }
   }
View Full Code Here

   @Override
   @AfterGroups(groups = "live")
   protected void tearDown() {
      for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
         LoadBalancer lb = entry.getKey();
         LoadBalancerApi lbClient = api.getLoadBalancerApi(lb.getRegion());

         if (lbClient.get(lb.getId()).getStatus() != Status.DELETED) {
            assertTrue(awaitAvailable(api.getLoadBalancerApi(lb.getRegion())).apply(lb));
            lbClient.delete(lb.getId());
         }
         assertTrue(awaitDeleted(api.getLoadBalancerApi(lb.getRegion())).apply(lb));
      }
      super.tearDown();
   }
View Full Code Here

   public void testCreateLoadBalancer() throws Exception {
      for (String region : api.getConfiguredRegions()) {
         Logger.getAnonymousLogger().info("starting lb in region " + region);

         LoadBalancer lb = api.getLoadBalancerApi(region).create(
               CreateLoadBalancer.builder()
                     .name(prefix + "-" + region)
                     .protocol("HTTP")
                     .port(80)
                     .virtualIPType(Type.PUBLIC)
                     .node(AddNode.builder()
                           .address("192.168.1.1")
                           .port(8080)
                           .build())
                     .build());
         checkLBInRegion(region, lb, prefix + "-" + region);

         assertEquals(lb.getStatus(), LoadBalancer.Status.BUILD);

         lbs.add(lb);

         assertTrue(awaitAvailable(api.getLoadBalancerApi(lb.getRegion())).apply(lb));

         LoadBalancer newLb = api.getLoadBalancerApi(region).get(lb.getId());
         checkLBInRegion(region, newLb, prefix + "-" + region);

         assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
      }
   }
View Full Code Here

         api.getLoadBalancerApi(lb.getRegion()).update(lb.getId(),
               UpdateLoadBalancer.builder().name("foo" + "-" + lb.getRegion()).build());

         assertTrue(awaitAvailable(api.getLoadBalancerApi(lb.getRegion())).apply(lb));

         LoadBalancer newLb = api.getLoadBalancerApi(lb.getRegion()).get(lb.getId());
         checkLBInRegion(newLb.getRegion(), newLb, "foo" + "-" + lb.getRegion());

         assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
      }
   }
View Full Code Here

            assert lb.getUpdated() != null : lb;
            assert !lb.getVirtualIPs().isEmpty() : lb;
            // node info not available during list;
            assert lb.getNodes().size() == 0 : lb;

            LoadBalancer getDetails = api.getLoadBalancerApi(region).get(lb.getId());

            try {
               assertEquals(getDetails.getRegion(), lb.getRegion());
               assertEquals(getDetails.getName(), lb.getName());
               assertEquals(getDetails.getId(), lb.getId());
               assertEquals(getDetails.getProtocol(), lb.getProtocol());
               assertEquals(getDetails.getPort(), lb.getPort());
               assertEquals(getDetails.getStatus(), lb.getStatus());
               assertEquals(getDetails.getCreated(), lb.getCreated());
               assertEquals(getDetails.getUpdated(), lb.getUpdated());
               assertEquals(getDetails.getVirtualIPs(), lb.getVirtualIPs());
               // node info not available during list;
               assert !getDetails.getNodes().isEmpty() : lb;
            } catch (AssertionError e) {
               throw new AssertionError(String.format("%s\n%s - %s", e.getMessage(), getDetails, lb));
            }
         }
      }
View Full Code Here

TOP

Related Classes of org.jclouds.rackspace.cloudloadbalancers.v1.domain.LoadBalancer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.