1 /* Copyright (c) 2014. 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;
9 import org.simgrid.msg.*;
10 import org.simgrid.msg.Process;
11 import java.util.ArrayList;
12 import java.util.List;
14 public class Test extends Process{
16 Test(Host host, String name, String[] args) throws HostNotFoundException, NativeException {
17 super(host, name, args);
20 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>();
44 Msg.info("This example evaluates the migration time of a VM in presence of collocated VMs on the source and the dest nodes");
45 Msg.info("The migrated VM has a memory intensity rate of 70% of the network BW and a cpu load of 90% \"(see cloudcom 2013 paper \"Adding a Live Migration Model Into SimGrid\" for further information) ");
47 Msg.info("Load of collocated VMs fluctuate between 0 and 90% in order to create a starvation issue and see whether it impacts or not the migration time");
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++){
83 -1, //size of disk image,
84 125, // Net bandwidth,
85 dpRate // Memory intensity
89 tmp.setLoad(vmSrcLoad[i-1]);
92 int collocatedDst = 6;
102 for (int i=1 ; i <= collocatedDst ; i++){
105 "vm"+(i+collocatedSrc),
108 125, // Net Bandwidth
109 null, //VM disk image
110 -1, //size of disk image,
111 125, // Net bandwidth,
112 dpRate // Memory intensity
116 tmp.setLoad(vmDstLoad[i-1]);
119 Msg.info("Round trip of VM1 (load "+load1+"%)");
121 Msg.info(" - Launch migration from host 0 to host 1");
122 startTime = Msg.getClock();
124 endTime = Msg.getClock();
125 Msg.info(" - End of Migration from host 0 to host 1 (duration:"+(endTime-startTime)+")");
126 Msg.info(" - Launch migration from host 1 to host 0");
127 startTime = Msg.getClock();
129 endTime = Msg.getClock();
130 Msg.info(" - End of Migration from host 1 to host 0 (duration:"+(endTime-startTime)+")");
133 Msg.info("\n \n \nRound trip of VM1 (load "+load2+"%)");
135 Msg.info(" - Launch migration from host 0 to host 1");
136 startTime = Msg.getClock();
138 endTime = Msg.getClock();
139 Msg.info(" - End of Migration from host 0 to host 1 (duration:"+(endTime-startTime)+")");
140 Msg.info(" - Launch migration from host 1 to host 0");
141 startTime = Msg.getClock();
143 endTime = Msg.getClock();
144 Msg.info(" - End of Migration from host 1 to host 0 (duration:"+(endTime-startTime)+")");
147 // no need to destroy the VMs: the garbage collector will get them all