X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e54471e47acaaa087f58c62c3ec142e911e30d40..b8df87e176f27b25534f27d7e240defa32ca35bc:/examples/java/cloud/migration/TestHostOnOff.java diff --git a/examples/java/cloud/migration/TestHostOnOff.java b/examples/java/cloud/migration/TestHostOnOff.java index 5fccb0bd75..8161ef2f07 100644 --- a/examples/java/cloud/migration/TestHostOnOff.java +++ b/examples/java/cloud/migration/TestHostOnOff.java @@ -1,4 +1,4 @@ -/* Copyright (c) 2014. The SimGrid Team. +/* Copyright (c) 2014-2019. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -6,10 +6,13 @@ package cloud.migration; -import java.util.Random; - -import org.simgrid.msg.*; +import org.simgrid.msg.Host; +import org.simgrid.msg.HostFailureException; +import org.simgrid.msg.HostNotFoundException; +import org.simgrid.msg.Msg; +import org.simgrid.msg.MsgException; import org.simgrid.msg.Process; +import org.simgrid.msg.VM; // This test aims at validating that the migration process is robust in face of host turning off either on the SRC // node or on the DST node. @@ -19,7 +22,7 @@ public class TestHostOnOff extends Process{ protected Host host1 = null; protected Host host2 = null; - TestHostOnOff(String hostname, String name) throws HostNotFoundException, NativeException { + TestHostOnOff(String hostname, String name) throws HostNotFoundException { super(hostname, name); } @@ -30,7 +33,7 @@ public class TestHostOnOff extends Process{ host1 = Host.getByName("PM1"); host2 = Host.getByName("PM2"); }catch (HostNotFoundException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + Msg.error("You are trying to use a non existing node:" + e.getMessage()); } // Robustness on the SRC node @@ -60,11 +63,7 @@ public class TestHostOnOff extends Process{ int dpRate = 70; XVM vm0 = null; vm0 = new XVM(host1, "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 ); @@ -84,19 +83,17 @@ public class TestHostOnOff extends Process{ try { sourceHost = Host.getByName(args[1]); destHost = Host.getByName(args[2]); - } catch (Exception e) { + } catch (HostNotFoundException e) { + Msg.error("You are trying to migrate from/to a non existing node: " + e.getMessage()); e.printStackTrace(); - System.err.println("You are trying to migrate from/to a non existing node"); } - if (destHost != null) { - if (sourceHost.isOn() && destHost.isOn()) { - try { - Msg.info("Migrate vm "+args[0]+" to node "+destHost.getName()); - VM.getVMByName(args[0]).migrate(destHost); - } catch (HostFailureException e) { - Msg.info("Something occurs during the migration that cannot validate the operation"); - e.printStackTrace(); - } + if (destHost != null && sourceHost.isOn() && destHost.isOn()) { + try { + Msg.info("Migrate vm "+args[0]+" to node "+destHost.getName()); + VM.getVMByName(args[0]).migrate(destHost); + } catch (HostFailureException e) { + Msg.error("Something occurs during the migration that cannot validate the operation: " + e.getMessage()); + e.printStackTrace(); } } } @@ -121,11 +118,7 @@ public class TestHostOnOff extends Process{ // Create VM0 int dpRate = 70; XVM vm0 = new XVM(host1, "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 ); @@ -141,11 +134,7 @@ public class TestHostOnOff extends Process{ Msg.info("Restart VM0"); vm0 = new XVM(host1, "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 );