# Scala examples
if(enable_scala)
set(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/scala/:${SIMGRID_JAR}:${SCALA_JARS}")
+ ADD_TEST(scala-bypass ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/scala --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/scala ${CMAKE_HOME_DIRECTORY}/examples/scala/master_slave_bypass/bypass.tesh)
+ ADD_TEST(scala-kill ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/scala --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/scala ${CMAKE_HOME_DIRECTORY}/examples/scala/master_slave_kill/kill.tesh)
ADD_TEST(scala-masterslave ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/scala --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/scala ${CMAKE_HOME_DIRECTORY}/examples/scala/masterslave/masterslave.tesh)
endif()
examples/java/tracing/CMakeLists.txt
examples/scala/CMakeLists.txt
examples/scala/masterslave/CMakeLists.txt
+ examples/scala/master_slave_bypass/CMakeLists.txt
+ examples/scala/master_slave_kill/CMakeLists.txt
examples/lua/CMakeLists.txt
examples/msg/CMakeLists.txt
examples/msg/actions/CMakeLists.txt
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/scala)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/scala/masterslave)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/scala/master_slave_bypass)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/scala/master_slave_kill)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/properties)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/actions)
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+set(example scala_master_slave_bypass)
+set(sources
+ ${CMAKE_CURRENT_SOURCE_DIR}/FinalizeTask.scala
+ ${CMAKE_CURRENT_SOURCE_DIR}/Master.scala
+ ${CMAKE_CURRENT_SOURCE_DIR}/MsBypass.scala
+ ${CMAKE_CURRENT_SOURCE_DIR}/Slave.scala
+ )
+
+if(enable_scala)
+ add_custom_command(
+ COMMENT "Building ${example}..."
+ OUTPUT ${example}_compiled
+ DEPENDS ${sources} SG_java_jar ${SIMGRID_JAR}
+ COMMAND ${SCALA_COMPILE} -cp ${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)
+endif()
+
+set(tesh_files
+ ${tesh_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/bypass.tesh
+ PARENT_SCOPE
+ )
+set(xml_files
+ ${xml_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/platform.xml
+ PARENT_SCOPE
+ )
+set(examples_src
+ ${examples_src}
+ ${sources}
+ PARENT_SCOPE
+ )
+set(bin_files
+ ${bin_files}
+ PARENT_SCOPE
+ )
+set(txt_files
+ ${txt_files}
+ PARENT_SCOPE
+ )
--- /dev/null
+/*
+ * Copyright 2006-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 master_slave_bypass
+import org.simgrid.msg.Task
+
+class FinalizeTask extends Task("finalize",0,0) {}
--- /dev/null
+/*
+ * Master of a basic master/slave example in Java
+ *
+ * Copyright 2006-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 master_slave_bypass
+
+import Stream._
+import org.simgrid.msg.HostNotFoundException
+import org.simgrid.msg.Msg
+import org.simgrid.msg.MsgException
+import org.simgrid.msg.Process
+import org.simgrid.msg.Task
+
+class Master(hostname:String, name:String) extends Process(hostname,name) {
+
+ def main(args:Array[String]) {
+ Msg.info("Master Hello!")
+
+ //Create a slave on host "alice"
+ try {
+ Msg.info("Create process on host 'alice'")
+ new Slave("alice","process2").start()
+ } catch {
+ case e:MsgException => println("Process2!")
+ }
+
+ //Wait for slave "alice"
+ continually({Task.receive("alice")})
+ .takeWhile(!_.isInstanceOf[FinalizeTask])
+ .force // to force the list to be compute
+
+ Msg.info("Received Finalize. I'm done. See you!")
+ }
+}
--- /dev/null
+/*
+ * Copyright 2006-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 master_slave_bypass
+
+import org.simgrid.msg.Msg
+import org.simgrid.msg.MsgException
+import org.simgrid.msg.NativeException
+
+object MsBypass extends App {
+ /* This only contains the launcher. If you do nothing more than than you can run
+ * scala simgrid.msg.Msg
+ * which also contains such a launcher
+ */
+
+ /* initialize the MSG simulation. Must be done before anything else (even logging). */
+ Msg.init(args)
+ Msg.createEnvironment(args(0))
+
+ /* bypass deployment */
+ try {
+ new Master("bob","process1").start()
+ }
+ catch {
+ case e:MsgException => println("Create processes failed!")
+ }
+
+ /* execute the simulation. */
+ Msg.run()
+}
--- /dev/null
+/*
+ * Copyright 2006-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 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
+
+class Slave(hostname:String, name:String) extends Process(hostname, name) {
+ def main(args:Array[String]) {
+ Msg.info("Slave Hello!")
+ val task = new FinalizeTask()
+ Msg.info("Send finalize!")
+ task.send("alice")
+ }
+}
--- /dev/null
+#! tesh
+
+! output sort
+$ java -cp ${classpath:=.} master_slave_bypass/MsBypass ${srcdir:=.}/master_slave_bypass/platform.xml
+> [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up.
+> [0.013010] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
+> [alice:process2:(2) 0.000000] [jmsg/INFO] Slave Hello!
+> [alice:process2:(2) 0.000000] [jmsg/INFO] Send finalize!
+> [bob:process1:(1) 0.000000] [jmsg/INFO] Master Hello!
+> [bob:process1:(1) 0.000000] [jmsg/INFO] Create process on host 'alice'
+> [bob:process1:(1) 0.013010] [jmsg/INFO] Received Finalize. I'm done. See you!
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+<AS id="AS0" routing="Full">
+ <host id="bob" power="137.333Mf"/>
+ <host id="alice" power="98.095Mf"/>
+ <host id="nono" power="98.095Mf"/>
+
+ <link id="1" bandwidth="100MBps" latency="1ms"/>
+ <link id="2" bandwidth="100MBps" latency="1ms"/>
+ <link id="3" bandwidth="100MBps" latency="1ms"/>
+
+ <route src="bob"
+ dst="alice"
+ symmetrical="YES">
+ <link_ctn id="1"/>
+ </route>
+ <route src="alice"
+ dst="nono"
+ symmetrical="YES">
+ <link_ctn id="2"/>
+ </route>
+ <route src="bob"
+ dst="nono"
+ symmetrical="YES">
+ <link_ctn id="3"/>
+ </route>
+</AS>
+</platform>
--- /dev/null
+cmake_minimum_required(VERSION 2.6)
+
+set(example scala_master_slave_kill)
+set(sources
+ ${CMAKE_CURRENT_SOURCE_DIR}/FinalizeTask.scala
+ ${CMAKE_CURRENT_SOURCE_DIR}/Master.scala
+ ${CMAKE_CURRENT_SOURCE_DIR}/MsKill.scala
+ ${CMAKE_CURRENT_SOURCE_DIR}/Slave.scala
+ )
+
+if(enable_scala)
+ add_custom_command(
+ COMMENT "Building ${example}..."
+ OUTPUT ${example}_compiled
+ DEPENDS ${sources} SG_java_jar ${SIMGRID_JAR}
+ COMMAND ${SCALA_COMPILE} -cp ${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)
+endif()
+
+set(tesh_files
+ ${tesh_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/kill.tesh
+ PARENT_SCOPE
+ )
+set(xml_files
+ ${xml_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/platform.xml
+ PARENT_SCOPE
+ )
+set(examples_src
+ ${examples_src}
+ ${sources}
+ PARENT_SCOPE
+ )
+set(bin_files
+ ${bin_files}
+ PARENT_SCOPE
+ )
+set(txt_files
+ ${txt_files}
+ PARENT_SCOPE
+ )
--- /dev/null
+/*
+ * Copyright 2006-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 master_slave_kill
+
+import org.simgrid.msg.Task
+
+class FinalizeTask extends Task("finalize",0,0) {}
+
--- /dev/null
+/*
+ * Master of a basic master/slave example in Java
+ *
+ * Copyright 2006-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 master_slave_kill
+
+import Stream._
+import org.simgrid.msg.HostNotFoundException
+import org.simgrid.msg.Msg
+import org.simgrid.msg.MsgException
+import org.simgrid.msg.Process
+import org.simgrid.msg.Task
+
+class Master(hostname:String, name:String) extends Process(hostname, name) {
+ def main(args:Array[String]) {
+ Msg.info("Master Hello!")
+ var process2:Slave = null
+
+ //Create a slave on host "alice"
+ try {
+ Msg.info("Create process on host 'alice'")
+ process2 = new Slave("alice","slave")
+ process2.start()
+ } catch {
+ case e:MsgException => println("Process2!")
+ }
+
+ //Wait for slave "alice"
+ continually({Task.receive("mail1")})
+ .takeWhile(!_.isInstanceOf[FinalizeTask])
+ .force // to force the list to be compute
+
+ Msg.info("Received mail1!")
+ process2.kill()
+ Msg.info("Process2 is now killed, should exit now")
+ }
+}
--- /dev/null
+/*
+ * Copyright 2006-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 master_slave_kill;
+
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.NativeException;
+
+object MsKill extends App{
+
+ /* This only contains the launcher. If you do nothing more than than you can run
+ * scala simgrid.msg.Msg
+ * which also contains such a launcher
+ */
+
+
+ /* initialize the MSG simulation. Must be done before anything else (even logging). */
+ Msg.init(args)
+ Msg.createEnvironment(args(0))
+
+ /* bypass deploymemt */
+ try {
+ val process1 = new Master("bob","master")
+ process1.start()
+ }
+ catch {
+ case e:MsgException => println("Create processes failed!")
+ }
+
+ /* execute the simulation. */
+ Msg.run()
+}
--- /dev/null
+/*
+ * Copyright 2006-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 master_slave_kill
+
+import org.simgrid.msg.HostFailureException
+import org.simgrid.msg.HostNotFoundException
+import org.simgrid.msg.Msg
+import org.simgrid.msg.MsgException
+import org.simgrid.msg.Task
+import org.simgrid.msg.TimeoutException
+import org.simgrid.msg.TransferFailureException
+import org.simgrid.msg.Process
+
+class Slave(hostname:String, name:String) extends Process(hostname, name) {
+ def main(args:Array[String]) {
+ Msg.info("Slave Hello!")
+
+ val task = new FinalizeTask();
+ Msg.info("Send Mail1!");
+ task.send("mail1");
+
+ try {
+ Task.receive("mail2");
+ } catch {
+ case e:MsgException => {Msg.debug("Received failed")
+ return}
+ }
+ Msg.info("Receive Mail2!")
+ }
+}
--- /dev/null
+#! tesh
+
+! output sort
+
+$ java -cp ${classpath:=.} master_slave_kill/MsKill ${srcdir:=.}/master_slave_kill/platform.xml
+> [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up.
+> [0.013010] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
+> [alice:slave:(2) 0.000000] [jmsg/INFO] Slave Hello!
+> [alice:slave:(2) 0.000000] [jmsg/INFO] Send Mail1!
+> [bob:master:(1) 0.000000] [jmsg/INFO] Master Hello!
+> [bob:master:(1) 0.000000] [jmsg/INFO] Create process on host 'alice'
+> [bob:master:(1) 0.013010] [jmsg/INFO] Received mail1!
+> [bob:master:(1) 0.013010] [jmsg/INFO] Process2 is now killed, should exit now
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+<AS id="AS0" routing="Full">
+ <host id="bob" power="137.333Mf"/>
+ <host id="alice" power="98.095Mf"/>
+ <host id="nono" power="98.095Mf"/>
+
+ <link id="1" bandwidth="100MBps" latency="1ms"/>
+ <link id="2" bandwidth="100MBps" latency="1ms"/>
+ <link id="3" bandwidth="100MBps" latency="1ms"/>
+
+ <route src="bob"
+ dst="alice"
+ symmetrical="YES">
+ <link_ctn id="1"/>
+ </route>
+ <route src="alice"
+ dst="nono"
+ symmetrical="YES">
+ <link_ctn id="2"/>
+ </route>
+ <route src="bob"
+ dst="nono"
+ symmetrical="YES">
+ <link_ctn id="3"/>
+ </route>
+</AS>
+</platform>
\ No newline at end of file