Ejemplo n.º 1
0
  // create an instance in the format of CreateAppInsertIntoVm.arff
  // eval can either be a Instance - MissingValue or the evaluation value
  private Instance createInstance(double eval, VirtualMachine vm) {
    Instance instance = new Instance(64);

    LinkedList<Integer> cpuallhist = vm.getCpuAllocationHistory(10);
    LinkedList<Integer> cpuusehist = vm.getCpuUsageHistory(10);

    LinkedList<Integer> memallhist = vm.getMemoryAllocationHistory(10);
    LinkedList<Integer> memusehist = vm.getMemoryUsageHistory(10);

    LinkedList<Integer> storageallhist = vm.getStorageAllocationHistory(10);
    LinkedList<Integer> storageusehist = vm.getStorageUsageHistory(10);

    // CPU/Memory/Storage - Allocation history before the new vm was created
    for (int i = 0; i < 10; i++) {
      // cpu allocation
      instance.setValue(getKnowledgeBase().attribute(i), clusterValue(cpuallhist.get(i)));
      // cpu usage
      instance.setValue(getKnowledgeBase().attribute(i + 10), clusterValue(cpuusehist.get(i)));

      // memory allocation
      instance.setValue(getKnowledgeBase().attribute(i + 20), clusterValue(memallhist.get(i)));
      // memory usage
      instance.setValue(getKnowledgeBase().attribute(i + 30), clusterValue(memusehist.get(i)));

      // storage allocation
      instance.setValue(getKnowledgeBase().attribute(i + 40), clusterValue(storageallhist.get(i)));
      // storage usage
      instance.setValue(getKnowledgeBase().attribute(i + 50), clusterValue(storageusehist.get(i)));
    }

    // SLAs
    // CPU
    instance.setValue(getKnowledgeBase().attribute(60), clusterValue(app.getCpu()));
    // Memory
    instance.setValue(getKnowledgeBase().attribute(61), clusterValue(app.getMemory()));
    // Storage
    instance.setValue(getKnowledgeBase().attribute(62), clusterValue(app.getStorage()));

    // Evaluation
    instance.setValue(getKnowledgeBase().attribute(63), eval);

    return instance;
  }