- private Host[] hosts;
-
- public Master(Host host, String name, Host[] hosts) {
- super(host,name,null);
- this.hosts = hosts;
- }
-
- public void main(String[] args) throws MsgException {
- int workersCount = Main.NHOSTS;
- ArrayList<VM> vms = new ArrayList<>();
-
- // Create one VM per host and bind a process inside each one.
- for (int i = 0; i < workersCount; i++) {
- Msg.info("create VM0"+i);
- VM vm = new VM(hosts[i+1],"VM0"+i);
- vm.start();
- vms.add(vm);
- Worker worker= new Worker(vm,i);
- Msg.info("Put Worker "+worker.getName()+ " on "+vm.getName());
- worker.start();
- }
-
- Msg.info("Launched " + vms.size() + " VMs");
-
- Msg.info("Send a first batch of work to everyone");
- workBatch(workersCount);
-
- Msg.info("Suspend all VMs");
- for (int i = 0; i < vms.size(); i++) {
- Msg.info("Suspend "+vms.get(i).getName());
- vms.get(i).suspend();
- }
-
- Msg.info("Wait a while");
- waitFor(2);
-
- Msg.info("Resume all VMs.");
- for (int i = 0; i < vms.size(); i++) {
- vms.get(i).resume();
- }
-
- Msg.info("Sleep long enough for everyone to be done with previous batch of work");
- waitFor(1000 - Msg.getClock());
-
-/* Msg.info("Add one more process per VM.");
+ private Host[] hosts;
+
+ public Master(Host host, String name, Host[] hosts) {
+ super(host,name,null);
+ this.hosts = hosts;
+ }
+
+ public void main(String[] args) throws MsgException {
+ int workersCount = Main.NHOSTS;
+
+ for (int step = 1; step <= Main.NSTEPS ; step++) {
+ // Create one VM per host and bind a process inside each one.
+ for (int i = 0; i < workersCount; i++) {
+ Msg.verb("create VM0-s"+step+"-"+i);
+ VM vm = new VM(hosts[i+1],"VM0-s"+step+"-"+i);
+ vm.start();
+ Worker worker= new Worker(vm,"WK:"+step+":"+ i);
+ Msg.verb("Put Worker "+worker.getName()+ " on "+vm.getName());
+ worker.start();
+ }
+ VM[] vms = VM.all();
+
+ Msg.info("Launched " + vms.length + " VMs");
+
+ Msg.info("Send some work to everyone");
+ workBatch(workersCount,"WK:"+step+":");
+
+ Msg.info("Suspend all VMs, wait a while, resume them, migrate them and shut them down.");
+ for (VM vm : vms) {
+ Msg.verb("Suspend "+vm.getName());
+ vm.suspend();
+ }
+
+ Msg.verb("Wait a while, and resume all VMs.");
+ waitFor(2);
+ for (VM vm : vms)
+ vm.resume();
+
+
+ Msg.verb("Sleep long enough for everyone to be done with previous batch of work");
+ waitFor(1000*step - Msg.getClock());
+
+ /* Msg.info("Add one more process per VM.");