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

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


      if (this == obj)
         return true;
      if (obj == null || getClass() != obj.getClass())
         return false;

      LoadBalancer that = LoadBalancer.class.cast(obj);
      return Objects.equal(this.name, that.name);
   }
View Full Code Here


   }

   @Override
   public LoadBalancer apply(LB lb) {
      try {
         Builder builder = LoadBalancer.builder().id(lb.id).region(region).status(lb.status).name(lb.getName())
               .protocol(lb.getProtocol()).port(lb.getPort()).nodeCount(lb.nodeCount).nodes(lb.getNodes())
               .timeout(lb.getTimeout()).algorithm(lb.getAlgorithm()).halfClosed(lb.isHalfClosed())
               .sessionPersistenceType(lb.getSessionPersistenceType()).connectionLogging(lb.isConnectionLogging())
               .connectionThrottle(lb.getConnectionThrottle()).healthMonitor(lb.getHealthMonitor());

         if (lb.cluster.size() == 1)
            builder.clusterName(Iterables.get(lb.cluster.values(), 0));
         if (lb.created.size() == 1)
            builder.created(Iterables.get(lb.created.values(), 0));
         if (lb.updated.size() == 1)
            builder.updated(Iterables.get(lb.updated.values(), 0));
         if (lb.contentCaching.size() == 1)
            builder.contentCaching(Iterables.get(lb.contentCaching.values(), 0));
         if (lb.sslTermination != null)
            builder.sslTermination(lb.sslTermination);
         if (lb.sourceAddresses != null)
            builder.sourceAddresses(lb.sourceAddresses);
         if (lb.accessList == null)
            builder.accessRules(ImmutableSet.<AccessRuleWithId> of());
         else
            builder.accessRules(lb.accessList);
         if (lb.virtualIps == null)
            builder.virtualIPs(ImmutableSet.<VirtualIPWithId> of());
         else
            builder.virtualIPs(lb.virtualIps);
         if (lb.metadata == null)
            builder.metadata(new Metadata());
         else
            builder.metadata(ParseMetadata.transformCLBMetadataToMetadata(lb.metadata));
        
         int indexOfLB = endpoint.toString().lastIndexOf(LOAD_BALANCERS);
         String path = endpoint.toString().substring(0, indexOfLB + LOAD_BALANCERS.length());
         builder.uri(URI.create(path + "/" + lb.id));

         return builder.build();
      }
      catch (NullPointerException e) {
         logger.warn(e, "nullpointer found parsing %s", lb);
         throw e;
      }
View Full Code Here

         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

      }
      super.tearDown();
   }

   private Metadata getExpectedMetadata() {
      Metadata metadata = new Metadata();
      metadata.put("key1", "value1");
      metadata.put("key2", "value2");
      metadata.put("key3", "value3");

      return metadata;
   }
View Full Code Here

      return "/loadbalancer-get.json";
   }

   @Override
   public LoadBalancer expected() {
      Metadata metadata = new Metadata();
      metadata.put("color", "red");
      metadata.putId("color", 1);
      metadata.put("label", "web-load-balancer");
      metadata.putId("label", 2);
     
      return LoadBalancer
            .builder()
            .region("DFW")
            .id(2000)
View Full Code Here

         if (lb.virtualIps == null)
            builder.virtualIPs(ImmutableSet.<VirtualIPWithId> of());
         else
            builder.virtualIPs(lb.virtualIps);
         if (lb.metadata == null)
            builder.metadata(new Metadata());
         else
            builder.metadata(ParseMetadata.transformCLBMetadataToMetadata(lb.metadata));
        
         int indexOfLB = endpoint.toString().lastIndexOf(LOAD_BALANCERS);
         String path = endpoint.toString().substring(0, indexOfLB + LOAD_BALANCERS.length());
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

            api.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).update(n.getId(),
                     UpdateNode.builder().weight(23).build());
            assertEquals(api.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId())
                     .getStatus(), Node.Status.ONLINE);

            Node newNode = api.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId());
            assertEquals(newNode.getStatus(), Node.Status.ONLINE);
            assertEquals(newNode.getWeight(), (Integer) 23);
         }
      }
   }
View Full Code Here

            assert n.getPort() != -1 : n;
            assert n.getStatus() != null : n;
            assert !Arrays.asList(LoadBalancer.WEIGHTED_ALGORITHMS).contains(lb.getAlgorithm())
                     || n.getWeight() != null : n;

            Node getDetails = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).get(n.getId());

            try {
               assertEquals(getDetails.getId(), n.getId());
               assertEquals(getDetails.getCondition(), n.getCondition());
               assertEquals(getDetails.getAddress(), n.getAddress());
               assertEquals(getDetails.getPort(), n.getPort());
               assertEquals(getDetails.getStatus(), n.getStatus());
               if (Arrays.asList(LoadBalancer.WEIGHTED_ALGORITHMS).contains(lb.getAlgorithm())) {
                  assertEquals(getDetails.getWeight(), n.getWeight());
               }
            } catch (AssertionError e) {
               throw new AssertionError(String.format("%s\n%s - %s", e.getMessage(), getDetails, n));
            }
         }
View Full Code Here

                  .port(80)
                  .algorithm(Algorithm.RANDOM)
                  .status(Status.ACTIVE)
                  .nodeCount(1)
                  .virtualIPs(ImmutableSet.of(
                        new VirtualIPWithId(VirtualIP.Type.PUBLIC, VirtualIP.IPVersion.IPV4, 403, "206.55.130.1")))
                  .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
                  .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z"))
                  .uri(URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/71")).build(),
            LoadBalancer
                  .builder()
                  .region("DFW")
                  .name("lb-site2")
                  .id(166)
                  .protocol("HTTP")
                  .port(80)
                  .algorithm(Algorithm.RANDOM)
                  .status(Status.ACTIVE)
                  .nodeCount(1)
                  .virtualIPs(ImmutableSet.of(
                        new VirtualIPWithId(VirtualIP.Type.PUBLIC, VirtualIP.IPVersion.IPV4, 401, "206.55.130.2")))
                  .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:42Z"))
                  .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-11-30T03:23:44Z"))
                  .uri(URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/123123/loadbalancers/166")).build());
   }
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.