1 package at.ac.tuwien.lsdc.management;
3 import java.util.HashMap;
5 import at.ac.tuwien.lsdc.types.PhysicalMachine;
7 public class MachineManager {
8 // this class is responsible to start and stop PMs & VMs
9 // also it will be used to put an application on a VM
10 // move an application and get utilization data
12 private HashMap<Integer, PhysicalMachine> PMs = new HashMap<Integer, PhysicalMachine>();
14 public MachineManager(int numPMs) {
18 private void init(int numPMs) {
19 for (int i = 0; i < numPMs; i++) {
20 PhysicalMachine pm = new PhysicalMachine();
21 PMs.put(pm.getId(), pm);
25 public double getCurrentConsumption() {
26 double consumption = 0;
27 for (PhysicalMachine pm : PMs.values()) {
29 consumption = consumption + pm.getConsumption();
34 public int countCurrentlyRunningPMs() {
36 for (PhysicalMachine pm : PMs.values()) {
43 public int countCurrentlyRunningVMs() {
45 for (PhysicalMachine pm : PMs.values()) {
47 running += pm.countCurrentlyRunningVMs();