From e8ace613433496e0e5219469472d6bf584b7db86 Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 14 Oct 2011 13:26:09 +0200 Subject: [PATCH] Add a new example for java with bypass of deployment. --- .gitignore | 6 +++- CMakeLists.txt | 11 +++++- examples/master_slave_bypass/Master.java | 29 ++++++++++++++++ examples/master_slave_bypass/MsBypass.java | 39 ++++++++++++++++++++++ examples/master_slave_bypass/Slave.java | 22 ++++++++++++ examples/master_slave_bypass/platform.xml | 16 +++++++++ 6 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 examples/master_slave_bypass/Master.java create mode 100644 examples/master_slave_bypass/MsBypass.java create mode 100644 examples/master_slave_bypass/Slave.java create mode 100644 examples/master_slave_bypass/platform.xml diff --git a/.gitignore b/.gitignore index 11091e1f3f..42403ade75 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ *.class simgrid.jar libSG_java.so - +build/ +*.dylib +.project +.cproject +.classpath diff --git a/CMakeLists.txt b/CMakeLists.txt index 8741b2edd6..ff7ce529e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,6 +127,9 @@ set(JAVA_EXAMPLES examples/pingPong/Sender.java examples/pingPong/Receiver.java examples/pingPong/PingPongTest.java + examples/master_slave_bypass/Master.java + examples/master_slave_bypass/MsBypass.java + examples/master_slave_bypass/Slave.java ) set(CMAKE_SRC @@ -144,6 +147,7 @@ set(XML_FILES examples/pingPong/pingPongDeployment.xml examples/basic/basicDeployment.xml examples/basic/deploy.xml + examples/master_slave_bypass/platform.xml ) set(source_to_pack @@ -205,11 +209,12 @@ add_custom_target(simgrid_jar ALL add_custom_command( COMMENT "Build examples for java" 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/basic/*.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/commTime/*.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/master_slave_bypass/*.java ) add_custom_target(simgrid_java_examples ALL DEPENDS ${JAVA_EXAMPLES_CLASS} @@ -243,6 +248,10 @@ java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar ADD_TEST(mutualExclusion java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar mutualExclusion/centralized/MutexCentral ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/ring3.xml ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/mutex_centralized_deployment.xml ) +ADD_TEST(bypass +java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar master_slave_bypass/MsBypass ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/platform.xml +) + ########################################## # Set the DYLD_LIBRARY_PATH for mac # diff --git a/examples/master_slave_bypass/Master.java b/examples/master_slave_bypass/Master.java new file mode 100644 index 0000000000..67499fa62d --- /dev/null +++ b/examples/master_slave_bypass/Master.java @@ -0,0 +1,29 @@ +/* + * Master of a basic master/slave example in Java + * + * 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 master_slave_bypass; +import org.simgrid.msg.HostNotFoundException; +import org.simgrid.msg.Msg; +import org.simgrid.msg.MsgException; +import org.simgrid.msg.Process; + +public class Master extends Process { + public Master(String hostname, String name) throws HostNotFoundException { + super(hostname, name); + } + public void main(String[] args) throws MsgException { + Msg.info("Master Hello!"); +/* try { + Slave process2 = new Slave("alice","process2"); + } + catch (MsgException e){ + System.out.println("Mes couilles!!!!!"); + } */ + } +} diff --git a/examples/master_slave_bypass/MsBypass.java b/examples/master_slave_bypass/MsBypass.java new file mode 100644 index 0000000000..006c63dd6a --- /dev/null +++ b/examples/master_slave_bypass/MsBypass.java @@ -0,0 +1,39 @@ +/* + * 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 master_slave_bypass; + +import org.simgrid.msg.Msg; +import org.simgrid.msg.MsgException; +import org.simgrid.msg.NativeException; + +public class MsBypass { + + /* 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); + Msg.createEnvironment(args[0]); + + /* bypass deploymemt */ + try { + Master process1 = new Master("bob","process1"); + Slave process2 = new Slave("alice","process2"); + } + catch (MsgException e){ + System.out.println("Mes couilles!!!!!"); + } + + /* execute the simulation. */ + Msg.run(); + } +} diff --git a/examples/master_slave_bypass/Slave.java b/examples/master_slave_bypass/Slave.java new file mode 100644 index 0000000000..84de81ccee --- /dev/null +++ b/examples/master_slave_bypass/Slave.java @@ -0,0 +1,22 @@ +/* + * 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 master_slave_bypass; +import org.simgrid.msg.HostFailureException; +import org.simgrid.msg.HostNotFoundException; +import org.simgrid.msg.Msg; +import org.simgrid.msg.TimeoutException; +import org.simgrid.msg.TransferFailureException; +import org.simgrid.msg.Process; + +public class Slave extends Process { + public Slave(String hostname, String name) throws HostNotFoundException { + super(hostname, name); + } + public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException { + Msg.info("Slave Hello!"); + } +} \ No newline at end of file diff --git a/examples/master_slave_bypass/platform.xml b/examples/master_slave_bypass/platform.xml new file mode 100644 index 0000000000..ea46d06cd0 --- /dev/null +++ b/examples/master_slave_bypass/platform.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file -- 2.20.1