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

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


   }

   private AbstractDatastore getLeastUsedDatastore(
         Map<AbstractDatastore, Integer> usage, int requiredInGB) {
      int min = Integer.MAX_VALUE;
      AbstractDatastore result = null;

      for (AbstractDatastore ads : usage.keySet()) {
         if (ads.getFreeSpace() >= requiredInGB && usage.get(ads) < min) {
            min = usage.get(ads);
            result = ads;
View Full Code Here


      List<DiskSpec> replacements = new ArrayList<DiskSpec>(badDisks.size());

      for (DiskSpec disk : badDisks) {
         int requiredSize = disk.getSize();
         AbstractDatastore ads = getLeastUsedDatastore(usage, requiredSize);
         if (ads == null) {
            throw ClusterHealServiceException.NOT_ENOUGH_STORAGE(nodeName,
                  "Cannot find a datastore with enough space to place disk "
                        + disk.getName() + " of size " + disk.getSize()
                        + " GB");
         }

         DiskSpec replacement = new DiskSpec(disk);
         replacement.setTargetDs(ads.getName());
         replacement.setVmdkPath(null);
         replacements.add(replacement);

         // deduct space
         ads.allocate(requiredSize);
         // increase reference by 1
         usage.put(ads, usage.get(ads) + 1);
      }

      return replacements;
View Full Code Here

      List<AbstractDatastore> pools =
            new ArrayList<AbstractDatastore>(validDatastores.size());

      for (VcDatastore ds : validDatastores) {
         totalSizeInGB += ds.getFreeSpace() >> 30;
         AbstractDatastore ads =
               new AbstractDatastore(ds.getName(),
                     (int) (ds.getFreeSpace() >> 30));
         pools.add(ads);
         usage.put(ads, 0);
      }

      int requiredSizeInGB = 0;
      for (DiskSpec disk : badDisks) {
         requiredSizeInGB += disk.getSize();
      }

      if (totalSizeInGB < requiredSizeInGB) {
         throw ClusterHealServiceException.NOT_ENOUGH_STORAGE(nodeName,
               "" + requiredSizeInGB + " GB storage is required on host "
                     + targetHost.getName() + ", but only " + totalSizeInGB
                     + " GB available");
      }

      List<DiskEntity> goodDisks = clusterEntityMgr.getDisks(nodeName);

      // collects datastore usages
      for (DiskEntity disk : goodDisks) {
         boolean bad = false;
         for (DiskSpec diskSpec : badDisks) {
            if (disk.getName().equals(diskSpec.getName())) {
               bad = true;
               break;
            }
         }

         // ignore bad disks
         if (bad)
            continue;

         AbstractDatastore targetAds = null;
         for (AbstractDatastore ads : pools) {
            if (ads.getName().equals(disk.getDatastoreName())) {
               targetAds = ads;
               break;
            }
View Full Code Here

         // in dc.datastores
         for (AbstractCluster cluster : dc.getClusters()) {
            // replace datastores in cluster level
            List<AbstractDatastore> dsList = new ArrayList<AbstractDatastore>();
            for (AbstractDatastore datastore : cluster.getDatastores()) {
               AbstractDatastore ds =
                     dc.findAbstractDatastore(datastore.getName());
               AuAssert.check(ds != null);
               dsList.add(ds);
            }
            cluster.setDatastores(dsList);

            // replace datastores in host level
            for (AbstractHost host : cluster.getHosts()) {
               List<AbstractDatastore> datastores =
                     new ArrayList<AbstractDatastore>();
               for (AbstractDatastore datastore : host.getDatastores()) {
                  AbstractDatastore ds =
                        dc.findAbstractDatastore(datastore.getName());
                  AuAssert.check(ds != null);
                  datastores.add(ds);
               }
               host.setDatastores(datastores);
View Full Code Here

      diskSpec.setSize(40);
      diskSpecs.add(diskSpec);

      //5 Datastores with 5G, 10G, 20G, 30G, 50G free space
      List<AbstractDatastore> datastores = new ArrayList<AbstractDatastore>();
      AbstractDatastore datastore = new AbstractDatastore("datastore1", 5);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore2", 10);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore3", 20);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore4", 30);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore5", 50);
      datastores.add(datastore);

      Method placeUnSeparableDisks = PlacementPlanner.class.
            getDeclaredMethod("placeUnSeparableDisks", List.class, List.class);
      placeUnSeparableDisks.setAccessible(true);
View Full Code Here

      diskSpec.setName("diskSpec");
      diskSpec.setSize(50);

      //5 Datastores with 5G, 10G, 20G, 30G, 50G free space
      List<AbstractDatastore> datastores = new ArrayList<AbstractDatastore>();
      AbstractDatastore datastore = new AbstractDatastore("datastore1", 5);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore2", 10);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore3", 20);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore4", 30);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore5", 50);
      datastores.add(datastore);

      //Use reflection to invoke private method PlacementPlanner.evenSpliter()
      Method evenSpliter = PlacementPlanner.class.getDeclaredMethod("evenSpliter", DiskSpec.class, List.class);
      evenSpliter.setAccessible(true);
View Full Code Here

      diskSpec.setName("diskSpec");
      diskSpec.setSize(70);

      //5 Datastores with 5G, 10G, 20G, 30G, 50G free space
      List<AbstractDatastore> datastores = new ArrayList<AbstractDatastore>();
      AbstractDatastore datastore = new AbstractDatastore("datastore1", 5);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore2", 10);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore3", 20);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore4", 30);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore5", 50);
      datastores.add(datastore);

      //Use reflection to invoke private method PlacementPlanner.evenSpliter()
      Method aggregateSpliter = PlacementPlanner.class.getDeclaredMethod("aggregateSpliter", DiskSpec.class, List.class);
      aggregateSpliter.setAccessible(true);
View Full Code Here

      diskSpec.setName("diskSpec");
      diskSpec.setSize(10);

      //5 Datastores with 5G, 10G, 20G, 30G, 50G free space
      List<AbstractDatastore> datastores = new ArrayList<AbstractDatastore>();
      AbstractDatastore datastore = new AbstractDatastore("datastore1", 10);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore2", 9);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore3", 8);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore4", 7);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore5", 3);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore6", 1);
      datastores.add(datastore);
      datastore = new AbstractDatastore("datastore7", 1);
      datastores.add(datastore);

      //Use reflection to invoke private method PlacementPlanner.evenSpliter()
      Method evenSpliter = PlacementPlanner.class.getDeclaredMethod("evenSpliter", DiskSpec.class, List.class);
      evenSpliter.setAccessible(true);
