From: Samuel Lepetit Date: Tue, 12 Jun 2012 13:11:11 +0000 (+0200) Subject: Merge scm.gforge.inria.fr:/gitroot/simgrid/simgrid-java X-Git-Tag: v3_9_90~569^2~19^2~56^2~4 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d318c9e02308e2c7c66e3fcc06105d96332ebb44?hp=f4fb259da7eb35a292005c2deea6b8f94ede5fc7 Merge scm.gforge.inria.fr:/gitroot/simgrid/simgrid-java --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 55a5fad96d..327131ae71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,13 +120,6 @@ set(JAVA_EXAMPLES examples/async/Forwarder.java examples/async/Master.java examples/async/Slave.java - examples/startKillTime/Slave.java - examples/basic/FinalizeTask.java - examples/basic/Forwarder.java - examples/basic/Master.java - examples/basic/BasicTest.java - examples/basic/Slave.java - examples/bittorrent/Bittorrent.java examples/bittorrent/Common.java examples/bittorrent/Connection.java @@ -146,6 +139,11 @@ set(JAVA_EXAMPLES examples/commTime/Master.java examples/commTime/Slave.java examples/commTime/CommTimeTest.java + examples/masterslave/FinalizeTask.java + examples/masterslave/Forwarder.java + examples/masterslave/Master.java + examples/masterslave/Masterslave.java + examples/masterslave/Slave.java examples/master_slave_bypass/Master.java examples/master_slave_bypass/MsBypass.java examples/master_slave_bypass/Slave.java @@ -154,6 +152,9 @@ set(JAVA_EXAMPLES examples/master_slave_kill/MsKill.java examples/master_slave_kill/Slave.java examples/master_slave_kill/FinalizeTask.java + examples/migration/Emigrant.java + examples/migration/Migration.java + examples/migration/Policeman.java examples/mutualExclusion/centralized/MutexCentral.java examples/mutualExclusion/centralized/GrantTask.java examples/mutualExclusion/centralized/Coordinator.java @@ -165,6 +166,7 @@ set(JAVA_EXAMPLES examples/pingPong/Receiver.java examples/pingPong/PingPongTest.java examples/startKillTime/Master.java + examples/startKillTime/Slave.java examples/startKillTime/StartKillTime.java examples/suspend/DreamMaster.java examples/suspend/LazyGuy.java @@ -179,17 +181,17 @@ ${CMAKE_HOME_DIRECTORY}/FindSimGrid.cmake ) set(XML_FILES - examples/commTime/commTimeDeployment.xml - examples/mutualExclusion/ring3.xml - examples/mutualExclusion/centralized/mutex_centralized_deployment.xml examples/platform.xml - examples/pingPong/pingPongDeployment.xml - examples/basic/basicDeployment.xml - examples/basic/deploy.xml - examples/master_slave_bypass/platform.xml - examples/master_slave_kill/platform.xml examples/async/asyncDeployment.xml examples/bittorrent/bittorrent.xml + examples/commTime/commTimeDeployment.xml + examples/masterslave/masterslaveDeployment.xml + examples/masterslave/deploy.xml + examples/master_slave_bypass/platform.xml + examples/master_slave_kill/platform.xml + examples/mutualExclusion/ring3.xml + examples/mutualExclusion/centralized/mutex_centralized_deployment.xml + examples/pingPong/pingPongDeployment.xml ) set(source_to_pack @@ -262,12 +264,13 @@ add_custom_command( OUTPUT ${JAVA_EXAMPLES_CLASS} DEPENDS ${JAVA_EXAMPLES} COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/async/*.java - COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/basic/*.java - COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/*.java + COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/*.java COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/chord/*.java COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/commTime/*.java + COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/masterslave/*.java COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/*.java COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/*.java + COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/migration/*.java COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/*.java COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/priority/*.java @@ -297,19 +300,20 @@ INCLUDE(CTest) ENABLE_TESTING() ADD_TEST(async ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/async/async.tesh) -ADD_TEST(basic ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/basic/basic.tesh) ADD_TEST(bittorrent ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/bittorrent.tesh) ADD_TEST(bypass ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/bypass.tesh) ADD_TEST(commTime ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/commTime/commtime.tesh) ADD_TEST(chord ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/chord/chord.tesh) ADD_TEST(kill ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/kill.tesh) +ADD_TEST(masterslave ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/masterslave/masterslave.tesh) +ADD_TEST(migration ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/migration/migration.tesh) ADD_TEST(mutualExclusion ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/mutualexclusion.tesh) ADD_TEST(pingPong ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingpong.tesh) ADD_TEST(priority ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/priority/priority.tesh) ADD_TEST(startKillTime ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/startKillTime.tesh) ADD_TEST(suspend ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/suspend/suspend.tesh) #Don't forget to put new test in this list!!! -set(test_list async basic bittorrent bypass chord commTime kill mutualExclusion pingPong priority startKillTime) +set(test_list async bittorrent bypass chord commTime kill masterslave migration mutualExclusion pingPong priority startKillTime) ########################################## # Set the DYLD_LIBRARY_PATH for mac # diff --git a/examples/async/AsyncTest.java b/examples/async/AsyncTest.java index 1e14632da9..f8abd3367e 100644 --- a/examples/async/AsyncTest.java +++ b/examples/async/AsyncTest.java @@ -22,23 +22,16 @@ public class AsyncTest { /* initialize the MSG simulation. Must be done before anything else (even logging). */ Msg.init(args); - if(args.length == 0) { - Msg.createEnvironment("async_platform.xml"); - Msg.deployApplication("async_deployment.xml"); - - } else if (args.length < 2) { - - + if (args.length < 2) { Msg.info("Usage : Async platform_file deployment_file"); - Msg.info("example : Async async_platform.xml async_deployment.xml"); - System.exit(1); - } else { - - /* construct the platform and deploy the application */ - Msg.createEnvironment(args[0]); - Msg.deployApplication(args[1]); + Msg.info("example : Async basic_platform.xml basic_deployment.xml"); + System.exit(1); } + /* construct the platform and deploy the application */ + Msg.createEnvironment(args[0]); + Msg.deployApplication(args[1]); + /* execute the simulation. */ Msg.run(); } diff --git a/examples/basic/BasicTest.java b/examples/basic/BasicTest.java deleted file mode 100644 index af6f35bffd..0000000000 --- a/examples/basic/BasicTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2006,2007,2010. The SimGrid Team. All rights reserved. - * - * 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 basic; - -import org.simgrid.msg.Msg; -import org.simgrid.msg.NativeException; - -public class BasicTest { - - /* This only contains the launcher. If you do nothing more than than you can run - * java simgrid.msg.Msg - * which also contains such a launcher - */ - - public static void main(String[] args) throws NativeException { - - /* initialize the MSG simulation. Must be done before anything else (even logging). */ - Msg.init(args); - - if(args.length == 0) { - Msg.createEnvironment("basic_platform.xml"); - Msg.deployApplication("basic_deployment.xml"); - - } else if (args.length < 2) { - - - Msg.info("Usage : Basic platform_file deployment_file"); - Msg.info("example : Basic basic_platform.xml basic_deployment.xml"); - System.exit(1); - } else { - - /* construct the platform and deploy the application */ - Msg.createEnvironment(args[0]); - Msg.deployApplication(args[1]); - } - - /* execute the simulation. */ - Msg.run(); - } -} diff --git a/examples/basic/basic.tesh b/examples/basic/basic.tesh deleted file mode 100644 index f05eba9c58..0000000000 --- a/examples/basic/basic.tesh +++ /dev/null @@ -1,35 +0,0 @@ -#! ./tesh - -! output sort - -$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar basic/BasicTest ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/basic/basicDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" -> [ 0.000000] (0:@) Ready to run MSG_MAIN -> [ 0.000000] (1:basic.Master@Jacquelin) Hello! Got 7 slaves and 5 tasks to process -> [ 0.000000] (2:basic.Forwarder@Jackson) Receiving on 'slave_0' -> [ 0.000000] (3:basic.Forwarder@Casavant) Receiving on 'slave_1' -> [ 0.851529] (2:basic.Forwarder@Jackson) Sending "Task_0" to "slave_7" -> [ 2.208640] (3:basic.Forwarder@Casavant) Sending "Task_1" to "slave_9" -> [ 2.720598] (11:basic.Slave@Sirois) Received "Task_1". Processing it. -> [ 3.554211] (9:basic.Slave@Stephen) Received "Task_0". Processing it. -> [ 5.252532] (4:basic.Slave@iRMX) Received "Task_2". Processing it. -> [ 6.267288] (5:basic.Slave@Bousquet) Received "Task_3". Processing it. -> [ 7.711085] (1:basic.Master@Jacquelin) All tasks have been dispatched. Let's tell everybody the computation is over. -> [ 7.711085] (6:basic.Slave@Soucy) Received "Task_4". Processing it. -> [ 8.562549] (2:basic.Forwarder@Jackson) Got a finalize task. Let's forward that we're done. -> [ 9.919556] (3:basic.Forwarder@Casavant) Got a finalize task. Let's forward that we're done. -> [ 10.431474] (11:basic.Slave@Sirois) Received Finalize. I'm done. See you! -> [ 11.265023] (9:basic.Slave@Stephen) Received Finalize. I'm done. See you! -> [ 11.318960] (12:basic.Slave@Monique) Received Finalize. I'm done. See you! -> [ 11.318960] (3:basic.Forwarder@Casavant) I'm done. See you! -> [ 12.963214] (4:basic.Slave@iRMX) Received Finalize. I'm done. See you! -> [ 13.908112] (10:basic.Slave@Robert) Received Finalize. I'm done. See you! -> [ 13.908112] (2:basic.Forwarder@Jackson) I'm done. See you! -> [ 13.977892] (5:basic.Slave@Bousquet) Received Finalize. I'm done. See you! -> [ 15.421578] (6:basic.Slave@Soucy) Received Finalize. I'm done. See you! -> [ 16.278886] (7:basic.Slave@Kuenning) Received Finalize. I'm done. See you! -> [ 17.252217] (0:@) Done running MSG_MAIN -> [ 17.252217] (0:@) MSG_main finished -> [ 17.252217] (0:@) Clean java world -> [ 17.252217] (0:@) Clean native world -> [ 17.252217] (1:basic.Master@Jacquelin) Goodbye now! -> [ 17.252217] (8:basic.Slave@Browne) Received Finalize. I'm done. See you! \ No newline at end of file diff --git a/examples/basic/deploy.xml b/examples/basic/deploy.xml deleted file mode 100644 index f1351dca2d..0000000000 --- a/examples/basic/deploy.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/examples/master_slave_bypass/platform.xml b/examples/master_slave_bypass/platform.xml index 310c6e65d2..776a31b11d 100644 --- a/examples/master_slave_bypass/platform.xml +++ b/examples/master_slave_bypass/platform.xml @@ -26,4 +26,4 @@ - \ No newline at end of file + diff --git a/examples/basic/FinalizeTask.java b/examples/masterslave/FinalizeTask.java similarity index 93% rename from examples/basic/FinalizeTask.java rename to examples/masterslave/FinalizeTask.java index 7034e4ca00..c95e455485 100644 --- a/examples/basic/FinalizeTask.java +++ b/examples/masterslave/FinalizeTask.java @@ -5,7 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ -package basic; +package masterslave; import org.simgrid.msg.Task; public class FinalizeTask extends Task { @@ -13,4 +13,4 @@ public class FinalizeTask extends Task { super("finalize",0,0); } } - \ No newline at end of file + diff --git a/examples/basic/Forwarder.java b/examples/masterslave/Forwarder.java similarity index 98% rename from examples/basic/Forwarder.java rename to examples/masterslave/Forwarder.java index e8faf39e5e..0c285ee4d0 100644 --- a/examples/basic/Forwarder.java +++ b/examples/masterslave/Forwarder.java @@ -5,7 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ -package basic; +package masterslave; import org.simgrid.msg.Host; import org.simgrid.msg.Msg; diff --git a/examples/basic/Master.java b/examples/masterslave/Master.java similarity index 98% rename from examples/basic/Master.java rename to examples/masterslave/Master.java index dfb4a9b475..9d582cf8be 100644 --- a/examples/basic/Master.java +++ b/examples/masterslave/Master.java @@ -7,7 +7,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ -package basic; +package masterslave; import org.simgrid.msg.Host; import org.simgrid.msg.Msg; import org.simgrid.msg.MsgException; diff --git a/examples/masterslave/Masterslave.java b/examples/masterslave/Masterslave.java new file mode 100644 index 0000000000..03acdc6b69 --- /dev/null +++ b/examples/masterslave/Masterslave.java @@ -0,0 +1,35 @@ +/* + * Copyright 2006,2007,2010. The SimGrid Team. All rights reserved. + * + * 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 masterslave; + +import org.simgrid.msg.Msg; +import org.simgrid.msg.NativeException; + +public class Masterslave { + + /* This only contains the launcher. If you do nothing more than than you can run + * java simgrid.msg.Msg + * which also contains such a launcher + */ + + public static void main(String[] args) throws NativeException { + /* initialize the MSG simulation. Must be done before anything else (even logging). */ + Msg.init(args); + + if (args.length < 2) { + Msg.info("Usage : Masterslave platform_file deployment_file"); + Msg.info("example : Masterslave basic_platform.xml basic_deployment.xml"); + System.exit(1); + } + /* construct the platform and deploy the application */ + Msg.createEnvironment(args[0]); + Msg.deployApplication(args[1]); + /* execute the simulation. */ + Msg.run(); + } +} diff --git a/examples/basic/README b/examples/masterslave/README similarity index 100% rename from examples/basic/README rename to examples/masterslave/README diff --git a/examples/basic/Slave.java b/examples/masterslave/Slave.java similarity index 98% rename from examples/basic/Slave.java rename to examples/masterslave/Slave.java index dc216a4d46..e72b76d30d 100644 --- a/examples/basic/Slave.java +++ b/examples/masterslave/Slave.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 basic; +package masterslave; import org.simgrid.msg.Host; import org.simgrid.msg.HostFailureException; @@ -45,4 +45,4 @@ public class Slave extends Process { Msg.info("Received Finalize. I'm done. See you!"); } -} \ No newline at end of file +} diff --git a/examples/masterslave/deploy.xml b/examples/masterslave/deploy.xml new file mode 100644 index 0000000000..f72a8b9523 --- /dev/null +++ b/examples/masterslave/deploy.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + diff --git a/examples/masterslave/masterslave.tesh b/examples/masterslave/masterslave.tesh new file mode 100644 index 0000000000..b13ffaf143 --- /dev/null +++ b/examples/masterslave/masterslave.tesh @@ -0,0 +1,35 @@ +#! ./tesh + +! output sort + +$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar masterslave/Masterslave ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/masterslave/masterslaveDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (0:@) Ready to run MSG_MAIN +> [ 0.000000] (1:masterslave.Master@Jacquelin) Hello! Got 7 slaves and 5 tasks to process +> [ 0.000000] (2:masterslave.Forwarder@Jackson) Receiving on 'slave_0' +> [ 0.000000] (3:masterslave.Forwarder@Casavant) Receiving on 'slave_1' +> [ 0.851529] (2:masterslave.Forwarder@Jackson) Sending "Task_0" to "slave_7" +> [ 2.208640] (3:masterslave.Forwarder@Casavant) Sending "Task_1" to "slave_9" +> [ 2.720598] (11:masterslave.Slave@Sirois) Received "Task_1". Processing it. +> [ 3.554211] (9:masterslave.Slave@Stephen) Received "Task_0". Processing it. +> [ 5.252532] (4:masterslave.Slave@iRMX) Received "Task_2". Processing it. +> [ 6.267288] (5:masterslave.Slave@Bousquet) Received "Task_3". Processing it. +> [ 7.711085] (1:masterslave.Master@Jacquelin) All tasks have been dispatched. Let's tell everybody the computation is over. +> [ 7.711085] (6:masterslave.Slave@Soucy) Received "Task_4". Processing it. +> [ 8.562549] (2:masterslave.Forwarder@Jackson) Got a finalize task. Let's forward that we're done. +> [ 9.919556] (3:masterslave.Forwarder@Casavant) Got a finalize task. Let's forward that we're done. +> [ 10.431474] (11:masterslave.Slave@Sirois) Received Finalize. I'm done. See you! +> [ 11.265023] (9:masterslave.Slave@Stephen) Received Finalize. I'm done. See you! +> [ 11.318960] (12:masterslave.Slave@Monique) Received Finalize. I'm done. See you! +> [ 11.318960] (3:masterslave.Forwarder@Casavant) I'm done. See you! +> [ 12.963214] (4:masterslave.Slave@iRMX) Received Finalize. I'm done. See you! +> [ 13.908112] (10:masterslave.Slave@Robert) Received Finalize. I'm done. See you! +> [ 13.908112] (2:masterslave.Forwarder@Jackson) I'm done. See you! +> [ 13.977892] (5:masterslave.Slave@Bousquet) Received Finalize. I'm done. See you! +> [ 15.421578] (6:masterslave.Slave@Soucy) Received Finalize. I'm done. See you! +> [ 16.278886] (7:masterslave.Slave@Kuenning) Received Finalize. I'm done. See you! +> [ 17.252217] (0:@) Done running MSG_MAIN +> [ 17.252217] (0:@) MSG_main finished +> [ 17.252217] (0:@) Clean java world +> [ 17.252217] (0:@) Clean native world +> [ 17.252217] (1:masterslave.Master@Jacquelin) Goodbye now! +> [ 17.252217] (8:masterslave.Slave@Browne) Received Finalize. I'm done. See you! diff --git a/examples/basic/basicDeployment.xml b/examples/masterslave/masterslaveDeployment.xml similarity index 67% rename from examples/basic/basicDeployment.xml rename to examples/masterslave/masterslaveDeployment.xml index 7edfa6d0d0..6c01ac0120 100644 --- a/examples/basic/basicDeployment.xml +++ b/examples/masterslave/masterslaveDeployment.xml @@ -1,49 +1,49 @@ - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/examples/migration/Emigrant.java b/examples/migration/Emigrant.java new file mode 100644 index 0000000000..c87508125d --- /dev/null +++ b/examples/migration/Emigrant.java @@ -0,0 +1,42 @@ +/* + * 2012. The SimGrid Team. All rights reserved. + * + * 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; + +import org.simgrid.msg.Host; +import org.simgrid.msg.Msg; +import org.simgrid.msg.MsgException; +import org.simgrid.msg.Task; +import org.simgrid.msg.Process; + +public class Emigrant extends Process { + public Emigrant(Host host, String name, String[]args) { + super(host,name,args); + } + public void main(String[] args) throws MsgException { + Migration.mutex.acquire(); + + Msg.info("I'll look for a new job on another machine where the grass is greener."); + migrate(Host.getByName("Boivin")); + + Msg.info("Yeah, found something to do"); + Task task = new Task("job", 98095000, 0); + task.execute(); + waitFor(2); + + Msg.info("Moving back to home after work"); + migrate(Host.getByName("Jacquelin")); + migrate(Host.getByName("Boivin")); + waitFor(4); + + Migration.processToMigrate = this; + Migration.mutex.release(); + suspend(); + + Msg.info("I've been moved on this new host:" + getHost().getName()); + Msg.info("Uh, nothing to do here. Stopping now"); + } +} \ No newline at end of file diff --git a/examples/migration/Migration.java b/examples/migration/Migration.java new file mode 100644 index 0000000000..bcf17ab095 --- /dev/null +++ b/examples/migration/Migration.java @@ -0,0 +1,46 @@ +/* + * $Id$ + * + * Copyright 2006,2007 Martin Quinson, Malek Cherier + * All rights reserved. + * + * 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; +import org.simgrid.msg.Msg; +import org.simgrid.msg.Mutex; +import org.simgrid.msg.NativeException; +import org.simgrid.msg.Process; +/** + * Demonstrates the use of Task.setPriority to change + * the computation priority of a task + */ +public class Migration { + public static Mutex mutex; + public static Process processToMigrate = null; + + /* This only contains the launcher. If you do nothing more than than you can run + * java simgrid.msg.Msg + * which also contains such a launcher + */ + + public static void main(String[] args) throws NativeException { + /* initialize the MSG simulation. Must be done before anything else (even logging). */ + Msg.init(args); + if(args.length < 2) { + Msg.info("Usage : Priority platform_file deployment_file"); + Msg.info("example : Priority ping_pong_platform.xml ping_pong_deployment.xml"); + System.exit(1); + } + /* Create the mutex */ + mutex = new Mutex(); + + /* construct the platform and deploy the application */ + Msg.createEnvironment(args[0]); + Msg.deployApplication(args[1]); + + /* execute the simulation. */ + Msg.run(); + } +} diff --git a/examples/migration/Policeman.java b/examples/migration/Policeman.java new file mode 100644 index 0000000000..3e01db31c7 --- /dev/null +++ b/examples/migration/Policeman.java @@ -0,0 +1,32 @@ +/* + * 2012. The SimGrid Team. All rights reserved. + * + * 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; + +import org.simgrid.msg.Host; +import org.simgrid.msg.Msg; +import org.simgrid.msg.MsgException; +import org.simgrid.msg.Task; +import org.simgrid.msg.Process; + +public class Policeman extends Process { + public Policeman(Host host, String name, String[]args) { + super(host,name,args); + } + + @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")); + Msg.info("I moved the emigrant"); + Migration.processToMigrate.resume(); + } +} \ No newline at end of file diff --git a/examples/migration/migration.tesh b/examples/migration/migration.tesh new file mode 100644 index 0000000000..869acc592a --- /dev/null +++ b/examples/migration/migration.tesh @@ -0,0 +1,18 @@ +#! ./tesh + +! output sort + +$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar migration/Migration ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/migration/migrationDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +> [ 0.000000] (0:@) Ready to run MSG_MAIN +> [ 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 +> [ 7.000000] (0:@) Done running MSG_MAIN +> [ 7.000000] (0:@) MSG_main finished +> [ 7.000000] (0:@) Clean java world +> [ 7.000000] (0:@) Clean native world +> [ 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 + diff --git a/examples/migration/migrationDeployment.xml b/examples/migration/migrationDeployment.xml new file mode 100644 index 0000000000..db7c6c0905 --- /dev/null +++ b/examples/migration/migrationDeployment.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/suspend/DreamMaster.java b/examples/suspend/DreamMaster.java index 2f1efe5476..f3bb90d980 100644 --- a/examples/suspend/DreamMaster.java +++ b/examples/suspend/DreamMaster.java @@ -15,7 +15,7 @@ public class DreamMaster extends Process { Msg.info("Let's wait a little bit..."); waitFor(10); Msg.info("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!"); - lazyGuy.restart(); + lazyGuy.resume(); Msg.info("OK, goodbye now."); } } \ No newline at end of file diff --git a/examples/suspend/LazyGuy.java b/examples/suspend/LazyGuy.java index cb7c7228e7..09046368a4 100644 --- a/examples/suspend/LazyGuy.java +++ b/examples/suspend/LazyGuy.java @@ -10,7 +10,7 @@ public class LazyGuy extends Process { } public void main(String[] args) throws MsgException { Msg.info("Nobody's watching me ? Let's go to sleep."); - pause(); + suspend(); Msg.info("Uuuh ? Did somebody call me ?"); Msg.info("Mmmh, goodbye now."); } diff --git a/org/simgrid/msg/HostFailureException.java b/org/simgrid/msg/HostFailureException.java index 083aa4a6d2..fb9bcf3b3b 100644 --- a/org/simgrid/msg/HostFailureException.java +++ b/org/simgrid/msg/HostFailureException.java @@ -12,7 +12,7 @@ package org.simgrid.msg; /** - * This exception is raised when The host on which you are running has just been rebooted. + * This exception is raised when the host on which you are running has just been rebooted. */ public class HostFailureException extends MsgException { private static final long serialVersionUID = 1L; diff --git a/org/simgrid/msg/Msg.java b/org/simgrid/msg/Msg.java index a4db8becd3..c2b9cd720f 100644 --- a/org/simgrid/msg/Msg.java +++ b/org/simgrid/msg/Msg.java @@ -24,28 +24,6 @@ public final class Msg { System.exit(1); } } - - /** Everything is right. Keep on going the way ! */ - public static final int SUCCESS = 0; - - /** Something must be not perfectly clean (but I may be paranoid freak...) */ - public static final int WARNING = 1; - - /** There has been a problem during your task transfer. - * Either the network is down or the remote host has been shutdown */ - public static final int TRANSFERT_FAILURE = 2; - - /** System shutdown. - * The host on which you are running has just been rebooted. - * Free your data structures and return now ! */ - public static final int HOST_FAILURE = 3; - - /** Canceled task. This task has been canceled by somebody ! */ - public static final int TASK_CANCELLLED = 4; - - /** You've done something wrong. You'd better look at it... */ - public static final int FATAL_ERROR = 5; - /** Retrieve the simulation time * @return */ diff --git a/org/simgrid/msg/Mutex.java b/org/simgrid/msg/Mutex.java index b88e4d2bb9..7032b6e3ad 100644 --- a/org/simgrid/msg/Mutex.java +++ b/org/simgrid/msg/Mutex.java @@ -1,8 +1,4 @@ -package org.simgrid.msg; -/** A mutex implemented on top of SimGrid synchronization mechanisms. - * You can use it exactly the same way that you use the mutexes, - * but to handle the interactions between the threads within the simulation. - * +/* * Copyright 2012 The SimGrid team. All right reserved. * * This program is free software; you can redistribute @@ -10,17 +6,23 @@ package org.simgrid.msg; * (GNU LGPL) which comes with this package. * */ +package org.simgrid.msg; +/** A mutex implemented on top of SimGrid synchronization mechanisms. + * You can use it exactly the same way that you use the mutexes, + * but to handle the interactions between the processes within the simulation. + * + */ public class Mutex { private long bind; // The C object -- don't touch it - public Mutex(int capa) { - init(capa); + public Mutex() { + init(); } protected void finalize() { exit(); } private native void exit(); - private native void init(int capacity); + private native void init(); public native void acquire(); public native void release(); diff --git a/org/simgrid/msg/Process.java b/org/simgrid/msg/Process.java index f9572c58f9..714a7a3a75 100644 --- a/org/simgrid/msg/Process.java +++ b/org/simgrid/msg/Process.java @@ -230,16 +230,31 @@ public abstract class Process implements Runnable { /** * Suspends the process by suspending the task on which it was * waiting for the completion. - * */ - public native void pause(); + public native void suspend(); + /** + * Suspends the process by suspending the task on which it was + * waiting for the completion. + * DEPRECATED: use suspend instead. + */ + @Deprecated + public void pause() { + suspend(); + } /** * Resumes a suspended process by resuming the task on which it was * waiting for the completion. - * - * + * DEPRECATED: use resume instead. */ - public native void restart(); + @Deprecated + public void restart() { + resume(); + } + /** + * Resumes a suspended process by resuming the task on which it was + * waiting for the completion. + */ + public native void resume(); /** * Tests if a process is suspended. * @@ -308,7 +323,7 @@ public abstract class Process implements Runnable { * @param host The host where to migrate the process. * */ - public native static void migrate(Process process, Host host); + public native void migrate(Host host); /** * Makes the current process sleep until millis millisecondes have elapsed. * You should note that unlike "waitFor" which takes seconds, this method takes milliseconds. diff --git a/org/simgrid/msg/ProcessKilledError.java b/org/simgrid/msg/ProcessKilledError.java index 6cd1c4a458..56dcb872d6 100644 --- a/org/simgrid/msg/ProcessKilledError.java +++ b/org/simgrid/msg/ProcessKilledError.java @@ -1,7 +1,9 @@ package org.simgrid.msg; -/** This exception class is only used to interrupt the java user code - * when the process gets killed by an external event */ +/** This error class is only used to interrupt the java user code + * when the process gets killed by an external event. + * Don't catch it. + */ public class ProcessKilledError extends Error { private static final long serialVersionUID = 1L; diff --git a/src/jmsg_process.c b/src/jmsg_process.c index 78c88dccc1..dc3d26271b 100644 --- a/src/jmsg_process.c +++ b/src/jmsg_process.c @@ -216,7 +216,7 @@ Java_org_simgrid_msg_Process_currentProcess(JNIEnv * env, jclass cls) } JNIEXPORT void JNICALL -Java_org_simgrid_msg_Process_pause(JNIEnv * env, +Java_org_simgrid_msg_Process_suspend(JNIEnv * env, jobject jprocess) { m_process_t process = jprocess_to_native_process(jprocess, env); @@ -234,7 +234,7 @@ Java_org_simgrid_msg_Process_pause(JNIEnv * env, } JNIEXPORT void JNICALL -Java_org_simgrid_msg_Process_restart(JNIEnv * env, +Java_org_simgrid_msg_Process_resume(JNIEnv * env, jobject jprocess) { m_process_t process = jprocess_to_native_process(jprocess, env); diff --git a/src/jmsg_process.h b/src/jmsg_process.h index 3866ad9520..7d5beadcd3 100644 --- a/src/jmsg_process.h +++ b/src/jmsg_process.h @@ -182,18 +182,18 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess (JNIEnv *, jclass); /* * Class org_simgrid_msg_Process - * Method pause + * Method suspend * Signature (Lorg/simgrid/msg/Process;)V */ JNIEXPORT void JNICALL -Java_org_simgrid_msg_Process_pause(JNIEnv * env, +Java_org_simgrid_msg_Process_suspend(JNIEnv * env, jobject jprocess); /* * Class org_simgrid_msg_Process - * Method restart + * Method resume * Signature (Lorg/simgrid/msg/Process;)V */ -JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart +JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume (JNIEnv *, jobject); /* * Class org_simgrid_msg_Process diff --git a/src/jmsg_synchro.c b/src/jmsg_synchro.c index abffec41a6..a5040260ee 100644 --- a/src/jmsg_synchro.c +++ b/src/jmsg_synchro.c @@ -8,6 +8,8 @@ #include "jmsg_synchro.h" #include "jxbt_utilities.h" +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg); + static jfieldID jsyncro_field_Mutex_bind; JNIEXPORT void JNICALL diff --git a/src/smx_context_java.c b/src/smx_context_java.c index a68ebea770..91a3b93114 100644 --- a/src/smx_context_java.c +++ b/src/smx_context_java.c @@ -138,7 +138,7 @@ void smx_ctx_java_stop(smx_context_t context) { smx_ctx_java_t ctx_java = (smx_ctx_java_t)context; /* I am the current process and I am dying */ - if (context->iwannadie == -1) { + if (context->iwannadie) { context->iwannadie = 0; JNIEnv *env = get_current_thread_env(); jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", bprintf("Process killed :)"));