From 17ab9dc49cf3c80993e131be3232837142516f47 Mon Sep 17 00:00:00 2001 From: alebre Date: Wed, 29 Jan 2014 16:35:46 +0100 Subject: [PATCH] add migration-test adrien --- .../java/cloud/migration-test/.idea/.name | 1 + .../cloud/migration-test/.idea/compiler.xml | 23 + .../.idea/copyright/profiles_settings.xml | 5 + .../cloud/migration-test/.idea/encodings.xml | 5 + .../.idea/libraries/simgrid.xml | 9 + .../java/cloud/migration-test/.idea/misc.xml | 14 + .../cloud/migration-test/.idea/modules.xml | 9 + .../.idea/scopes/scope_settings.xml | 5 + .../cloud/migration-test/.idea/uiDesigner.xml | 125 +++ .../java/cloud/migration-test/.idea/vcs.xml | 7 + .../cloud/migration-test/.idea/workspace.xml | 748 ++++++++++++++++++ .../CONFIG/cluster_platform.xml | 9 + .../migration-test/CONFIG/deploy_simple.xml | 6 + .../migration-test/CONFIG/platform_simple.xml | 10 + .../java/cloud/migration-test/src/Daemon.java | 30 + .../java/cloud/migration-test/src/Main.java | 29 + .../java/cloud/migration-test/src/Test.java | 134 ++++ .../java/cloud/migration-test/src/XVM.java | 67 ++ 18 files changed, 1236 insertions(+) create mode 100644 examples/java/cloud/migration-test/.idea/.name create mode 100644 examples/java/cloud/migration-test/.idea/compiler.xml create mode 100644 examples/java/cloud/migration-test/.idea/copyright/profiles_settings.xml create mode 100644 examples/java/cloud/migration-test/.idea/encodings.xml create mode 100644 examples/java/cloud/migration-test/.idea/libraries/simgrid.xml create mode 100644 examples/java/cloud/migration-test/.idea/misc.xml create mode 100644 examples/java/cloud/migration-test/.idea/modules.xml create mode 100644 examples/java/cloud/migration-test/.idea/scopes/scope_settings.xml create mode 100644 examples/java/cloud/migration-test/.idea/uiDesigner.xml create mode 100644 examples/java/cloud/migration-test/.idea/vcs.xml create mode 100644 examples/java/cloud/migration-test/.idea/workspace.xml create mode 100644 examples/java/cloud/migration-test/CONFIG/cluster_platform.xml create mode 100644 examples/java/cloud/migration-test/CONFIG/deploy_simple.xml create mode 100644 examples/java/cloud/migration-test/CONFIG/platform_simple.xml create mode 100644 examples/java/cloud/migration-test/src/Daemon.java create mode 100644 examples/java/cloud/migration-test/src/Main.java create mode 100644 examples/java/cloud/migration-test/src/Test.java create mode 100644 examples/java/cloud/migration-test/src/XVM.java diff --git a/examples/java/cloud/migration-test/.idea/.name b/examples/java/cloud/migration-test/.idea/.name new file mode 100644 index 0000000000..b8167805ce --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/.name @@ -0,0 +1 @@ +MIGRATION-SG-UNIT-TESTS \ No newline at end of file diff --git a/examples/java/cloud/migration-test/.idea/compiler.xml b/examples/java/cloud/migration-test/.idea/compiler.xml new file mode 100644 index 0000000000..217af471a9 --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/examples/java/cloud/migration-test/.idea/copyright/profiles_settings.xml b/examples/java/cloud/migration-test/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000000..3572571ad8 --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/copyright/profiles_settings.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/examples/java/cloud/migration-test/.idea/encodings.xml b/examples/java/cloud/migration-test/.idea/encodings.xml new file mode 100644 index 0000000000..e206d70d85 --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/java/cloud/migration-test/.idea/libraries/simgrid.xml b/examples/java/cloud/migration-test/.idea/libraries/simgrid.xml new file mode 100644 index 0000000000..928de67688 --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/libraries/simgrid.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/examples/java/cloud/migration-test/.idea/misc.xml b/examples/java/cloud/migration-test/.idea/misc.xml new file mode 100644 index 0000000000..c431c66a5a --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/examples/java/cloud/migration-test/.idea/modules.xml b/examples/java/cloud/migration-test/.idea/modules.xml new file mode 100644 index 0000000000..a47c2034d9 --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/examples/java/cloud/migration-test/.idea/scopes/scope_settings.xml b/examples/java/cloud/migration-test/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000000..922003b843 --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/examples/java/cloud/migration-test/.idea/uiDesigner.xml b/examples/java/cloud/migration-test/.idea/uiDesigner.xml new file mode 100644 index 0000000000..3b00020308 --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/uiDesigner.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/java/cloud/migration-test/.idea/vcs.xml b/examples/java/cloud/migration-test/.idea/vcs.xml new file mode 100644 index 0000000000..ebabb34f16 --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/examples/java/cloud/migration-test/.idea/workspace.xml b/examples/java/cloud/migration-test/.idea/workspace.xml new file mode 100644 index 0000000000..37a45e3847 --- /dev/null +++ b/examples/java/cloud/migration-test/.idea/workspace.xml @@ -0,0 +1,748 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + + + 1384769876563 + 1384769876563 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + 1.7 + + + + + + + + MIGRATION-SG-UNIT-TESTS + + + + + + + + 1.7 + + + + + + + + simgrid + + + + + + + + + diff --git a/examples/java/cloud/migration-test/CONFIG/cluster_platform.xml b/examples/java/cloud/migration-test/CONFIG/cluster_platform.xml new file mode 100644 index 0000000000..e0811a018d --- /dev/null +++ b/examples/java/cloud/migration-test/CONFIG/cluster_platform.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/examples/java/cloud/migration-test/CONFIG/deploy_simple.xml b/examples/java/cloud/migration-test/CONFIG/deploy_simple.xml new file mode 100644 index 0000000000..405b195216 --- /dev/null +++ b/examples/java/cloud/migration-test/CONFIG/deploy_simple.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/java/cloud/migration-test/CONFIG/platform_simple.xml b/examples/java/cloud/migration-test/CONFIG/platform_simple.xml new file mode 100644 index 0000000000..7ccd7363f9 --- /dev/null +++ b/examples/java/cloud/migration-test/CONFIG/platform_simple.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/examples/java/cloud/migration-test/src/Daemon.java b/examples/java/cloud/migration-test/src/Daemon.java new file mode 100644 index 0000000000..91141c8412 --- /dev/null +++ b/examples/java/cloud/migration-test/src/Daemon.java @@ -0,0 +1,30 @@ +import org.simgrid.msg.*; +import org.simgrid.msg.Process; + +public class Daemon extends Process { + private Task currentTask; + public Daemon(VM vm, int load) { + super((Host)vm,"Daemon"); + currentTask = new Task(this.getHost().getName()+"-daemon-0", this.getHost().getSpeed()*100, 0); + } + public void main(String[] args) throws MsgException { + int i = 1; + while(!Main.isEndOfTest()) { + // TODO the binding is not yet available + try { + currentTask.execute(); + } catch (HostFailureException e) { + e.printStackTrace(); + } catch (TaskCancelledException e) { + System.out.println("task cancelled"); + suspend(); // Suspend the process + } + currentTask = new Task(this.getHost().getName()+"-daemon-"+(i++), this.getHost().getSpeed()*100, 0); + Msg.info(currentTask.getName()); + } + } + + public double getRemaining(){ + return this.currentTask.getRemainingDuration(); + } + } diff --git a/examples/java/cloud/migration-test/src/Main.java b/examples/java/cloud/migration-test/src/Main.java new file mode 100644 index 0000000000..d088468598 --- /dev/null +++ b/examples/java/cloud/migration-test/src/Main.java @@ -0,0 +1,29 @@ +import org.simgrid.msg.Host; +import org.simgrid.msg.HostNotFoundException; +import org.simgrid.msg.Msg; +import org.simgrid.msg.NativeException; + +public class Main { + private static boolean endOfTest = false; + + public static void setEndOfTest(){ + endOfTest=true; + } + + public static boolean isEndOfTest(){ + return endOfTest; + } + + public static void main(String[] args) throws NativeException { + /* Init. internal values */ + Msg.init(args); + + /* construct the platform and deploy the application */ + Msg.createEnvironment("./CONFIG/platform_simple.xml"); + Msg.deployApplication("./CONFIG/deploy_simple.xml"); + + Msg.run(); + + + } +} diff --git a/examples/java/cloud/migration-test/src/Test.java b/examples/java/cloud/migration-test/src/Test.java new file mode 100644 index 0000000000..d1e28b8782 --- /dev/null +++ b/examples/java/cloud/migration-test/src/Test.java @@ -0,0 +1,134 @@ +import org.simgrid.msg.*; +import org.simgrid.msg.Process; + +public class Test extends Process{ + + Test(Host host, String name, String[] args) throws HostNotFoundException, NativeException { + super(host, name, args); + } + + public void main(String[] strings) throws MsgException { + + double startTime = 0; + double endTime = 0; + + /* get hosts 1 and 2*/ + Host host0 = null; + Host host1 = null; + + try { + host0 = Host.getByName("host0"); + host1 = Host.getByName("host1"); + }catch (HostNotFoundException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + + /* Create VM1 */ + int dpRate = 70; + int load1 = 90; + int load2 = 80; + + XVM vm1 = null; + vm1 = new XVM( + host0, + "vm0", + 1, // Nb of vcpu + 2048, // Ramsize, + 125, // Net Bandwidth + null, //VM disk image + -1, //size of disk image, + 125, // Net bandwidth, + dpRate // Memory intensity + ); + + + vm1.start(); + + /* Collocated VMs */ + int collocatedSrc = 6; + int vmSrcLoad[] = { + 80, + 0, + 90, + 40, + 30, + 90, + }; + + XVM tmp = null; + for (int i=1 ; i<= collocatedSrc ; i++){ + tmp = new XVM( + host0, + "vm"+i, + 1, // Nb of vcpu + 2048, // Ramsize, + 125, // Net Bandwidth + null, //VM disk image + -1, //size of disk image, + 125, // Net bandwidth, + dpRate // Memory intensity + ); + tmp.start(); + tmp.setLoad(vmSrcLoad[i-1]); + } + + int collocatedDst = 6; + int vmDstLoad[] = { + 0, + 40, + 90, + 100, + 0, + 80, + }; + + for (int i=1 ; i <= collocatedDst ; i++){ + tmp = new XVM( + host1, + "vm"+i+collocatedSrc, + 1, // Nb of vcpu + 2048, // Ramsize, + 125, // Net Bandwidth + null, //VM disk image + -1, //size of disk image, + 125, // Net bandwidth, + dpRate // Memory intensity + ); + tmp.start(); + tmp.setLoad(vmDstLoad[i-1]); + } + + + + + + Msg.info("Round trip of VM1 (load "+load1+"%)"); + vm1.setLoad(load1); + Msg.info(" - Launch migration from host 0 to host 1"); + startTime = Msg.getClock(); + vm1.migrate(host1); + endTime = Msg.getClock(); + Msg.info(" - End of Migration from host 0 to host 1 (duration:"+(endTime-startTime)+")"); + Msg.info(" - Launch migration from host 1 to host 0"); + startTime = Msg.getClock(); + vm1.migrate(host0); + endTime = Msg.getClock(); + Msg.info(" - End of Migration from host 1 to host 0 (duration:"+(endTime-startTime)+")"); + + Msg.info("\n \n \nRound trip of VM1 (load "+load2+"%)"); + vm1.setLoad(load2); + Msg.info(" - Launch migration from host 0 to host 1"); + startTime = Msg.getClock(); + vm1.migrate(host1); + endTime = Msg.getClock(); + Msg.info(" - End of Migration from host 0 to host 1 (duration:"+(endTime-startTime)+")"); + Msg.info(" - Launch migration from host 1 to host 0"); + startTime = Msg.getClock(); + vm1.migrate(host0); + endTime = Msg.getClock(); + Msg.info(" - End of Migration from host 1 to host 0 (duration:"+(endTime-startTime)+")"); + + waitFor(100000); + Main.setEndOfTest(); + } +} diff --git a/examples/java/cloud/migration-test/src/XVM.java b/examples/java/cloud/migration-test/src/XVM.java new file mode 100644 index 0000000000..5cc70f5e7e --- /dev/null +++ b/examples/java/cloud/migration-test/src/XVM.java @@ -0,0 +1,67 @@ +import org.simgrid.msg.Host; +import org.simgrid.msg.HostNotFoundException; +import org.simgrid.msg.Msg; +import org.simgrid.msg.VM; + +/** + * A stupid VM extension to associate a daemon to the VM + */ +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); + this.currentLoad = 0; + this.netBW = netBW ; + this. dpIntensity = dpIntensity ; + this.ramsize= ramsize; + this.daemon = new Daemon(this, 100); + + } + + public void setLoad(int load){ + if (load >0) { + this.setBound(load); + // this.getDaemon().setLoad(load); + daemon.resume(); + } + else{ + daemon.suspend(); + } + currentLoad = load ; + } + + public void start(){ + super.start(); + try { + daemon.start(); + } catch (HostNotFoundException e) { + e.printStackTrace(); + } + this.setLoad(0); + + } + public Daemon getDaemon(){ + return this.daemon; + } + public int getLoad(){ + System.out.println("Remaining comp:" + this.daemon.getRemaining()); + return this.currentLoad; + } + + public void migrate(Host host){ + Msg.info("Start migration of VM " + this.getName() + " to " + host.getName()); + Msg.info(" currentLoad:" + this.currentLoad + "/ramSize:" + this.ramsize + "/dpIntensity:" + this.dpIntensity + "/remaining:" + this.daemon.getRemaining()); + super.migrate(host); + this.setLoad(this.currentLoad); //Fixed the fact that setBound is not propagated to the new node. + Msg.info("End of migration of VM " + this.getName() + " to node " + host.getName()); + } +} -- 2.20.1