/* (non-Javadoc)
   * @see entropy.monitoring.ConfigurationAdapter#extractConfiguration()
   */
  @Override
  public Configuration extractConfiguration() {

    Configuration config = new SimpleConfiguration();

    for (ServerType server : Utils.getAllServers(currentFit4Green)) {
      Node node = getNode(server);

      if (server.getStatus() == ServerStatusType.ON
          || server.getStatus()
              == ServerStatusType
                  .POWERING_ON) { // POWERING_ON nodes are seen as ON by entropy as they will be
        // soon on. This avoids ping-pong effect on the state.
        config.addOnline(node);

        for (VirtualMachineType VM : Utils.getVMs(server)) {
          VirtualMachine vm = getVM(node, VM);
          config.setRunOn(vm, node);
        }
      } else { // OFF, POWERING_OFF
        config.addOffline(node);
      }
    }
    return config;
  }
  private Node getNode(ServerType server) {
    ArrayList<CoreType> cores = Utils.getAllCores(server.getMainboard().get(0));

    // freq in Hz
    double freq = cores.get(0).getFrequency().getValue();
    int nbCPUs = cores.size();
    int cpuCapacity = nbCPUs * 100; // getCPUCapacity ((int) (freq / 1000000), nbCPUs);
    int memoryTotal = (int) Utils.getMemory(server) * 1024;
    int powerIdle = (int) getPIdle(server);
    int powerPerVM = (int) getPperVM(server);

    log.debug("creation of an Entropy Node with name " + server.getFrameworkID());
    log.debug("server is " + server.getStatus().toString());
    log.debug("nbCPUs " + nbCPUs);
    log.debug("freq " + freq + " GHz");
    log.debug("cpuCapacity " + cpuCapacity + " %");
    log.debug("memoryTotal " + memoryTotal + " MB");
    log.debug("powerIdle " + powerIdle + " W");
    log.debug("powerPerVM " + powerPerVM + " W");

    Node node =
        new F4GNode(
            server.getFrameworkID(), nbCPUs, cpuCapacity, memoryTotal, powerIdle, powerPerVM);
    return node;
  }
  public float getPIdle(ServerType server) {

    double ue = getUsageEffectiveness(server);

    ServerStatusType status = server.getStatus();
    server.setStatus(ServerStatusType.ON); // set the server status to ON to avoid a null power
    float powerIdle = (float) (powerCalculation.computePowerIdle(server, powerCalculator) * ue);
    server.setStatus(status);

    return powerIdle;
  }
  public float getPperVM(ServerType server) {

    double ue = getUsageEffectiveness(server);

    VMType vm = currentVMType.getVMType().get(0);
    ServerStatusType status = server.getStatus();
    server.setStatus(ServerStatusType.ON); // set the server status to ON to avoid a null power
    float PperVM = (float) (powerCalculation.computePowerForVM(server, vm, powerCalculator) * ue);
    server.setStatus(status);

    return PperVM;
  }
Example #5
0
  /**
   * Creates a list of virtual machines.
   *
   * @param actualHostList to store the hosts list.
   * @author jclegea
   */
  private void createHostVirtualMachineList(
      ArrayList actualHostList,
      int siteIndex,
      int datacenterIndex,
      int rackIndex,
      int enclosureIndex,
      int hostIndex)
      throws Exception {
    String key;
    HashMap serverList;
    ServerType serverType = new ServerType();
    VirtualMachineType serverVirtualMachine;
    List<VirtualMachineType> virtualMachineList;

    try {
      actualHostList.clear();
      key =
          this.comName
              + "_"
              + datacenterInformation_.getHostName(
                  siteIndex, datacenterIndex, rackIndex, enclosureIndex, hostIndex);
      serverList = monitor.getMonitoredObjectsCopy(this.comName);
      serverType = (ServerType) serverList.get(key);
      if (serverType != null) {
        virtualMachineList = serverType.getNativeHypervisor().getVirtualMachine();
        for (Iterator iterator = virtualMachineList.iterator(); iterator.hasNext(); ) {
          serverVirtualMachine = (VirtualMachineType) iterator.next();
          // log.debug("SERVERTYPE: " + serverVirtualMachine.getFrameworkID());
          actualHostList.add(serverVirtualMachine.getFrameworkID());
        }
      }

    } catch (Exception exception) {
      log.error("Cannot create actual virtual machine list");
    }
  }