Package com.vmware.bdd.placement

Examples of com.vmware.bdd.placement.Container


         List<BaseNode> existedNodes) {

      logger.info("Begin to calculate provision plan.");

      logger.info("Calling resource manager to get available vc hosts");
      Container container = new Container();

      List<VcCluster> clusters = resMgr.getAvailableClusters();
      AuAssert.check(clusters != null && clusters.size() != 0);
      for (VcCluster cl : clusters) {
         VcResourceUtils.refreshDatastore(cl);
         container.addResource(cl);
      }

      // check time on hosts
      int maxTimeDiffInSec = Constants.MAX_TIME_DIFF_IN_SEC;
      SoftwareManager softMgr =
            softwareManagerCollector.getSoftwareManager(clusterSpec
                  .getAppManager());
      if (softMgr.hasHbase(clusterSpec.toBlueprint()))
         maxTimeDiffInSec = Constants.MAX_TIME_DIFF_IN_SEC_HBASE;

      List<String> outOfSyncHosts = new ArrayList<String>();
      for (AbstractHost host : container.getAllHosts()) {
         int hostTimeDiffInSec =
               VcResourceUtils.getHostTimeDiffInSec(host.getName());
         if (Math.abs(hostTimeDiffInSec) > maxTimeDiffInSec) {
            logger.info("Host " + host.getName() + " has a time difference of "
                  + hostTimeDiffInSec
                  + " seconds and is dropped from placement.");
            outOfSyncHosts.add(host.getName());
         }
      }
      for (String host : outOfSyncHosts) {
         container.removeHost(host);
      }

      // filter hosts by networks
      List<com.vmware.bdd.spectypes.VcCluster> usedClusters = clusterSpec.getVcClusters();
      List<String> noNetworkHosts = new ArrayList<String>();
      noNetworkHosts = resMgr.filterHostsByNetwork(clusterSpec.getNetworkNames(), usedClusters);

      for (String host : noNetworkHosts) {
         container.removeHost(host);
      }

      Map<String, List<String>> filteredHosts =new HashMap<String, List<String>>();
      if (!outOfSyncHosts.isEmpty()) filteredHosts.put(PlacementUtil.OUT_OF_SYNC_HOSTS, outOfSyncHosts);
      if (!noNetworkHosts.isEmpty()) {
         filteredHosts.put(PlacementUtil.NO_NETWORKS_HOSTS, noNetworkHosts);
         filteredHosts.put(PlacementUtil.NETWORK_NAMES, clusterSpec.getNetworkNames());
      }

      container.SetTemplateNode(templateNode);
      if (clusterSpec.getHostToRackMap() != null
            && clusterSpec.getHostToRackMap().size() != 0) {
         container.addRackMap(clusterSpec.getHostToRackMap());
      }

      // rack topology file validation
      Set<String> validRacks = new HashSet<String>();
      List<AbstractHost> hosts = container.getAllHosts();
      for (AbstractHost host : hosts) {
         if (container.getRack(host) != null) {
            // this rack is valid as it contains at least one host
            validRacks.add(container.getRack(host));
         }
      }

      for (NodeGroupCreate nodeGroup : clusterSpec.getNodeGroups()) {
         if (nodeGroup.getPlacementPolicies() != null
View Full Code Here

TOP

Related Classes of com.vmware.bdd.placement.Container

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.