Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get rid of the vm_params struct
[simgrid.git] / examples / java / energy / vm / EnergyVMRunner.java
index 6b37812..1fbb13b 100644 (file)
@@ -5,15 +5,14 @@
 
 package energy.vm;
 
-import org.simgrid.msg.Msg;
-import org.simgrid.msg.VM;
 import org.simgrid.msg.Host;
-import org.simgrid.msg.Task;
-import org.simgrid.msg.Process;
 import org.simgrid.msg.HostFailureException;
 import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.Task;
 import org.simgrid.msg.TaskCancelledException;
-import org.simgrid.msg.NativeException;
+import org.simgrid.msg.VM;
 
 /* This class is a process in charge of running the test. It creates and starts the VMs, and fork processes within VMs */
 public class EnergyVMRunner extends Process {
@@ -28,7 +27,7 @@ public class EnergyVMRunner extends Process {
       Task  task = new Task(this.getHost().getName()+"-task", 300E6 , 0);
       try {
         task.execute();
-      } catch (HostFailureException | TaskCancelledException e) { // If your compiler fails on that multicatch, please proceed to Java 1.7 or higher
+      } catch (HostFailureException | TaskCancelledException e) {
         Msg.error(e.getMessage());
         e.printStackTrace();
       } 
@@ -36,7 +35,7 @@ public class EnergyVMRunner extends Process {
     }
   }
 
-  EnergyVMRunner(Host host, String name, String[] args) throws HostNotFoundException, NativeException  {
+  EnergyVMRunner(Host host, String name, String[] args) throws HostNotFoundException {
     super(host, name, args);
   }
 
@@ -48,31 +47,31 @@ public class EnergyVMRunner extends Process {
     Host host3 = Host.getByName("MyHost3");
 
     Msg.info("Creating and starting two VMs");
-    VM vmHost1 = new VM(host1, "vmHost1", 2048, 10, 50);
+    VM vmHost1 = new VM(host1, "vmHost1");
     vmHost1.start();
 
-    VM vmHost3 = new VM(host3, "vmHost3", 2048, 10, 50);
-    vmHost3.start();
+    VM vmHost2 = new VM(host2, "vmHost3");
+    vmHost2.start();
 
     Msg.info("Create two tasks on Host1: one inside a VM, the other directly on the host");
     new DummyProcess (vmHost1, "p11").start(); 
-    new DummyProcess (host1, "p12").start(); 
+    new DummyProcess (vmHost1, "p12").start(); 
 
     Msg.info("Create two tasks on Host2: both directly on the host");
-    new DummyProcess (host2, "p21").start(); 
-    new DummyProcess (host2, "p22").start(); 
+    new DummyProcess (vmHost2, "p21").start();
+    new DummyProcess (host2, "p22").start();
 
     Msg.info("Create two tasks on Host3: both inside a VM");
-    new DummyProcess (vmHost3, "p31").start(); 
-    new DummyProcess (vmHost3, "p312").start(); 
+    new DummyProcess (host3, "p31").start();
+    new DummyProcess (host3, "p312").start();
 
     Msg.info("Wait 5 seconds. The tasks are still running (they run for 3 seconds, but 2 tasks are co-located, "
              + "so they run for 6 seconds)"); 
-    waitFor(5); 
+    waitFor(5);
     Msg.info("Wait another 5 seconds. The tasks stop at some point in between"); 
-    waitFor(5); 
+    waitFor(5);
 
-    vmHost1.destroy(); 
-    vmHost3.destroy(); 
+    vmHost1.destroy();
+    vmHost2.destroy();
   }
 }