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

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


    */
   public static void main(String[] args) throws IOException {
      AddNodes addNodes = new AddNodes(args[0], args[1]);

      try {
         LoadBalancer loadBalancer = addNodes.getLoadBalancer();
         Set<AddNode> addNodeSet = addNodes.createAddNodes();
         addNodes.addNodesToLoadBalancer(addNodeSet, loadBalancer);
      }
      catch (Exception e) {
         e.printStackTrace();
View Full Code Here


            .virtualIPType(VirtualIP.Type.PUBLIC)
            .build();

      // This will fail if the service cannot resolve the hostname of the database instance.
      // This happens when the internal DNS record for the database hostname has not propagated yet. Just retry to fix.
      LoadBalancer loadBalancer;
      do {
         loadBalancer = lbApi.create(createLB);
         Uninterruptibles.sleepUninterruptibly(30, TimeUnit.SECONDS);
      }
      while(loadBalancer == null);
View Full Code Here

            responseWithAccess,
            authenticatedGET().endpoint(endpoint).build(),
            HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/loadbalancer-get.json")).build()
      ).getLoadBalancerApiForZone("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 void testCreateLoadBalancers() {
      assertTrue(api.getConfiguredZones().size() > 0, "Need to have some zones!");
      Logger.getAnonymousLogger().info("running against zones " + api.getConfiguredZones());
      for (String zone : api.getConfiguredZones()) {
         Logger.getAnonymousLogger().info("starting lb in zone " + zone);
         LoadBalancer lb = api.getLoadBalancerApiForZone(zone).create(
                  CreateLoadBalancer.builder().name(prefix + "-" + zone).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.getLoadBalancerApiForZone(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.getNodeApiForZoneAndLoadBalancer(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.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).get(n.getId()).getStatus(),
                     Node.Status.ONLINE);
         }

         assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(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.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).createMetadata(node.getId(), metadataMap);
         assertEquals(metadata, getExpectedMetadata());
         assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));

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

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

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

         assertTrue(api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).deleteMetadata(node.getId(),
               ImmutableList.<Integer> of(metadata.getId("key2"), metadata.getId("key3"))));
         assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
         metadata = api.getNodeApiForZoneAndLoadBalancer(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.getLoadBalancerApiForZone(lb.getRegion());

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

       */
      @Override
      public boolean apply(LoadBalancer loadBalancer) {
         checkNotNull(loadBalancer, "loadBalancer must be defined");

         LoadBalancer loadBalancerUpdated = loadBalancerApi.get(loadBalancer.getId());
         checkNotNull(loadBalancerUpdated, "LoadBalancer %s not found.", loadBalancer.getId());

         return status.equals(loadBalancerUpdated.getStatus());
      }
View Full Code Here

       * @return boolean Return true when the snapshot is deleted, false otherwise
       */
      @Override
      public boolean apply(LoadBalancer loadBalancer) {
         checkNotNull(loadBalancer, "loadBalancer must be defined");
         LoadBalancer loadBalancerUpdate = loadBalancerApi.get(loadBalancer.getId());

         if (loadBalancerUpdate == null) {
            return true;
         }
         else {
            return loadBalancerUpdate.getStatus().equals(LoadBalancer.Status.DELETED);
         }
      }
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.