From f0ae52bce3948c1d4073a3ba432986722389292b Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 29 Mar 2016 18:58:55 +0200 Subject: [PATCH] get rid of dumb deployment --- examples/java/migration/CMakeLists.txt | 3 +-- examples/java/migration/Emigrant.java | 15 ++++++------ .../migration/{Migration.java => Main.java} | 23 +++++++++++++------ examples/java/migration/Policeman.java | 18 +++++++-------- examples/java/migration/migration.tesh | 16 ++++++------- .../java/migration/migrationDeployment.xml | 6 ----- 6 files changed, 42 insertions(+), 39 deletions(-) rename examples/java/migration/{Migration.java => Main.java} (57%) delete mode 100644 examples/java/migration/migrationDeployment.xml diff --git a/examples/java/migration/CMakeLists.txt b/examples/java/migration/CMakeLists.txt index 486b642854..666b4922c4 100644 --- a/examples/java/migration/CMakeLists.txt +++ b/examples/java/migration/CMakeLists.txt @@ -1,5 +1,5 @@ set(example java_migration) -set(sources ${CMAKE_CURRENT_SOURCE_DIR}/Migration.java ${CMAKE_CURRENT_SOURCE_DIR}/Emigrant.java ${CMAKE_CURRENT_SOURCE_DIR}/Policeman.java) +set(sources ${CMAKE_CURRENT_SOURCE_DIR}/Main.java ${CMAKE_CURRENT_SOURCE_DIR}/Emigrant.java ${CMAKE_CURRENT_SOURCE_DIR}/Policeman.java) if(enable_java) add_custom_command( @@ -15,5 +15,4 @@ if(enable_java) endif() set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/migration.tesh PARENT_SCOPE) -set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/migrationDeployment.xml PARENT_SCOPE) set(examples_src ${examples_src} ${sources} PARENT_SCOPE) diff --git a/examples/java/migration/Emigrant.java b/examples/java/migration/Emigrant.java index 194630675e..66f7e5090b 100644 --- a/examples/java/migration/Emigrant.java +++ b/examples/java/migration/Emigrant.java @@ -10,15 +10,16 @@ import org.simgrid.msg.Host; import org.simgrid.msg.Task; import org.simgrid.msg.Process; import org.simgrid.msg.MsgException; +import org.simgrid.msg.HostNotFoundException; public class Emigrant extends Process { - public Emigrant(Host host, String name, String[]args) { - super(host,name,args); + public Emigrant(String hostname, String name) throws HostNotFoundException { + super(hostname, name); } - public void main(String[] args) throws MsgException { - Migration.mutex.acquire(); - + public void main(String[] args) throws MsgException { + Main.mutex.acquire(); + Msg.info("I'll look for a new job on another machine where the grass is greener."); migrate(Host.getByName("Boivin")); @@ -32,8 +33,8 @@ public class Emigrant extends Process { migrate(Host.getByName("Boivin")); waitFor(4); - Migration.processToMigrate = this; - Migration.mutex.release(); + Main.processToMigrate = this; + Main.mutex.release(); suspend(); Msg.info("I've been moved on this new host:" + getHost().getName()); diff --git a/examples/java/migration/Migration.java b/examples/java/migration/Main.java similarity index 57% rename from examples/java/migration/Migration.java rename to examples/java/migration/Main.java index 37509a07f7..38945df3dd 100644 --- a/examples/java/migration/Migration.java +++ b/examples/java/migration/Main.java @@ -9,24 +9,33 @@ import org.simgrid.msg.Msg; import org.simgrid.msg.Mutex; import org.simgrid.msg.Process; import org.simgrid.msg.NativeException; +import org.simgrid.msg.HostNotFoundException; -public class Migration { +public class Main { public static Mutex mutex; public static Process processToMigrate = null; - public static void main(String[] args) throws NativeException { + public static void main(String[] args) throws NativeException { Msg.init(args); - if(args.length < 2) { - Msg.info("Usage : Migration platform_file deployment_file"); - Msg.info("example : Migration ../platforms/platform.xml migrationDeployment.xml"); + if(args.length < 1) { + Msg.info("Usage : Migration platform_file"); + Msg.info("example : Migration ../platforms/platform.xml"); System.exit(1); } /* Create the mutex */ mutex = new Mutex(); - /* construct the platform and deploy the application */ + /* construct the platform*/ Msg.createEnvironment(args[0]); - Msg.deployApplication(args[1]); + /* bypass deploymemt */ + try { + Policeman policeman = new Policeman("Boivin","policeman"); + policeman.start(); + Emigrant emigrant = new Emigrant("Jacquelin","emigrant"); + emigrant.start(); + } catch (HostNotFoundException e){ + System.out.println("Create processes failed!"); + } /* execute the simulation. */ Msg.run(); diff --git a/examples/java/migration/Policeman.java b/examples/java/migration/Policeman.java index 3d4cfb4650..3bdde64938 100644 --- a/examples/java/migration/Policeman.java +++ b/examples/java/migration/Policeman.java @@ -10,22 +10,22 @@ import org.simgrid.msg.Msg; import org.simgrid.msg.Host; import org.simgrid.msg.Process; import org.simgrid.msg.MsgException; +import org.simgrid.msg.HostNotFoundException; public class Policeman extends Process { - public Policeman(Host host, String name, String[]args) { - super(host,name,args); + public Policeman(String hostname, String name) throws HostNotFoundException { + super(hostname, name); } - @Override public void main(String[] args) throws MsgException { waitFor(1); - + Msg.info("Wait a bit before migrating the emigrant."); - - Migration.mutex.acquire(); - - Migration.processToMigrate.migrate(Host.getByName("Jacquelin")); + + Main.mutex.acquire(); + + Main.processToMigrate.migrate(Host.getByName("Jacquelin")); Msg.info("I moved the emigrant"); - Migration.processToMigrate.resume(); + Main.processToMigrate.resume(); } } \ No newline at end of file diff --git a/examples/java/migration/migration.tesh b/examples/java/migration/migration.tesh index 8c35b9d348..604a1d0a52 100644 --- a/examples/java/migration/migration.tesh +++ b/examples/java/migration/migration.tesh @@ -2,13 +2,13 @@ ! output sort 19 -$ java -classpath ${classpath:=.} migration/Migration ${srcdir:=.}/../platforms/platform.xml ${srcdir:=.}/migration/migrationDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ java -classpath ${classpath:=.} migration/Main ${srcdir:=.}/../platforms/platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (0:maestro@) Using regular java threads. -> [ 0.000000] (1:migration.Emigrant@Jacquelin) I'll look for a new job on another machine where the grass is greener. -> [ 0.000000] (1:migration.Emigrant@Boivin) Yeah, found something to do -> [ 1.000000] (2:migration.Policeman@Boivin) Wait a bit before migrating the emigrant. -> [ 3.000000] (1:migration.Emigrant@Boivin) Moving back to home after work +> [ 0.000000] (2:emigrant@Jacquelin) I'll look for a new job on another machine where the grass is greener. +> [ 0.000000] (2:emigrant@Boivin) Yeah, found something to do +> [ 1.000000] (1:policeman@Boivin) Wait a bit before migrating the emigrant. +> [ 3.000000] (2:emigrant@Boivin) Moving back to home after work > [ 7.000000] (0:maestro@) MSG_main finished; Cleaning up the simulation... -> [ 7.000000] (1:migration.Emigrant@Jacquelin) I've been moved on this new host:Jacquelin -> [ 7.000000] (1:migration.Emigrant@Jacquelin) Uh, nothing to do here. Stopping now -> [ 7.000000] (2:migration.Policeman@Boivin) I moved the emigrant +> [ 7.000000] (2:emigrant@Jacquelin) I've been moved on this new host:Jacquelin +> [ 7.000000] (2:emigrant@Jacquelin) Uh, nothing to do here. Stopping now +> [ 7.000000] (1:policeman@Boivin) I moved the emigrant diff --git a/examples/java/migration/migrationDeployment.xml b/examples/java/migration/migrationDeployment.xml deleted file mode 100644 index 78aba8ce3b..0000000000 --- a/examples/java/migration/migrationDeployment.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - -- 2.20.1