X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/946b604fdce1a3ca5bfd2f512aa69d78b3259a13..717bb82fd56727b8a066418eaa654290373736ea:/examples/java/cloud/migration/XVM.java diff --git a/examples/java/cloud/migration/XVM.java b/examples/java/cloud/migration/XVM.java index f34da08607..6c24b50d47 100644 --- a/examples/java/cloud/migration/XVM.java +++ b/examples/java/cloud/migration/XVM.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2014. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2014-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -9,31 +8,26 @@ package cloud.migration; import org.simgrid.msg.Msg; import org.simgrid.msg.VM; import org.simgrid.msg.Host; -import org.simgrid.msg.HostNotFoundException; import org.simgrid.msg.HostFailureException; public class XVM extends VM { private int dpIntensity; - private int netBW; private int ramsize; private int currentLoad; private Daemon daemon; - public XVM(Host host, String name, - int nbCores, int ramsize, int netBW, String diskPath, int diskSize, int migNetBW, int dpIntensity){ - super(host, name, nbCores, ramsize, netBW, diskPath, diskSize, (int)(migNetBW*0.9), dpIntensity); + public XVM(Host host, String name, int ramsize, int migNetBW, int dpIntensity){ + super(host, name, ramsize, (int)(migNetBW*0.9), dpIntensity); this.currentLoad = 0; - this.netBW = netBW ; - this. dpIntensity = dpIntensity ; + this.dpIntensity = dpIntensity ; this.ramsize= ramsize; - this.daemon = new Daemon(this, 100); + this.daemon = new Daemon(this); } public void setLoad(int load){ if (load >0) { - this.setBound(load); - // this.getDaemon().setLoad(load); + this.setBound(this.getSpeed()*load/100); daemon.resume(); } else{ daemon.suspend(); @@ -41,13 +35,10 @@ public class XVM extends VM { currentLoad = load ; } - public void start(){ + @Override + public void start() { super.start(); - try { - daemon.start(); - } catch (HostNotFoundException e) { - e.printStackTrace(); - } + daemon.start(); this.setLoad(0); } @@ -55,11 +46,12 @@ public class XVM extends VM { return this.daemon; } - public int getLoad(){ - System.out.println("Remaining comp:" + this.daemon.getRemaining()); + public double getLoad(){ + Msg.info("Remaining comp:" + this.daemon.getRemaining()); return this.currentLoad; } + @Override public void migrate(Host host) throws HostFailureException { Msg.info("Start migration of VM " + this.getName() + " to " + host.getName()); Msg.info(" currentLoad:" + this.currentLoad + "/ramSize:" + this.ramsize + "/dpIntensity:" + this.dpIntensity