Package com.vmware.bdd.placement.entity.AbstractDatacenter

Examples of com.vmware.bdd.placement.entity.AbstractDatacenter.AbstractHost


                  .getAbstractDatacenter(TestPlacementUtil.DATACENTER_SPEC);

      Container container = new Container(dc);
      container.SetTemplateNode(TestPlacementUtil.getTemplateNode());
      List<AbstractHost> allHosts = container.getAllHosts();
      AbstractHost host = allHosts.get(0);
      container.removeHost(host.getName());
      List<String> outOfSyncHosts = new ArrayList<String>();
      outOfSyncHosts.add(host.getName());
      List<String> noNetworkHosts = new ArrayList<String>();
      noNetworkHosts.add(host.getName());
      Map<String, List<String>> filteredHosts = new HashMap<String, List<String>>();
      filteredHosts.put(PlacementUtil.OUT_OF_SYNC_HOSTS, outOfSyncHosts);
      filteredHosts.put(PlacementUtil.NETWORK_NAMES, new ArrayList<String>(Arrays.asList("VM Network")));
      filteredHosts.put(PlacementUtil.NO_NETWORKS_HOSTS, noNetworkHosts);
View Full Code Here


      try {
         // add hosts
         for (VcHost host : cluster.getHosts()) {
            if (host.isConnected() && !host.isUnavailbleForManagement()
                  && host.getDatastores() != null && host.getDatastores().size() > 0) {
               AbstractHost abstractHost = new AbstractHost(host.getName());
               for (VcDatastore datastore : host.getDatastores()) {
                  AbstractDatastore ds =
                        this.dc.findAbstractDatastore(datastore.getName());
                  if (ds != null) {
                     abstractHost.addDatastore(ds);
                     logger.info("added datastore " + ds.getName() + " to host "
                           + host.getName());
                  }
               }
               abstractCluster.addHost(abstractHost);
View Full Code Here

   public void removeHost(String hostname) {
      for (AbstractCluster cluster : this.dc.getClusters()) {
         List<AbstractHost> hosts = cluster.getHosts();
         Iterator<AbstractHost> it = hosts.iterator();
         while ( it.hasNext() ) {
            AbstractHost h = it.next();
            if (h.getName().equals(hostname)) {
               hosts.remove(h);
               logger.info("remove " + hostname + " from cluster " + cluster.getName());
               return;
            }
         }
View Full Code Here

      return associatedCandidates;
   }

   private AbstractHost getLeastUsed(List<AbstractHost> candidates) {
      int min = Integer.MAX_VALUE;
      AbstractHost candidate = null;

      for (AbstractHost host : candidates) {
         if (!hostMapByCluster.containsKey(host.getName())) {
            return host;
         } else if (hostMapByCluster.get(host.getName()) < min) {
View Full Code Here

      return size;
   }

   // try to place disk onto a host, inject the disk placement plans into BaseNode.disks field
   private boolean placeDisk(VirtualNode vNode, AbstractHost host) {
      AbstractHost clonedHost = AbstractHost.clone(host);

      Map<BaseNode, List<DiskSpec>> result =
            new HashMap<BaseNode, List<DiskSpec>>();

      for (BaseNode node : vNode.getBaseNodes()) {
         List<DiskSpec> disks;

         List<AbstractDatastore> imagestores =
               clonedHost.getDatastores(node.getImagestoreNamePattern());

         List<AbstractDatastore> diskstores =
               clonedHost.getDatastores(node.getDiskstoreNamePattern());

         // system and swap disk
         List<DiskSpec> systemDisks = new ArrayList<DiskSpec>();
         // un-separable disks
         List<DiskSpec> unseparable = new ArrayList<DiskSpec>();
View Full Code Here

         logger.info("vNode " + vNode.getBaseNodeNames()
               + " has RoundRobin Rack policy");
         logger.info("Candidate racks are " + candidateRacks);
      }

      AbstractHost candidate = null;
      boolean found = false;
      int rackIndex = 0;
      while (candidates.size() > 0) {
         List<AbstractHost> subset = candidates;
         if (rrRackPolicy) {
            while (rackIndex < candidateRacks.size()) {
               subset = rackFilter(candidates, candidateRacks.get(rackIndex));
               if (subset.size() > 0) {
                  break;
               }
               rackIndex++;
            }
            if (rackIndex == candidateRacks.size()) {
               logger.warn("tried with all candidate racks, there are no host are available");
               if (isAssociatedCandidates)
                  return null;
               else
                  throw PlacementException.OUT_OF_RACK(candidateRacks, vNode.getBaseNodeNames());
            }
            logger.info("try hosts on Rack " + candidateRacks.get(rackIndex));
         }

         // least used hosts, RR policy
         candidate = getLeastUsed(subset);

         logger.info("found a candidate host " + candidate
               + ", try to place disk onto it");

         // generate the disk placement plan for a candidate host
         if (placeDisk(vNode, candidate)) {
            // assign host
            logger.info("candidate host " + candidate + " is selected");
            assignHost(vNode, candidate);
            found = true;
            break;
         }

         logger.info("drop candidate host " + candidate.getName()
               + " as it failed to come out a  disk placement plan");
         candidates.remove(candidate);
      }

      if (!found)
View Full Code Here

      if (vNode.getReferToGroup() != null) {
         associatedCandidates = groupAssociationFilter(vNode, candidates);
         logger.info("candidates " + associatedCandidates
               + " passed strict group association filter");

         AbstractHost candidate = assignHost(vNode, associatedCandidates, true);
         if (candidate != null) {
            logger.info("found candiate host " + candidate
                  + " satisfying the group association policy");
            return candidate;
         }
View Full Code Here

                  + "to place the virtual node " + vNode.getBaseNodeNames());
            throw PlacementException.OUT_OF_VC_HOST(PlacementUtil.getBaseNodeNames(vNode));
         }

         // select host
         AbstractHost host = planner.selectHost(vNode, candidates);

         if (host == null) {
            logger.error("cannot find a candidate from host lists "
                  + candidates + " for the virtual node "
                  + vNode.getBaseNodeNames());
View Full Code Here

TOP

Related Classes of com.vmware.bdd.placement.entity.AbstractDatacenter.AbstractHost

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.