Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
define a process package in examples/java
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 29 Mar 2016 19:25:08 +0000 (21:25 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 29 Mar 2016 19:25:08 +0000 (21:25 +0200)
  + comprises kill, migration, and suspend
Also found a way to factor java cmake \o/\o/\o/

18 files changed:
.gitignore
examples/java/CMakeLists.txt [new file with mode: 0644]
examples/java/kill/CMakeLists.txt [deleted file]
examples/java/migration/CMakeLists.txt [deleted file]
examples/java/process/kill/Killer.java [moved from examples/java/kill/Killer.java with 95% similarity]
examples/java/process/kill/Main.java [moved from examples/java/kill/Main.java with 97% similarity]
examples/java/process/kill/Victim.java [moved from examples/java/kill/Victim.java with 97% similarity]
examples/java/process/kill/process_kill.tesh [moved from examples/java/kill/kill.tesh with 84% similarity]
examples/java/process/migration/Emigrant.java [moved from examples/java/migration/Emigrant.java with 97% similarity]
examples/java/process/migration/Main.java [moved from examples/java/migration/Main.java with 98% similarity]
examples/java/process/migration/Policeman.java [moved from examples/java/migration/Policeman.java with 97% similarity]
examples/java/process/migration/process_migration.tesh [moved from examples/java/migration/migration.tesh with 83% similarity]
examples/java/process/suspend/DreamMaster.java [moved from examples/java/suspend/DreamMaster.java with 94% similarity]
examples/java/process/suspend/LazyGuy.java [moved from examples/java/suspend/LazyGuy.java with 96% similarity]
examples/java/process/suspend/Main.java [moved from examples/java/suspend/Suspend.java with 95% similarity]
examples/java/process/suspend/process_suspend.tesh [moved from examples/java/suspend/suspend.tesh with 82% similarity]
examples/java/suspend/CMakeLists.txt [deleted file]
tools/cmake/DefinePackages.cmake

index 146f5df..9e829bd 100644 (file)
@@ -980,14 +980,14 @@ examples/java/commTime/java_commTime_compiled
 examples/java/energy/java_energy_compiled
 examples/java/io/java_io_compiled
 examples/java/kademlia/java_kademlia_compiled
 examples/java/energy/java_energy_compiled
 examples/java/io/java_io_compiled
 examples/java/kademlia/java_kademlia_compiled
-examples/java/kill/java_kill_compiled
+examples/java/process/kill/java_process_kill_compiled
+examples/java/process/migration/java_process_migration_compiled
+examples/java/process_suspend/java_process_suspend_compiled
 examples/java/masterworker/java_masterworker_compiled
 examples/java/masterworker/java_masterworker_compiled
-examples/java/migration/java_migration_compiled
 examples/java/mutualExclusion/java_mutualExclusion_compiled
 examples/java/pingPong/java_pingPong_compiled
 examples/java/priority/java_priority_compiled
 examples/java/startKillTime/java_startKillTime_compiled
 examples/java/mutualExclusion/java_mutualExclusion_compiled
 examples/java/pingPong/java_pingPong_compiled
 examples/java/priority/java_priority_compiled
 examples/java/startKillTime/java_startKillTime_compiled
-examples/java/suspend/java_suspend_compiled
 examples/java/tracing/java_tracing_compiled
 examples/java/reservationSurfPlugin/java_reservation_surf_plugin_compiled
 examples/java/surfCpuModel/java_surf_cpu_model_compiled
 examples/java/tracing/java_tracing_compiled
 examples/java/reservationSurfPlugin/java_reservation_surf_plugin_compiled
 examples/java/surfCpuModel/java_surf_cpu_model_compiled
diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f179234
--- /dev/null
@@ -0,0 +1,38 @@
+set(process_kill_sources      ${CMAKE_CURRENT_SOURCE_DIR}/process/kill/Main.java
+                              ${CMAKE_CURRENT_SOURCE_DIR}/process/kill/Killer.java
+                              ${CMAKE_CURRENT_SOURCE_DIR}/process/kill/Victim.java)
+set(process_migration_sources ${CMAKE_CURRENT_SOURCE_DIR}/process/migration/Main.java
+                              ${CMAKE_CURRENT_SOURCE_DIR}/process/migration/Emigrant.java
+                              ${CMAKE_CURRENT_SOURCE_DIR}/process/migration/Policeman.java)
+set(process_suspend_sources   ${CMAKE_CURRENT_SOURCE_DIR}/process/suspend/Main.java
+                              ${CMAKE_CURRENT_SOURCE_DIR}/process/suspend/DreamMaster.java
+                              ${CMAKE_CURRENT_SOURCE_DIR}/process/suspend/LazyGuy.java)
+
+foreach (example process_kill process_migration process_suspend)
+  if(enable_java)
+    string (REPLACE "_" "/" example_dir ${example})
+
+    add_custom_command(
+      COMMENT "Building java_${example}..."
+      OUTPUT ${example_dir}/java_${example}_compiled
+      DEPENDS ${example_sources} simgrid-java_jar ${SIMGRID_JAR}
+      COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR} -d ${CMAKE_CURRENT_SOURCE_DIR} ${${example}_sources}
+      COMMAND ${CMAKE_COMMAND} -E remove ${example_dir}/java_${example}_compiled
+      COMMAND ${CMAKE_COMMAND} -E touch ${example_dir}/java_${example}_compiled
+    )
+    add_custom_target(${example} ALL DEPENDS ${example_dir}/java_${example}_compiled)
+  endif()
+  set(examples_src  ${examples_src}  ${${example}_sources})
+  set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example_dir}/${example}.tesh)
+endforeach()
+
+set(examples_src  ${examples_src}  PARENT_SCOPE)
+set(tesh_files    ${tesh_files}    PARENT_SCOPE)
+
+if(enable_java)
+  foreach (example process_kill process_migration process_suspend)
+    string (REPLACE "_" "/" example_dir ${example})
+    ADD_TESH(java-${example}  --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/${example_dir}/${example}.tesh)
+  endforeach()
+endif()
+
diff --git a/examples/java/kill/CMakeLists.txt b/examples/java/kill/CMakeLists.txt
deleted file mode 100644 (file)
index 4a7eaf1..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-set(example java_kill)
-set(sources ${CMAKE_CURRENT_SOURCE_DIR}/Main.java ${CMAKE_CURRENT_SOURCE_DIR}/Killer.java ${CMAKE_CURRENT_SOURCE_DIR}/Victim.java)
-
-if(enable_java)
-  add_custom_command(
-    COMMENT "Building ${example}..."
-    OUTPUT ${example}_compiled
-    DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
-    COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR} -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources}
-    COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled
-    COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled
-  )
-  add_custom_target(${example} ALL DEPENDS ${example}_compiled)
-  ADD_TESH(java-kill --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/kill/kill.tesh)
-endif()
-
-set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/kill.tesh  PARENT_SCOPE)
-set(examples_src  ${examples_src}  ${sources}                             PARENT_SCOPE)
diff --git a/examples/java/migration/CMakeLists.txt b/examples/java/migration/CMakeLists.txt
deleted file mode 100644 (file)
index 666b492..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-set(example java_migration)
-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(
-    COMMENT "Building ${example}..."
-    OUTPUT ${example}_compiled
-    DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
-    COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR} -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources}
-    COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled
-    COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled
-  )
-  add_custom_target(${example} ALL DEPENDS ${example}_compiled)
-  ADD_TESH(java-migration --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/migration/migration.tesh)
-endif()
-
-set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/migration.tesh           PARENT_SCOPE)
-set(examples_src  ${examples_src}  ${sources}                                           PARENT_SCOPE)
similarity index 95%
rename from examples/java/kill/Killer.java
rename to examples/java/process/kill/Killer.java
index 08bd9b6..b465908 100644 (file)
@@ -6,13 +6,13 @@
 /* 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. */
 
 /* 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. */
 
