Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get rid of dumb deployment
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 29 Mar 2016 16:58:55 +0000 (18:58 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 29 Mar 2016 16:58:55 +0000 (18:58 +0200)
examples/java/migration/CMakeLists.txt
examples/java/migration/Emigrant.java
examples/java/migration/Main.java [moved from examples/java/migration/Migration.java with 57% similarity]
examples/java/migration/Policeman.java
examples/java/migration/migration.tesh
examples/java/migration/migrationDeployment.xml [deleted file]

index 486b642..666b492 100644 (file)
@@ -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)
index 1946306..66f7e50 100644 (file)
@@ -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());
similarity index 57%
rename from examples/java/migration/Migration.java
rename to examples/java/migration/Main.java
index 37509a0..38945df 100644 (file)
@@ -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();
index 3d4cfb4..3bdde64 100644 (file)
@@ -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
index 8c35b9d..604a1d0 100644 (file)
@@ -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 (file)
index 78aba8c..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
-  <process host="Jacquelin" function="migration.Emigrant"/>
-  <process host="Boivin" function="migration.Policeman"/>
-</platform>