View Full Code Here

            logger.info("datastore " + datastore.getName()
                  + " is inaccessible or in maintanence mode. Ignore it.");
            continue;
         }
         if (this.dc.findAbstractDatastore(datastore.getName()) == null) {
            AbstractDatastore ds = new AbstractDatastore(datastore.getName());
            ds.setFreeSpace((int) (datastore.getFreeSpace() / (1024 * 1024 * 1024)));
            this.dc.addDatastore(ds);

            logger.info("added datastore " + ds.getName() + " with space "
                  + ds.getFreeSpace() + " to datacenter");
         }
      }

      // translate cluster and hosts
      AbstractCluster abstractCluster = new AbstractCluster(cluster.getName());

      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);
               logger.info("added host " + host.getName() + " to container");
            }
         }

         // add datastores
         for (VcDatastore datastore : cluster.getAllDatastores()) {
            AbstractDatastore ds =
                  this.dc.findAbstractDatastore(datastore.getName());
            if (ds != null) {
               abstractCluster.addDatastore(ds);
               logger.info("added datastore " + ds.getName() + " with space "
                     + ds.getFreeSpace() + " to cluster " + cluster.getName());
            }
         }

         this.dc.addCluster(abstractCluster);
      } catch (Exception e) {
View Full Code Here

      Collections.shuffle(datastores);

      for (DiskSpec disk : disks) {
         int i = 0;
         for (; i < datastores.size(); i++) {
            AbstractDatastore ds = datastores.get(i);
            if (disk.getSize() <= ds.getFreeSpace()) {
               disk.setTargetDs(ds.getName());
               ds.allocate(disk.getSize());
               result.add(disk);
               Collections.rotate(datastores, 1);
               break;
            }
         }
View Full Code Here

TOP

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

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.