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;
12 import org.simgrid.msg.*;
13 import org.simgrid.msg.Process;
15 public class Test extends Process{
17 Test(Host host, String name, String[] args) throws HostNotFoundException, NativeException {
18 super(host, name, args);
21 public void main(String[] strings) throws MsgException {
25 /* get hosts 1 and 2*/
30 host0 = Host.getByName("host0");
31 host1 = Host.getByName("host1");
32 }catch (HostNotFoundException e) {
33 e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
36 List<VM> vms = new ArrayList<VM>();
43 Msg.info("This example evaluates the migration time of a VM in presence of collocated VMs on the source and "
45 Msg.info("The migrated VM has a memory intensity rate of 70% of the network BW and a cpu load of 90% \" "
46 +"(see cloudcom 2013 paper \"Adding a Live Migration Model Into SimGrid\" for further information) ");
48 Msg.info("Load of collocated VMs fluctuate between 0 and 90% in order to create a starvation issue and see "
49 + "whether it impacts or not the migration time");
51 vm1 = new XVM(host0, "vm0",
56 -1, //size of disk image,
57 125, // Net bandwidth,
58 dpRate // Memory intensity
64 int collocatedSrc = 6;
75 for (int i=1 ; i<= collocatedSrc ; i++){
76 tmp = new XVM(host0, "vm"+i,
81 -1, //size of disk image,
82 125, // Net bandwidth,
83 dpRate // Memory intensity
87 tmp.setLoad(vmSrcLoad[i-1]);
90 int collocatedDst = 6;
100 for (int i=1 ; i <= collocatedDst ; i++){
101 tmp = new XVM(host1, "vm"+(i+collocatedSrc),
104 125, // Net Bandwidth
105 null, //VM disk image
106 -1, //size of disk image,
107 125, // Net bandwidth,
108 dpRate // Memory intensity
112 tmp.setLoad(vmDstLoad[i-1]);
115 Msg.info("Round trip of VM1 (load "+load1+"%)");
117 Msg.info(" - Launch migration from host 0 to host 1");
118 startTime = Msg.getClock();
120 endTime = Msg.getClock();
121 Msg.info(" - End of Migration from host 0 to host 1 (duration:"+(endTime-startTime)+")");
122 Msg.info(" - Launch migration from host 1 to host 0");
123 startTime = Msg.getClock();
125 endTime = Msg.getClock();
126 Msg.info(" - End of Migration from host 1 to host 0 (duration:"+(endTime-startTime)+")");
130 Msg.info("Round trip of VM1 (load "+load2+"%)");
132 Msg.info(" - Launch migration from host 0 to host 1");
133 startTime = Msg.getClock();
135 endTime = Msg.getClock();
136 Msg.info(" - End of Migration from host 0 to host 1 (duration:"+(endTime-startTime)+")");
137 Msg.info(" - Launch migration from host 1 to host 0");
138 startTime = Msg.getClock();
140 endTime = Msg.getClock();
141 Msg.info(" - End of Migration from host 1 to host 0 (duration:"+(endTime-startTime)+")");
144 Msg.info("Forcefully destroy VMs");