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,
23 int nbCores, int ramsize, int netBW, String diskPath, int diskSize, int migNetBW, int dpIntensity){
24 super(host, name, nbCores, ramsize, netBW, diskPath, diskSize, (int)(migNetBW*0.9), dpIntensity);
26 this. dpIntensity = dpIntensity ;
27 this.ramsize= ramsize;
28 this.daemon = new Daemon(this, 100);
31 public void setLoad(int load){
33 this.setBound(this.getSpeed()*load/100);
34 // this.getDaemon().setLoad(load);
46 } catch (HostNotFoundException e) {
52 public Daemon getDaemon(){
57 System.out.println("Remaining comp:" + this.daemon.getRemaining());
58 return this.currentLoad;
61 public void migrate(Host host) throws HostFailureException {
62 Msg.info("Start migration of VM " + this.getName() + " to " + host.getName());
63 Msg.info(" currentLoad:" + this.currentLoad + "/ramSize:" + this.ramsize + "/dpIntensity:" + this.dpIntensity
64 + "/remaining:" + String.format(java.util.Locale.US, "%.2E",this.daemon.getRemaining()));
67 } catch (Exception e){
68 Msg.info("Something wrong during the live migration of VM "+this.getName());
69 throw new HostFailureException();
71 this.setLoad(this.currentLoad); //Fixed the fact that setBound is not propagated to the new node.
72 Msg.info("End of migration of VM " + this.getName() + " to node " + host.getName());