From: Frederic Suter Date: Tue, 29 Mar 2016 19:25:08 +0000 (+0200) Subject: define a process package in examples/java X-Git-Tag: v3_13~229 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a44f50f08e09cc6164f1b85fba51b2fdd9052cf0 define a process package in examples/java + comprises kill, migration, and suspend Also found a way to factor java cmake \o/\o/\o/ --- diff --git a/.gitignore b/.gitignore index 146f5df8b6..9e829bd855 100644 --- a/.gitignore +++ b/.gitignore @@ -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/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/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/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 diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt new file mode 100644 index 0000000000..f179234dda --- /dev/null +++ b/examples/java/CMakeLists.txt @@ -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 index 4a7eaf159b..0000000000 --- a/examples/java/kill/CMakeLists.txt +++ /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 index 666b4922c4..0000000000 --- a/examples/java/migration/CMakeLists.txt +++ /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) diff --git a/examples/java/kill/Killer.java b/examples/java/process/kill/Killer.java similarity index 95% rename from examples/java/kill/Killer.java rename to examples/java/process/kill/Killer.java index 08bd9b6386..b46590838e 100644 --- a/examples/java/kill/Killer.java +++ b/examples/java/process/kill/Killer.java @@ -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. */ -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 kill.Victim; +import process.kill.Victim; public class Killer extends Process { public Killer(String hostname, String name) throws HostNotFoundException { diff --git a/examples/java/kill/Main.java b/examples/java/process/kill/Main.java similarity index 97% rename from examples/java/kill/Main.java rename to examples/java/process/kill/Main.java index baacd19672..8a1065aff2 100644 --- a/examples/java/kill/Main.java +++ b/examples/java/process/kill/Main.java @@ -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. */ -package kill; +package process.kill; import org.simgrid.msg.Msg; import org.simgrid.msg.MsgException; diff --git a/examples/java/kill/Victim.java b/examples/java/process/kill/Victim.java similarity index 97% rename from examples/java/kill/Victim.java rename to examples/java/process/kill/Victim.java index dfa61c0ac5..14fb38e922 100644 --- a/examples/java/kill/Victim.java +++ b/examples/java/process/kill/Victim.java @@ -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. */ -package kill; +package process.kill; import org.simgrid.msg.Msg; import org.simgrid.msg.Task; import org.simgrid.msg.Process; diff --git a/examples/java/kill/kill.tesh b/examples/java/process/kill/process_kill.tesh similarity index 84% rename from examples/java/kill/kill.tesh rename to examples/java/process/kill/process_kill.tesh index defce7f5fb..b0dae507cb 100644 --- a/examples/java/kill/kill.tesh +++ b/examples/java/process/kill/process_kill.tesh @@ -2,7 +2,7 @@ ! 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! diff --git a/examples/java/migration/Emigrant.java b/examples/java/process/migration/Emigrant.java similarity index 97% rename from examples/java/migration/Emigrant.java rename to examples/java/process/migration/Emigrant.java index 66f7e5090b..9cf5a5c633 100644 --- a/examples/java/migration/Emigrant.java +++ b/examples/java/process/migration/Emigrant.java @@ -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. */ -package migration; +package process.migration; import org.simgrid.msg.Msg; import org.simgrid.msg.Host; import org.simgrid.msg.Task; diff --git a/examples/java/migration/Main.java b/examples/java/process/migration/Main.java similarity index 98% rename from examples/java/migration/Main.java rename to examples/java/process/migration/Main.java index 38945df3dd..f128e70f5c 100644 --- a/examples/java/migration/Main.java +++ b/examples/java/process/migration/Main.java @@ -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. */ -package migration; +package process.migration; import org.simgrid.msg.Msg; import org.simgrid.msg.Mutex; import org.simgrid.msg.Process; diff --git a/examples/java/migration/Policeman.java b/examples/java/process/migration/Policeman.java similarity index 97% rename from examples/java/migration/Policeman.java rename to examples/java/process/migration/Policeman.java index 3bdde64938..d078cfb92d 100644 --- a/examples/java/migration/Policeman.java +++ b/examples/java/process/migration/Policeman.java @@ -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. */ -package migration; +package process.migration; import org.simgrid.msg.Msg; import org.simgrid.msg.Host; diff --git a/examples/java/migration/migration.tesh b/examples/java/process/migration/process_migration.tesh similarity index 83% rename from examples/java/migration/migration.tesh rename to examples/java/process/migration/process_migration.tesh index 604a1d0a52..38c7228521 100644 --- a/examples/java/migration/migration.tesh +++ b/examples/java/process/migration/process_migration.tesh @@ -2,7 +2,7 @@ ! 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 diff --git a/examples/java/suspend/DreamMaster.java b/examples/java/process/suspend/DreamMaster.java similarity index 94% rename from examples/java/suspend/DreamMaster.java rename to examples/java/process/suspend/DreamMaster.java index 650a364730..08459e4db5 100644 --- a/examples/java/suspend/DreamMaster.java +++ b/examples/java/process/suspend/DreamMaster.java @@ -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. */ -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; diff --git a/examples/java/suspend/LazyGuy.java b/examples/java/process/suspend/LazyGuy.java similarity index 96% rename from examples/java/suspend/LazyGuy.java rename to examples/java/process/suspend/LazyGuy.java index 74231fe6b7..b42bcce0e9 100644 --- a/examples/java/suspend/LazyGuy.java +++ b/examples/java/process/suspend/LazyGuy.java @@ -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. */ -package suspend; +package process.suspend; import org.simgrid.msg.Host; import org.simgrid.msg.Msg; import org.simgrid.msg.Process; diff --git a/examples/java/suspend/Suspend.java b/examples/java/process/suspend/Main.java similarity index 95% rename from examples/java/suspend/Suspend.java rename to examples/java/process/suspend/Main.java index c56e739bfa..22af11311a 100644 --- a/examples/java/suspend/Suspend.java +++ b/examples/java/process/suspend/Main.java @@ -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. */ -package suspend; +package process.suspend; 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) { diff --git a/examples/java/suspend/suspend.tesh b/examples/java/process/suspend/process_suspend.tesh similarity index 82% rename from examples/java/suspend/suspend.tesh rename to examples/java/process/suspend/process_suspend.tesh index b78bd64489..c1d9cc7e54 100644 --- a/examples/java/suspend/suspend.tesh +++ b/examples/java/process/suspend/process_suspend.tesh @@ -1,7 +1,7 @@ #! 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... diff --git a/examples/java/suspend/CMakeLists.txt b/examples/java/suspend/CMakeLists.txt deleted file mode 100644 index 2e05729d54..0000000000 --- a/examples/java/suspend/CMakeLists.txt +++ /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) diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index f136617612..c554038669 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -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 + examples/java/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/kill/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/suspend/CMakeLists.txt examples/java/tracing/CMakeLists.txt examples/msg/CMakeLists.txt