From: Samuel Lepetit Date: Wed, 16 May 2012 11:56:08 +0000 (+0200) Subject: Add an example to test starting_time and kill_time X-Git-Tag: v3_9_90~569^2~19^2~76 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/72b87a2780383260b02c46d94d609579d606bb15 Add an example to test starting_time and kill_time --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 513265f0ca..753e8a7c1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,7 @@ set(JMSG_JAVA_SRC ) set(JAVA_EXAMPLES + examples/mutualExclusion/centralized/MutexCentral.java examples/mutualExclusion/centralized/GrantTask.java examples/mutualExclusion/centralized/Coordinator.java @@ -145,6 +146,9 @@ set(JAVA_EXAMPLES examples/async/Forwarder.java examples/async/Master.java examples/async/Slave.java + examples/startKillTime/Slave.java + examples/startKillTime/Master.java + examples/startKillTime/StartKillTime.java ) set(CMAKE_SRC @@ -242,6 +246,7 @@ add_custom_command( 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/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/startKillTime/*.java ) add_custom_target(simgrid_java_examples ALL @@ -271,8 +276,9 @@ ADD_TEST(CommTime ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE ADD_TEST(mutualExclusion ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/mutualexclusion.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(kill ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/kill.tesh) +ADD_TEST(startKillTime ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/startKillTime.tesh) #Don't forget to put new test in this list!!! -set(test_list basic async pingPong CommTime mutualExclusion bypass kill) +set(test_list basic async pingPong CommTime mutualExclusion bypass kill startKillTime) ########################################## # Set the DYLD_LIBRARY_PATH for mac # diff --git a/examples/startKillTime/Master.java b/examples/startKillTime/Master.java new file mode 100644 index 0000000000..1262850e7d --- /dev/null +++ b/examples/startKillTime/Master.java @@ -0,0 +1,27 @@ +/* + * 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 startKillTime; +import org.simgrid.msg.Host; +import org.simgrid.msg.HostFailureException; +import org.simgrid.msg.HostNotFoundException; +import org.simgrid.msg.TransferFailureException; +import org.simgrid.msg.TimeoutException; +import org.simgrid.msg.Msg; +import org.simgrid.msg.Process; + + +public class Master extends Process { + public Master(Host host, String name, String[]args, double startTime, double killTime) { + super(host,name,args,startTime,killTime); + } + public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException { + Msg.info("Hello!"); + waitFor(10.0); + Msg.info("OK, goodbye now."); + + } +} diff --git a/examples/startKillTime/Slave.java b/examples/startKillTime/Slave.java new file mode 100644 index 0000000000..2120e905d3 --- /dev/null +++ b/examples/startKillTime/Slave.java @@ -0,0 +1,29 @@ +/* + * 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 startKillTime; +import org.simgrid.msg.Host; +import org.simgrid.msg.HostFailureException; +import org.simgrid.msg.HostNotFoundException; +import org.simgrid.msg.TransferFailureException; +import org.simgrid.msg.TimeoutException; +import org.simgrid.msg.Msg; +import org.simgrid.msg.Process; + +/** + * Lazy Guy Slave, suspends itself ASAP + */ +public class Slave extends Process { + public Slave(Host host, String name, String[]args, double startTime, double killTime) { + super(host,name,args,startTime,killTime); + } + public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException { + Msg.info("Hello!"); + waitFor(10.0); + Msg.info("OK, goodbye now."); + + } +} diff --git a/examples/startKillTime/StartKillTime.java b/examples/startKillTime/StartKillTime.java new file mode 100644 index 0000000000..55fb7bee8c --- /dev/null +++ b/examples/startKillTime/StartKillTime.java @@ -0,0 +1,33 @@ +/* Copyright (c) 2007, 2009, 2010, 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 startKillTime; +import org.simgrid.msg.Msg; +import org.simgrid.msg.NativeException; + +public class StartKillTime { + + /* This only contains the launcher. If you do nothing more than than you can run + * java org.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 : StartKilltime platform_file deployment_file"); + Msg.info("example : StartKilltime platform.xml startKilltime.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/startKillTime/deployment.xml b/examples/startKillTime/deployment.xml new file mode 100644 index 0000000000..8afa3fd495 --- /dev/null +++ b/examples/startKillTime/deployment.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/examples/startKillTime/deployment_kill.xml b/examples/startKillTime/deployment_kill.xml new file mode 100644 index 0000000000..0d7e003bb7 --- /dev/null +++ b/examples/startKillTime/deployment_kill.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/examples/startKillTime/deployment_start.xml b/examples/startKillTime/deployment_start.xml new file mode 100644 index 0000000000..dbf6de6a38 --- /dev/null +++ b/examples/startKillTime/deployment_start.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/examples/startKillTime/deployment_start_kill.xml b/examples/startKillTime/deployment_start_kill.xml new file mode 100644 index 0000000000..d7fd058fb0 --- /dev/null +++ b/examples/startKillTime/deployment_start_kill.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/examples/startKillTime/startKillTime.tesh b/examples/startKillTime/startKillTime.tesh new file mode 100644 index 0000000000..364d62148b --- /dev/null +++ b/examples/startKillTime/startKillTime.tesh @@ -0,0 +1,14 @@ +#! ./tesh +$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar startKillTime/StartKillTime ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/startKillTime/deployment_start_kill.xml +> [0.000000] [jmsg/INFO] Ready to run MSG_MAIN +> [Jacquelin:startKillTime.Master:(1) 0.000000] [jmsg/INFO] Hello! +> [Boivin:startKillTime.Slave:(2) 1.000000] [jmsg/INFO] Hello! +> [Jean_Yves:startKillTime.Slave:(3) 2.000000] [jmsg/INFO] Hello! +> [TeX:startKillTime.Slave:(4) 3.000000] [jmsg/INFO] Hello! +> [Geoff:startKillTime.Slave:(5) 4.000000] [jmsg/INFO] Hello! +> [Disney:startKillTime.Slave:(6) 5.000000] [jmsg/INFO] Hello! +> [Jacquelin:startKillTime.Master:(1) 10.000000] [jmsg/INFO] OK, goodbye now. +> [10.000000] [jmsg/INFO] Done running MSG_MAIN +> [10.000000] [jmsg/INFO] MSG_main finished +> [10.000000] [jmsg/INFO] Clean java world +> [10.000000] [jmsg/INFO] Clean native world