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.HostNotFoundException;
12 import org.simgrid.msg.HostFailureException;
14 public class XVM extends VM {
15 private int dpIntensity;
17 private int currentLoad;
19 private Daemon daemon;
21 public XVM(Host host, String name, int ramsize, int migNetBW, int dpIntensity){
22 super(host, name, ramsize, (int)(migNetBW*0.9), dpIntensity);
24 this.dpIntensity = dpIntensity ;
25 this.ramsize= ramsize;
26 this.daemon = new Daemon(this);
29 public void setLoad(int load){
31 this.setBound(this.getSpeed()*load/100);
32 // this.getDaemon().setLoad(load);
47 public Daemon getDaemon(){
52 System.out.println("Remaining comp:" + this.daemon.getRemaining());
53 return this.currentLoad;
57 public void migrate(Host host) throws HostFailureException {
58 Msg.info("Start migration of VM " + this.getName() + " to " + host.getName());
59 Msg.info(" currentLoad:" + this.currentLoad + "/ramSize:" + this.ramsize + "/dpIntensity:" + this.dpIntensity
60 + "/remaining:" + String.format(java.util.Locale.US, "%.2E",this.daemon.getRemaining()));
63 } catch (Exception e){
64 Msg.info("Something wrong during the live migration of VM "+this.getName());
65 throw new HostFailureException();
67 this.setLoad(this.currentLoad); //Fixed the fact that setBound is not propagated to the new node.
68 Msg.info("End of migration of VM " + this.getName() + " to node " + host.getName());