1 /* Copyright (c) 2014-2017. 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;
8 import org.simgrid.msg.Msg;
9 import org.simgrid.msg.VM;
10 import org.simgrid.msg.Host;
11 import org.simgrid.msg.HostFailureException;
13 public class XVM extends VM {
14 private int dpIntensity;
16 private int currentLoad;
18 private Daemon daemon;
20 public XVM(Host host, String name, int ramsize, int migNetBW, int dpIntensity){
21 super(host, name, ramsize, (int)(migNetBW*0.9), dpIntensity);
23 this.dpIntensity = dpIntensity ;
24 this.ramsize= ramsize;
25 this.daemon = new Daemon(this);
28 public void setLoad(int load){
30 this.setBound(this.getSpeed()*load/100);
45 public Daemon getDaemon(){
50 System.out.println("Remaining comp:" + this.daemon.getRemaining());
51 return this.currentLoad;
55 public void migrate(Host host) throws HostFailureException {
56 Msg.info("Start migration of VM " + this.getName() + " to " + host.getName());
57 Msg.info(" currentLoad:" + this.currentLoad + "/ramSize:" + this.ramsize + "/dpIntensity:" + this.dpIntensity
58 + "/remaining:" + String.format(java.util.Locale.US, "%.2E",this.daemon.getRemaining()));
61 } catch (Exception e){
62 Msg.info("Something wrong during the live migration of VM "+this.getName());
63 throw new HostFailureException();
65 this.setLoad(this.currentLoad); //Fixed the fact that setBound is not propagated to the new node.
66 Msg.info("End of migration of VM " + this.getName() + " to node " + host.getName());