A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #193 from Takishipp/signals
[simgrid.git]
/
examples
/
java
/
energy
/
vm
/
EnergyVMRunner.java
diff --git
a/examples/java/energy/vm/EnergyVMRunner.java
b/examples/java/energy/vm/EnergyVMRunner.java
index
b7a2102
..
62e359d
100644
(file)
--- a/
examples/java/energy/vm/EnergyVMRunner.java
+++ b/
examples/java/energy/vm/EnergyVMRunner.java
@@
-5,16
+5,14
@@
package energy.vm;
package energy.vm;
-import org.simgrid.msg.Msg;
-import org.simgrid.msg.VM;
import org.simgrid.msg.Host;
import org.simgrid.msg.Host;
-import org.simgrid.msg.Task;
-import org.simgrid.msg.Process;
-import org.simgrid.msg.MsgException;
import org.simgrid.msg.HostFailureException;
import org.simgrid.msg.HostNotFoundException;
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.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 {
/* 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 {
@@
-30,44
+28,42
@@
public class EnergyVMRunner extends Process {
try {
task.execute();
} catch (HostFailureException | TaskCancelledException e) {
try {
task.execute();
} catch (HostFailureException | TaskCancelledException e) {
+ Msg.error(e.getMessage());
e.printStackTrace();
}
Msg.info("This worker is done.");
}
}
e.printStackTrace();
}
Msg.info("This worker is done.");
}
}
- EnergyVMRunner(Host host, String name, String[] args) throws HostNotFoundException
, NativeException
{
+ EnergyVMRunner(Host host, String name, String[] args) throws HostNotFoundException {
super(host, name, args);
}
@Override
super(host, name, args);
}
@Override
- public void main(String[] strings) throws MsgException, HostNotFoundException {
- double startTime = 0;
- double endTime = 0;
-
+ public void main(String[] strings) throws HostNotFoundException, HostFailureException {
/* get hosts */
Host host1 = Host.getByName("MyHost1");
Host host2 = Host.getByName("MyHost2");
Host host3 = Host.getByName("MyHost3");
Msg.info("Creating and starting two VMs");
/* get hosts */
Host host1 = Host.getByName("MyHost1");
Host host2 = Host.getByName("MyHost2");
Host host3 = Host.getByName("MyHost3");
Msg.info("Creating and starting two VMs");
- VM vmHost1 = new VM(host1, "vmHost1",
4, 2048, 100, null, 1024 * 20, 10,
50);
+ VM vmHost1 = new VM(host1, "vmHost1",
2048, 10,
50);
vmHost1.start();
vmHost1.start();
- VM vmHost
3 = new VM(host3, "vmHost3", 4, 2048, 100, null, 1024 * 20, 10,
50);
- vmHost
3
.start();
+ VM vmHost
2 = new VM(host2, "vmHost3", 2048, 10,
50);
+ vmHost
2
.start();
Msg.info("Create two tasks on Host1: one inside a VM, the other directly on the host");
Msg.info("Create two tasks on Host1: one inside a VM, the other directly on the host");
- new DummyProcess (vmHost1, "p11");
- new DummyProcess (
host1, "p12"
);
+ new DummyProcess (vmHost1, "p11")
.start()
;
+ new DummyProcess (
vmHost1, "p12").start(
);
Msg.info("Create two tasks on Host2: both directly on the host");
Msg.info("Create two tasks on Host2: both directly on the host");
- new DummyProcess (
host2, "p21"
);
- new DummyProcess (host2, "p22");
+ new DummyProcess (
vmHost2, "p21").start(
);
+ new DummyProcess (host2, "p22")
.start()
;
Msg.info("Create two tasks on Host3: both inside a VM");
Msg.info("Create two tasks on Host3: both inside a VM");
- new DummyProcess (
vmHost3, "p31"
);
- new DummyProcess (
vmHost3, "p312"
);
+ 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)");
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)");
@@
-75,9
+71,7
@@
public class EnergyVMRunner extends Process {
Msg.info("Wait another 5 seconds. The tasks stop at some point in between");
waitFor(5);
Msg.info("Wait another 5 seconds. The tasks stop at some point in between");
waitFor(5);
- vmHost1.shutdown();
- vmHost3.shutdown();
- vmHost1.finalize();
- vmHost3.finalize();
+ vmHost1.destroy();
+ vmHost2.destroy();
}
}
}
}