1 /* Copyright (c) 2014-2018. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 package cloud.migration;
7 import java.util.ArrayList;
10 import org.simgrid.msg.Host;
11 import org.simgrid.msg.HostFailureException;
12 import org.simgrid.msg.HostNotFoundException;
13 import org.simgrid.msg.Msg;
14 import org.simgrid.msg.MsgException;
15 import org.simgrid.msg.Process;
16 import org.simgrid.msg.VM;
18 public class Test extends Process{
20 Test(String hostname, String name) throws HostNotFoundException {
21 super(hostname, name);
24 public void doMigration(VM vm, Host src, Host dst) throws HostFailureException{
25 Msg.info(" - Launch migration from "+ src.getName() +" to " + dst.getName());
26 double startTime = Msg.getClock();
28 double endTime = Msg.getClock();
29 Msg.info(" - End of Migration from "+ src.getName() +" to " + dst.getName()+ " (duration:" +
30 (endTime-startTime)+")");
33 public void main(String[] strings) throws MsgException {
34 Host host0 = Host.getByName("PM0");
35 Host host1 = Host.getByName("PM1");
37 List<VM> vms = new ArrayList<>();
44 Msg.info("This example evaluates the migration time of a VM in presence of collocated VMs on the source and "
46 Msg.info("The migrated VM has a memory intensity rate of 70% of the network BW and a cpu load of 90% \" "
47 +"(see cloudcom 2013 paper \"Adding a Live Migration Model Into SimGrid\" for further information) ");
49 Msg.info("Load of collocated VMs fluctuate between 0 and 90% in order to create a starvation issue and see "
50 + "whether it impacts or not the migration time");
51 XVM vm1 = new XVM(host0, "vm0",
53 125, // Net bandwidth,
54 dpRate // Memory intensity
70 for (int i=1 ; i<= vmSrcLoad.length ; i++){
71 tmp = new XVM(host0, "vm"+i,
73 125, // Net bandwidth,
74 dpRate // Memory intensity
78 tmp.setLoad(vmSrcLoad[i-1]);
90 for (int i=1 ; i <= vmDstLoad.length ; i++){
91 tmp = new XVM(host1, "vm"+(i+vmSrcLoad.length),
93 125, // Net bandwidth,
94 dpRate // Memory intensity
98 tmp.setLoad(vmDstLoad[i-1]);
101 Msg.info("Round trip of VM1 (load "+load1+"%)");
103 doMigration(vm1, host0, host1);
104 doMigration(vm1, host1, host0);
107 Msg.info("Round trip of VM1 (load "+load2+"%)");
109 doMigration(vm1, host0, host1);
110 doMigration(vm1, host1, host0);
113 Msg.info("Forcefully destroy VMs");