-package kill;
+package process.kill;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.MsgException;
 import org.simgrid.msg.HostNotFoundException;
 
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.MsgException;
 import org.simgrid.msg.HostNotFoundException;
 
-import kill.Victim;
+import process.kill.Victim;
 
 public class Killer extends Process {
   public Killer(String hostname, String name) throws HostNotFoundException {
 
 public class Killer extends Process {
   public Killer(String hostname, String name) throws HostNotFoundException {
similarity index 97%
rename from examples/java/kill/Main.java
rename to examples/java/process/kill/Main.java
index baacd19..8a1065a 100644 (file)
@@ -4,7 +4,7 @@
 /* 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. */
 
 /* 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. */
 
-package kill;
+package process.kill;
 
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
 
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
similarity index 97%
rename from examples/java/kill/Victim.java
rename to examples/java/process/kill/Victim.java
index dfa61c0..14fb38e 100644 (file)
@@ -4,7 +4,7 @@
 /* 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. */
 
 /* 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. */
 
-package kill;
+package process.kill;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.Process;
similarity index 84%
rename from examples/java/kill/kill.tesh
rename to examples/java/process/kill/process_kill.tesh
index defce7f..b0dae50 100644 (file)
@@ -2,7 +2,7 @@
 
 ! output sort 19
 
 
 ! output sort 19
 
-$ java -classpath ${classpath:=.} kill/Main ${srcdir:=.}/../platforms/platform.xml --lof=no_loc
+$ java -classpath ${classpath:=.} process/kill/Main ${srcdir:=.}/../platforms/platform.xml --lof=no_loc
 > [0.000000] [jmsg/INFO] Using regular java threads.
 > [11.000000] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
 > [Boivin:victim:(2) 0.000000] [jmsg/INFO] Hello!
 > [0.000000] [jmsg/INFO] Using regular java threads.
 > [11.000000] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
 > [Boivin:victim:(2) 0.000000] [jmsg/INFO] Hello!
similarity index 97%
rename from examples/java/migration/Emigrant.java
rename to examples/java/process/migration/Emigrant.java
index 66f7e50..9cf5a5c 100644 (file)
@@ -4,7 +4,7 @@
 /* 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. */
 
 /* 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. */
 
-package migration;
+package process.migration;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Task;
similarity index 98%
rename from examples/java/migration/Main.java
rename to examples/java/process/migration/Main.java
index 38945df..f128e70 100644 (file)
@@ -4,7 +4,7 @@
 /* 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. */
 
 /* 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. */
 
-package migration;
+package process.migration;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Mutex;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Mutex;
 import org.simgrid.msg.Process;
similarity index 97%
rename from examples/java/migration/Policeman.java
rename to examples/java/process/migration/Policeman.java
index 3bdde64..d078cfb 100644 (file)
@@ -4,7 +4,7 @@
 /* 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. */
 
 /* 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. */
 
-package migration;
+package process.migration;
 
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Host;
 
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Host;
@@ -2,7 +2,7 @@
 
 ! output sort 19
 
 
 ! output sort 19
 
-$ java -classpath ${classpath:=.} migration/Main ${srcdir:=.}/../platforms/platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ java -classpath ${classpath:=.} process/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] (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
 > [  0.000000] (0:maestro@) Using regular java threads.
 > [  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
similarity index 94%
rename from examples/java/suspend/DreamMaster.java
rename to examples/java/process/suspend/DreamMaster.java
index 650a364..08459e4 100644 (file)
@@ -4,8 +4,8 @@
 /* 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. */
 
 /* 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. */
 
-package suspend;
-import org.simgrid.msg .Host;
+package process.suspend;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.MsgException;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.MsgException;
similarity index 96%
rename from examples/java/suspend/LazyGuy.java
rename to examples/java/process/suspend/LazyGuy.java
index 74231fe..b42bcce 100644 (file)
@@ -4,7 +4,7 @@
 /* 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. */
 
 /* 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. */
 
-package suspend;
+package process.suspend;
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Process;
similarity index 95%
rename from examples/java/suspend/Suspend.java
rename to examples/java/process/suspend/Main.java
index c56e739..22af113 100644 (file)
@@ -4,11 +4,11 @@
 /* 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. */
 
 /* 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. */
 
-package suspend;
+package process.suspend;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
 
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
 
-public class Suspend {
+public class Main {
   public static void main(String[] args) {
     Msg.init(args);
     if(args.length < 1) {
   public static void main(String[] args) {
     Msg.init(args);
     if(args.length < 1) {
similarity index 82%
rename from examples/java/suspend/suspend.tesh
rename to examples/java/process/suspend/process_suspend.tesh
index b78bd64..c1d9cc7 100644 (file)
@@ -1,7 +1,7 @@
 #! tesh
 
 ! output sort 19
 #! tesh
 
 ! output sort 19
-$ java -classpath ${classpath:=.} suspend/Suspend ${srcdir:=.}/../platforms/platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ java -classpath ${classpath:=.} process/suspend/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:DreamMaster@Jacquelin) Let's create a lazy guy.
 > [  0.000000] (1:DreamMaster@Jacquelin) Let's wait a little bit...
 > [  0.000000] (0:maestro@) Using regular java threads.
 > [  0.000000] (1:DreamMaster@Jacquelin) Let's create a lazy guy.
 > [  0.000000] (1:DreamMaster@Jacquelin) Let's wait a little bit...
diff --git a/examples/java/suspend/CMakeLists.txt b/examples/java/suspend/CMakeLists.txt
deleted file mode 100644 (file)
index 2e05729..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-set(example java_suspend)
-set(sources ${CMAKE_CURRENT_SOURCE_DIR}/Suspend.java ${CMAKE_CURRENT_SOURCE_DIR}/DreamMaster.java ${CMAKE_CURRENT_SOURCE_DIR}/LazyGuy.java)
-
-if(enable_java)
-  add_custom_command(
-    COMMENT "Building ${example}..."
-    OUTPUT ${example}_compiled
-    DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
-    COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR} -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources}
-    COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled
-    COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled
-  )
-  add_custom_target(${example} ALL DEPENDS ${example}_compiled)
-  ADD_TESH(java-suspend --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/suspend/suspend.tesh)
-endif()
-
-set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/suspend.tesh           PARENT_SCOPE)
-set(examples_src  ${examples_src}  ${sources}                                         PARENT_SCOPE)
index f136617..c554038 100644 (file)
@@ -923,6 +923,7 @@ set(txt_files
 # The list of cmake build directories is constructed from the following list. 
 # Add your CMakeLists file here to see your subdir built.
 set(CMAKEFILES_TXT
 # The list of cmake build directories is constructed from the following list. 
 # Add your CMakeLists file here to see your subdir built.
 set(CMAKEFILES_TXT
+  examples/java/CMakeLists.txt
   examples/java/async/CMakeLists.txt
   examples/java/bittorrent/CMakeLists.txt
   examples/java/chord/CMakeLists.txt
   examples/java/async/CMakeLists.txt
   examples/java/bittorrent/CMakeLists.txt
   examples/java/chord/CMakeLists.txt
@@ -933,14 +934,11 @@ set(CMAKEFILES_TXT
   examples/java/energy/CMakeLists.txt
   examples/java/io/CMakeLists.txt
   examples/java/kademlia/CMakeLists.txt
   examples/java/energy/CMakeLists.txt
   examples/java/io/CMakeLists.txt
   examples/java/kademlia/CMakeLists.txt
-  examples/java/kill/CMakeLists.txt
   examples/java/masterworker/CMakeLists.txt
   examples/java/masterworker/CMakeLists.txt
-  examples/java/migration/CMakeLists.txt
   examples/java/mutualExclusion/CMakeLists.txt
   examples/java/pingPong/CMakeLists.txt
   examples/java/priority/CMakeLists.txt
   examples/java/startKillTime/CMakeLists.txt
   examples/java/mutualExclusion/CMakeLists.txt
   examples/java/pingPong/CMakeLists.txt
   examples/java/priority/CMakeLists.txt
   examples/java/startKillTime/CMakeLists.txt
-  examples/java/suspend/CMakeLists.txt
   examples/java/tracing/CMakeLists.txt
   
   examples/msg/CMakeLists.txt
   examples/java/tracing/CMakeLists.txt
   
   examples/msg/CMakeLists.txt