-/* Copyright (c) 2014. The SimGrid Team.
+/* Copyright (c) 2014-2019. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
package cloud.migration;
-import java.util.Random;
-
-import org.simgrid.msg.*;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.HostFailureException;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
import org.simgrid.msg.Process;
+import org.simgrid.msg.VM;
// This test aims at validating that the migration process is robust in face of host turning off either on the SRC
// node or on the DST node.
protected Host host1 = null;
protected Host host2 = null;
- TestHostOnOff(String hostname, String name) throws HostNotFoundException, NativeException {
+ TestHostOnOff(String hostname, String name) throws HostNotFoundException {
super(hostname, name);
}
host1 = Host.getByName("PM1");
host2 = Host.getByName("PM2");
}catch (HostNotFoundException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ Msg.error("You are trying to use a non existing node:" + e.getMessage());
}
// Robustness on the SRC node
int dpRate = 70;
XVM vm0 = null;
vm0 = new XVM(host1, "vm0",
- 1, // Nb of vcpu
2048, // Ramsize,
- 125, // Net Bandwidth
- null, //VM disk image
- -1, //size of disk image,
125, // Net bandwidth,
dpRate // Memory intensity
);
try {
sourceHost = Host.getByName(args[1]);
destHost = Host.getByName(args[2]);
- } catch (Exception e) {
+ } catch (HostNotFoundException e) {
+ Msg.error("You are trying to migrate from/to a non existing node: " + e.getMessage());
e.printStackTrace();
- System.err.println("You are trying to migrate from/to a non existing node");
}
- if (destHost != null) {
- if (sourceHost.isOn() && destHost.isOn()) {
- try {
- Msg.info("Migrate vm "+args[0]+" to node "+destHost.getName());
- VM.getVMByName(args[0]).migrate(destHost);
- } catch (HostFailureException e) {
- Msg.info("Something occurs during the migration that cannot validate the operation");
- e.printStackTrace();
- }
+ if (destHost != null && sourceHost.isOn() && destHost.isOn()) {
+ try {
+ Msg.info("Migrate vm "+args[0]+" to node "+destHost.getName());
+ VM.getVMByName(args[0]).migrate(destHost);
+ } catch (HostFailureException e) {
+ Msg.error("Something occurs during the migration that cannot validate the operation: " + e.getMessage());
+ e.printStackTrace();
}
}
}
// Create VM0
int dpRate = 70;
XVM vm0 = new XVM(host1, "vm0",
- 1, // Nb of vcpu
2048, // Ramsize,
- 125, // Net Bandwidth
- null, //VM disk image
- -1, //size of disk image,
125, // Net bandwidth,
dpRate // Memory intensity
);
Msg.info("Restart VM0");
vm0 = new XVM(host1, "vm0",
- 1, // Nb of vcpu
2048, // Ramsize,
- 125, // Net Bandwidth
- null, //VM disk image
- -1, //size of disk image,
125, // Net bandwidth,
dpRate // Memory intensity
);