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