1 /* Copyright (c) 2014, 2016. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 package cloud.migration;
8 import java.util.ArrayList;
11 import org.simgrid.msg.*;
12 import org.simgrid.msg.Process;
14 public class Test extends Process{
16 Test(String hostname, String name) throws HostNotFoundException, NativeException {
17 super(hostname, name);
20 public void doMigration(VM vm, Host src, Host dst) throws HostFailureException{
21 Msg.info(" - Launch migration from "+ src.getName() +" to " + dst.getName());
22 double startTime = Msg.getClock();
24 double endTime = Msg.getClock();
25 Msg.info(" - End of Migration from "+ src.getName() +" to " + dst.getName()+ " (duration:" +
26 (endTime-startTime)+")");
29 public void main(String[] strings) throws MsgException {
33 /* get hosts 1 and 2*/
34 host0 = Host.getByName("PM0");
35 host1 = Host.getByName("PM1");
36 }catch (HostNotFoundException e) {
40 List<VM> vms = new ArrayList<>();
47 Msg.info("This example evaluates the migration time of a VM in presence of collocated VMs on the source and "
49 Msg.info("The migrated VM has a memory intensity rate of 70% of the network BW and a cpu load of 90% \" "
50 +"(see cloudcom 2013 paper \"Adding a Live Migration Model Into SimGrid\" for further information) ");
52 Msg.info("Load of collocated VMs fluctuate between 0 and 90% in order to create a starvation issue and see "
53 + "whether it impacts or not the migration time");
54 XVM vm1 = new XVM(host0, "vm0",
56 125, // Net bandwidth,
57 dpRate // Memory intensity
63 int collocatedSrc = 6;
74 for (int i=1 ; i<= collocatedSrc ; i++){
75 tmp = new XVM(host0, "vm"+i,
77 125, // Net bandwidth,
78 dpRate // Memory intensity
82 tmp.setLoad(vmSrcLoad[i-1]);
85 int collocatedDst = 6;
95 for (int i=1 ; i <= collocatedDst ; i++){
96 tmp = new XVM(host1, "vm"+(i+collocatedSrc),
98 125, // Net bandwidth,
99 dpRate // Memory intensity
103 tmp.setLoad(vmDstLoad[i-1]);
106 Msg.info("Round trip of VM1 (load "+load1+"%)");
108 doMigration(vm1, host0, host1);
109 doMigration(vm1, host1, host0);
112 Msg.info("Round trip of VM1 (load "+load2+"%)");
114 doMigration(vm1, host0, host1);
115 doMigration(vm1, host1, host0);
118 Msg.info("Forcefully destroy VMs");