Package com.vmware.bdd.apitypes.PlacementPolicy

Examples of com.vmware.bdd.apitypes.PlacementPolicy.GroupRacks


      if (nodeGroup.getInstancePerHost() != null) {
         // assume this value is already validated
         int requiredHostNum = instanceNum / nodeGroup.getInstancePerHost();

         if (nodeGroup.getGroupRacks() != null) {
            GroupRacks groupRacks =
                  new Gson().fromJson(nodeGroup.getGroupRacks(),
                        GroupRacks.class);
            GroupRacksType rackType = groupRacks.getType();

            List<RackInfo> racksInfo = rackInfoMgr.getRackInfos();

            Set<String> specifiedRacks =
                  new HashSet<String>(Arrays.asList(groupRacks.getRacks()));
            List<String> IntersecRacks = new ArrayList<String>();
            Integer IntersecHostNum = 0;
            Integer maxIntersecHostNum = 0;
            for (RackInfo rackInfo : racksInfo) {
               if (specifiedRacks.isEmpty() || specifiedRacks.size() == 0
                     || specifiedRacks.contains(rackInfo.getName())) {
                  IntersecHostNum += rackInfo.getHosts().size();
                  IntersecRacks.add(rackInfo.getName());
                  if (rackInfo.getHosts().size() > maxIntersecHostNum) {
                     maxIntersecHostNum = rackInfo.getHosts().size();
                  }
               }
            }

            if (rackType.equals(GroupRacksType.ROUNDROBIN)
                  && IntersecHostNum < requiredHostNum) {
               throw ClusterConfigException.LACK_PHYSICAL_HOSTS(
                     requiredHostNum, nodeGroup.getName(), IntersecHostNum);
            } else if (rackType.equals(GroupRacksType.SAMERACK)
                  && requiredHostNum > maxIntersecHostNum) {
               throw ClusterConfigException.LACK_PHYSICAL_HOSTS(
                     requiredHostNum, nodeGroup.getName(), maxIntersecHostNum);
            }

            if (specifiedRacks.isEmpty()) {
               groupRacks.setRacks(new String[0]);
            } else {
               groupRacks.setRacks(IntersecRacks
                     .toArray(new String[IntersecRacks.size()]));
            }
            nodeGroup.setGroupRacks((new Gson()).toJson(groupRacks));
            clusterEntityMgr.update(nodeGroup);
         }
View Full Code Here


               valid = false;
               throw ClusterConfigException
                     .RACKPOLICY_WITH_NO_MAPPING_INFO_EXIST(ngc.getName());
            }

            GroupRacks r = policies.getGroupRacks();
            GroupRacksType rackType = r.getType();
            Set<String> specifiedRacks =
                  new HashSet<String>(Arrays.asList(r.getRacks()));

            if (rackType.equals(GroupRacksType.SAMERACK)
                  && specifiedRacks.size() != 1) {
               throw ClusterConfigException.MUST_DEFINE_ONE_RACK(ngc.getName());
            }

            List<String> intersecRacks = new ArrayList<String>();
            int intersecHostNum = 0;
            int maxIntersecHostNum = 0;

            for (RackInfo rackInfo : racksInfo) {
               if (specifiedRacks.isEmpty() || specifiedRacks.size() == 0
                     || specifiedRacks.contains(rackInfo.getName())) {
                  intersecHostNum += rackInfo.getHosts().size();
                  intersecRacks.add(rackInfo.getName());
                  if (rackInfo.getHosts().size() > maxIntersecHostNum) {
                     maxIntersecHostNum = rackInfo.getHosts().size();
                  }
               }
            }

            if (intersecRacks.size() == 0) {
               valid = false;
               throw ClusterConfigException.NO_VALID_RACK(ngc.getName());
            }

            if (ngc.calculateHostNum() != null) {
               if (rackType.equals(GroupRacksType.ROUNDROBIN)
                     && ngc.calculateHostNum() > intersecHostNum) {
                  valid = false;
                  throw ClusterConfigException.LACK_PHYSICAL_HOSTS(
                        ngc.calculateHostNum(), ngc.getName(), intersecHostNum);
               } else if (rackType.equals(GroupRacksType.SAMERACK)
                     && ngc.calculateHostNum() > maxIntersecHostNum) {
                  valid = false;
                  throw ClusterConfigException.LACK_PHYSICAL_HOSTS(
                        ngc.calculateHostNum(), ngc.getName(),
                        maxIntersecHostNum);
               }
            }

            if (specifiedRacks.isEmpty()) {
               r.setRacks(new String[0]);
            } else {
               r.setRacks(intersecRacks.toArray(new String[intersecRacks.size()]));
            }
         }
      }
      return valid;
   }
View Full Code Here

         if (getPlacementPolicies() == null) {
            setPlacementPolicies(new PlacementPolicy());
         }
         if (getPlacementPolicies().getGroupRacks() == null
               && getPlacementPolicies().getGroupAssociations() == null) {
            GroupRacks groupRacks = new GroupRacks();
            groupRacks.setType(GroupRacksType.ROUNDROBIN);
            groupRacks.setRacks(new String[0]);
            getPlacementPolicies().setGroupRacks(groupRacks);
         }
      }

      PlacementPolicy policies = getPlacementPolicies();
      if (policies != null) {
         if (policies.getInstancePerHost() != null) {
            if (policies.getInstancePerHost() <= 0) {
               valid = false;
               failedMsgList.add(new StringBuilder().append(getName())
                     .append(".placementPolicies.instancePerHost=")
                     .append(policies.getInstancePerHost()).append(".")
                     .toString());
            } else if (calculateHostNum() < 0) {
               valid = false;
               failedMsgList.add(new StringBuilder().append(getName())
                     .append(".placementPolicies.instancePerHost=")
                     .append(policies.getInstancePerHost())
                     .append(" must be evenly divisible.").toString());
            }
         }

         if (policies.getGroupRacks() != null) {
            GroupRacks r = policies.getGroupRacks();
            if (r.getType() == null) {
               r.setType(GroupRacksType.ROUNDROBIN);
            }

            if (r.getRacks() == null) {
               r.setRacks(new String[0]);
            }

            if (getStorage() != null
                  && getStorage().getType() != null
                  && getStorage().getType().equals(
View Full Code Here

      List<String> candidateRacks = new LinkedList<String>();

      // process rack policy
      boolean rrRackPolicy = false;
      GroupRacks rackPolicy = vNode.getParent().getGroupRacks();
      if (rackPolicy != null
            && GroupRacksType.ROUNDROBIN.equals(rackPolicy.getType())) {
         if (rackPolicy.getRacks() != null && rackPolicy.getRacks().length > 0) {
            candidateRacks = Arrays.asList(rackPolicy.getRacks());
         }
         /*
          * candidate racks are the joint set of the ones that are specified in group's
          * rack policy and the ones defined in hostToRack topology file
          */
 
View Full Code Here

TOP

Related Classes of com.vmware.bdd.apitypes.PlacementPolicy.GroupRacks

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.