コード例 #1
0
  /**
   * Creates instances of CloudSim's PowerPe class from a host registry.
   *
   * @param hr a host registry.
   * @return a list of PowerPe instances.
   * @since 1.0
   */
  static List<Pe> createPes(HostRegistry hr) {
    List<Pe> list = new ArrayList<Pe>();

    for (int i = 0; i < hr.getNumOfPes(); i++) {

      Optional<PeProvisioner> pp =
          PE_PROVISIONER.getExtensionInstanceByName(hr.getPeProvisionerAlias(), hr.getMipsPerPe());

      if (!pp.isPresent()) {
        Dialog.showErrorMessage(
            null,
            format("Error on loading the PE provisioning policy [%s]", hr.getPeProvisionerAlias()));
        return null;
      }

      list.add(new Pe(i, pp.get()));
    }

    return list;
  }
コード例 #2
0
  /**
   * Creates instances of CloudSim's PowerHost class from a list of host registers.
   *
   * @param hostList a list of datacenter registers
   * @return a list of PowerHost instances.
   * @since 1.0
   */
  static List<PowerHost> createHosts(final List<HostRegistry> hostList) {
    final List<PowerHost> list = new ArrayList<PowerHost>();

    int i = 0;

    for (HostRegistry hr : hostList) {
      for (int n = 0; n < hr.getAmount(); n++) {
        List<Pe> peList = createPes(hr);

        if (peList == null) {
          return null;
        }

        Optional<RamProvisioner> rp =
            RAM_PROVISIONER.getExtensionInstanceByName(hr.getRamProvisionerAlias(), hr.getRam());

        if (!rp.isPresent()) {
          Dialog.showErrorMessage(
              null,
              format("Error on loading the RAM provisioner [%s]", hr.getRamProvisionerAlias()));
          return null;
        }

        Optional<BwProvisioner> bp =
            BW_PROVISIONER.getExtensionInstanceByName(
                hr.getBwProvisionerAlias(), (long) hr.getBw());

        if (!bp.isPresent()) {
          Dialog.showErrorMessage(
              null,
              format(
                  "Error on loading the bandwidth provisioner [%s]", hr.getBwProvisionerAlias()));
          return null;
        }

        Optional<VmScheduler> vs =
            VM_SCHEDULER.getExtensionInstanceByName(hr.getSchedulingPolicyAlias(), peList);

        if (!vs.isPresent()) {
          Dialog.showErrorMessage(
              null,
              format(
                  "Error on loading the VM scheduling policy [%s]", hr.getSchedulingPolicyAlias()));
          return null;
        }

        Optional<PowerModel> pm =
            POWER_MODEL.getExtensionInstanceByName(
                hr.getPowerModelAlias(), hr.getMaxPower(), hr.getStaticPowerPercent());

        if (!pm.isPresent()) {
          Dialog.showErrorMessage(
              null, format("Error on loading the power model [%s]", hr.getPowerModelAlias()));
          return null;
        }

        list.add(new PowerHost(i, rp.get(), bp.get(), hr.getStorage(), peList, vs.get(), pm.get()));
        i++;
      }
    }

    return list;
  }