예제 #1
0
  /**
   * Gets the sla metrics.
   *
   * @param vms the vms
   * @return the sla metrics
   */
  protected static Map<String, Double> getSlaMetrics(List<Vm> vms) {
    Map<String, Double> metrics = new HashMap<String, Double>();
    List<Double> slaViolation = new LinkedList<Double>();
    double totalAllocated = 0;
    double totalRequested = 0;
    double totalUnderAllocatedDueToMigration = 0;

    for (Vm vm : vms) {
      double vmTotalAllocated = 0;
      double vmTotalRequested = 0;
      double vmUnderAllocatedDueToMigration = 0;
      double previousTime = -1;
      double previousAllocated = 0;
      double previousRequested = 0;
      boolean previousIsInMigration = false;

      for (VmStateHistoryEntry entry : vm.getStateHistory()) {
        if (previousTime != -1) {
          double timeDiff = entry.getTime() - previousTime;
          vmTotalAllocated += previousAllocated * timeDiff;
          vmTotalRequested += previousRequested * timeDiff;

          if (previousAllocated < previousRequested) {
            slaViolation.add((previousRequested - previousAllocated) / previousRequested);
            if (previousIsInMigration) {
              vmUnderAllocatedDueToMigration += (previousRequested - previousAllocated) * timeDiff;
            }
          }
        }

        previousAllocated = entry.getAllocatedMips();
        previousRequested = entry.getRequestedMips();
        previousTime = entry.getTime();
        previousIsInMigration = entry.isInMigration();
      }

      totalAllocated += vmTotalAllocated;
      totalRequested += vmTotalRequested;
      totalUnderAllocatedDueToMigration += vmUnderAllocatedDueToMigration;
    }

    metrics.put("overall", (totalRequested - totalAllocated) / totalRequested);
    if (slaViolation.isEmpty()) {
      metrics.put("average", 0.);
    } else {
      metrics.put("average", MathUtil.mean(slaViolation));
    }
    metrics.put("underallocated_migration", totalUnderAllocatedDueToMigration / totalRequested);
    // metrics.put("sla_time_per_vm_with_migration", slaViolationTimePerVmWithMigration /
    // totalTime);
    // metrics.put("sla_time_per_vm_without_migration", slaViolationTimePerVmWithoutMigration /
    // totalTime);

    return metrics;
  }
예제 #2
0
 /**
  * Gets the times before vm migration.
  *
  * @param vms the vms
  * @return the times before vm migration
  */
 public static List<Double> getTimesBeforeVmMigration(List<Vm> vms) {
   List<Double> timeBeforeVmMigration = new LinkedList<Double>();
   for (Vm vm : vms) {
     boolean previousIsInMigration = false;
     double lastTimeMigrationFinished = 0;
     for (VmStateHistoryEntry entry : vm.getStateHistory()) {
       if (previousIsInMigration == true && entry.isInMigration() == false) {
         timeBeforeVmMigration.add(entry.getTime() - lastTimeMigrationFinished);
       }
       if (previousIsInMigration == false && entry.isInMigration() == true) {
         lastTimeMigrationFinished = entry.getTime();
       }
       previousIsInMigration = entry.isInMigration();
     }
   }
   return timeBeforeVmMigration;
 }