Пример #1
0
 private LoadBalancer newLoadBalancer(Integer id, String name) {
   List<Node> nodes = new ArrayList<Node>();
   List<VirtualIp> vips = new ArrayList<VirtualIp>();
   List<NetworkItem> accessList = new ArrayList<NetworkItem>();
   LoadBalancer lb = new LoadBalancer();
   Created created = new Created();
   Updated updated = new Updated();
   created.setTime(Calendar.getInstance());
   updated.setTime(Calendar.getInstance());
   ConnectionThrottle ct = new ConnectionThrottle();
   Cluster cl = new Cluster();
   ConnectionLogging cnl = new ConnectionLogging();
   cnl.setEnabled(Boolean.TRUE);
   ct.setMaxConnectionRate(100);
   ct.setMaxConnections(200);
   ct.setMinConnections(300);
   ct.setRateInterval(60);
   cl.setName("TestCluster");
   lb.setName(name);
   lb.setAlgorithm("RANDOM");
   lb.setCluster(cl);
   lb.setConnectionLogging(cnl);
   lb.setConnectionThrottle(ct);
   lb.setPort(80);
   lb.setProtocol("HTTP");
   lb.setStatus("BUILD");
   lb.setCreated(created);
   lb.setUpdated(updated);
   nodes.add(newNode(1, 80, "127.0.0.10"));
   nodes.add(newNode(1, 443, "127.0.0.20"));
   vips.add(newVip(1, "127.0.0.1"));
   vips.add(newVip(2, "127.0.0.2"));
   lb.setVirtualIps(vips);
   lb.setNodes(nodes);
   SessionPersistence sp = new SessionPersistence();
   sp.setPersistenceType(PersistenceType.HTTP_COOKIE);
   lb.setSessionPersistence(sp);
   accessList.add(newNetworkItem(1, "10.0.0.0/8"));
   accessList.add(newNetworkItem(2, "192.168.0.0/24"));
   lb.setAccessList(accessList);
   LoadBalancerUsage lu = new LoadBalancerUsage();
   lu.setLoadBalancerId(id);
   lu.setLoadBalancerName(name);
   lu.getLoadBalancerUsageRecords().add(newLoadBalancerUsageRecord(1));
   lu.getLoadBalancerUsageRecords().add(newLoadBalancerUsageRecord(2));
   lb.setLoadBalancerUsage(lu);
   return lb;
 }
Пример #2
0
  public static List<LoadBalancerUsage> loadBalancerBillingsToLoadBalancerUsages(
      List<LoadBalancerBilling> loadBalancerBillings) {
    List<LoadBalancerUsage> loadBalancerUsages = new ArrayList<LoadBalancerUsage>();

    for (LoadBalancerBilling loadBalancerBilling : loadBalancerBillings) {
      LoadBalancerUsage loadBalancerUsage = new LoadBalancerUsage();
      loadBalancerUsage.setLoadBalancerId(loadBalancerBilling.getLoadBalancerId());
      loadBalancerUsage.setLoadBalancerName(loadBalancerBilling.getLoadBalancerName());
      for (Usage usage : loadBalancerBilling.getUsageRecords()) {
        loadBalancerUsage.getLoadBalancerUsageRecords().add(toRestApiUsage(usage));
      }
      loadBalancerUsages.add(loadBalancerUsage);
    }

    return loadBalancerUsages;
  }