examples/java/energy/java_energy_compiled
examples/java/io/java_io_compiled
examples/java/kademlia/java_kademlia_compiled
-examples/java/master_slave_bypass/java_master_slave_bypass_compiled
-examples/java/master_slave_kill/java_master_slave_kill_compiled
+examples/java/kill/java_kill_compiled
examples/java/masterworker/java_masterworker_compiled
examples/java/migration/java_migration_compiled
examples/java/mutualExclusion/java_mutualExclusion_compiled
-set(example java_master_slave_kill)
-set(sources ${CMAKE_CURRENT_SOURCE_DIR}/MsKill.java ${CMAKE_CURRENT_SOURCE_DIR}/FinalizeTask.java
- ${CMAKE_CURRENT_SOURCE_DIR}/Master.java ${CMAKE_CURRENT_SOURCE_DIR}/Slave.java)
+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(
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/master_slave_kill/kill.tesh)
+ 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(xml_files ${xml_files} PARENT_SCOPE)
set(examples_src ${examples_src} ${sources} PARENT_SCOPE)
--- /dev/null
+/* Master of a basic master/slave example in Java */
+
+/* Copyright (c) 2006-2014. 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 kill;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.HostNotFoundException;
+
+import kill.Victim;
+
+public class Killer extends Process {
+ public Killer(String hostname, String name) throws HostNotFoundException {
+ super(hostname, name);
+ }
+ public void main(String[] args) throws MsgException {
+ Victim poorVictim = null;
+ Msg.info("Hello!");
+ try {
+ poorVictim = new Victim("Boivin","victim");
+ poorVictim.start();
+ } catch (MsgException e){
+ System.out.println("Cannot create the victim process!");
+ }
+ sleep(10000);
+ Msg.info("Resume Process");
+ poorVictim.resume();
+ sleep(1000);
+ Msg.info("Kill Process");
+ poorVictim.kill();
+
+ Msg.info("Ok, goodbye now.");
+ }
+}
/* 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;
+package kill;
import org.simgrid.msg.Msg;
import org.simgrid.msg.MsgException;
import org.simgrid.msg.NativeException;
-public class MsKill {
- /* 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 class Main {
public static void main(String[] args) throws NativeException {
/* initialize the MSG simulation. Must be done before anything else (even logging). */
Msg.init(args);
/* bypass deploymemt */
try {
- Master process1 = new Master("Jacquelin","master");
- process1.start();
+ Killer killer = new Killer("Jacquelin","killer");
+ killer.start();
} catch (MsgException e){
System.out.println("Create processes failed!");
}
--- /dev/null
+/* Copyright (c) 2006-2014. 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 kill;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.HostNotFoundException;
+
+public class Victim extends Process {
+ public Victim(String hostname, String name) throws HostNotFoundException {
+ super(hostname, name);
+ }
+ public void main(String[] args) throws MsgException{
+ Msg.info("Hello!");
+ Msg.info("Suspending myself");
+ suspend();
+ Msg.info("OK, OK. Let's work");
+ Task task = new Task("work", 1e9, 0);
+ task.execute();
+ Msg.info("Bye");
+ }
+}
\ No newline at end of file
--- /dev/null
+#! tesh
+
+! output sort 19
+
+$ java -classpath ${classpath:=.} 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!
+> [Boivin:victim:(2) 0.000000] [jmsg/INFO] Suspending myself
+> [Boivin:victim:(2) 10.000000] [jmsg/INFO] OK, OK. Let's work
+> [Jacquelin:killer:(1) 0.000000] [jmsg/INFO] Hello!
+> [Jacquelin:killer:(1) 10.000000] [jmsg/INFO] Resume Process
+> [Jacquelin:killer:(1) 11.000000] [jmsg/INFO] Kill Process
+> [Jacquelin:killer:(1) 11.000000] [jmsg/INFO] Ok, goodbye now.
+++ /dev/null
-/* Copyright (c) 2006-2014. 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;
-
-public class FinalizeTask extends Task {
- public FinalizeTask() {
- super("finalize",0,0);
- }
-}
+++ /dev/null
-/* Master of a basic master/slave example in Java */
-
-/* Copyright (c) 2006-2014. 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.HostNotFoundException;
-import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
-import org.simgrid.msg.Process;
-import org.simgrid.msg.Task;
-
-import master_slave_kill.FinalizeTask;
-
-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!");
- Process process2 = null;
- //Create a slave on host "alice"
- try {
- Msg.info("Create process on host 'Boivin'");
- process2 = new Slave("Boivin","slave");
- process2.start();
- } catch (MsgException e){
- System.out.println("Process2!");
- }
-
- //Wait for slave "alice"
- while(true) {
- Task task = Task.receive("mail1");
- if (task instanceof FinalizeTask) {
- Msg.info("Received mail1!");
- break;
- }
- }
- process2.kill();
-
- Msg.info("Process2 is now killed, should exit now");
- }
-}
+++ /dev/null
-/* Copyright (c) 2006-2014. 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.NativeException;
-import org.simgrid.msg.Process;
-
-import master_slave_kill.FinalizeTask;
-
-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, NativeException {
- Msg.info("Slave Hello!");
-
- FinalizeTask task = new FinalizeTask();
- Msg.info("Send Mail1!");
- task.send("mail1");
-
- try {
- Task.receive("mail2");
- } catch (MsgException e) {
- Msg.debug("Received failed");
- return;
- }
- Msg.info("Receive Mail2!");
- }
-}
+++ /dev/null
-#! tesh
-
-! output sort 19
-
-$ java -classpath ${classpath:=.} master_slave_kill/MsKill ${srcdir:=.}/../platforms/platform.xml
-> [0.000000] [jmsg/INFO] Using regular java threads.
-> [Jacquelin:master:(1) 0.000000] [jmsg/INFO] Master Hello!
-> [Jacquelin:master:(1) 0.000000] [jmsg/INFO] Create process on host 'Boivin'
-> [Boivin:slave:(2) 0.000000] [jmsg/INFO] Slave Hello!
-> [Boivin:slave:(2) 0.000000] [jmsg/INFO] Send Mail1!
-> [Jacquelin:master:(1) 1.048881] [jmsg/INFO] Received mail1!
-> [Jacquelin:master:(1) 1.048881] [jmsg/INFO] Process2 is now killed, should exit now
-> [1.048881] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
examples/java/energy/CMakeLists.txt
examples/java/io/CMakeLists.txt
examples/java/kademlia/CMakeLists.txt
- examples/java/master_slave_kill/CMakeLists.txt
+ examples/java/kill/CMakeLists.txt
examples/java/masterworker/CMakeLists.txt
examples/java/migration/CMakeLists.txt
examples/java/mutualExclusion/CMakeLists.txt