Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rework the most basic java example
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 29 Mar 2016 15:19:32 +0000 (17:19 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 29 Mar 2016 15:19:32 +0000 (17:19 +0200)
  + no more Forwarder
  + no more Finalize Task
  + no more Slavery \o/

16 files changed:
.gitignore
examples/java/masterslave/CMakeLists.txt [deleted file]
examples/java/masterslave/FinalizeTask.java [deleted file]
examples/java/masterslave/Forwarder.java [deleted file]
examples/java/masterslave/README [deleted file]
examples/java/masterslave/deploy.xml [deleted file]
examples/java/masterslave/masterslave.tesh [deleted file]
examples/java/masterslave/masterslaveDeployment.xml [deleted file]
examples/java/masterworker/CMakeLists.txt [new file with mode: 0644]
examples/java/masterworker/Main.java [moved from examples/java/masterslave/Masterslave.java with 93% similarity]
examples/java/masterworker/Master.java [moved from examples/java/masterslave/Master.java with 73% similarity]
examples/java/masterworker/README [new file with mode: 0644]
examples/java/masterworker/Worker.java [moved from examples/java/masterslave/Slave.java with 81% similarity]
examples/java/masterworker/masterworker.tesh [new file with mode: 0644]
examples/java/masterworker/masterworkerDeployment.xml [new file with mode: 0644]
tools/cmake/DefinePackages.cmake

index 71fb91f..5cea948 100644 (file)
@@ -982,7 +982,7 @@ 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/masterslave/java_masterslave_compiled
+examples/java/masterworker/java_masterworker_compiled
 examples/java/migration/java_migration_compiled
 examples/java/mutualExclusion/java_mutualExclusion_compiled
 examples/java/pingPong/java_pingPong_compiled
diff --git a/examples/java/masterslave/CMakeLists.txt b/examples/java/masterslave/CMakeLists.txt
deleted file mode 100644 (file)
index fb8fa97..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-set(example java_masterslave)
-set(sources ${CMAKE_CURRENT_SOURCE_DIR}/Masterslave.java  ${CMAKE_CURRENT_SOURCE_DIR}/Forwarder.java
-            ${CMAKE_CURRENT_SOURCE_DIR}/Master.java ${CMAKE_CURRENT_SOURCE_DIR}/FinalizeTask.java  ${CMAKE_CURRENT_SOURCE_DIR}/Slave.java) 
-
-if(enable_java)
-  add_custom_command(
-    COMMENT "Building ${example}..."
-    OUTPUT ${example}_compiled
-    DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
-    COMMAND ${JAVA_COMPILE} -classpath ${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)
-  ADD_TESH(java-masterslave --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/masterslave/masterslave.tesh)
-endif()
-
-set(tesh_files   ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/masterslave.tesh           PARENT_SCOPE)
-set(xml_files    ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/deploy.xml
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/masterslaveDeployment.xml  PARENT_SCOPE)
-set(examples_src ${examples_src}  ${sources}                                             PARENT_SCOPE)
-set(txt_files  ${txt_files}  ${CMAKE_CURRENT_SOURCE_DIR}/README                          PARENT_SCOPE)
diff --git a/examples/java/masterslave/FinalizeTask.java b/examples/java/masterslave/FinalizeTask.java
deleted file mode 100644 (file)
index 8c89aa6..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/* 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 masterslave;
-import org.simgrid.msg.Task;
-
-public class FinalizeTask extends Task {
-   public FinalizeTask() {
-      super("finalize",0,0);
-   }
-}
-
diff --git a/examples/java/masterslave/Forwarder.java b/examples/java/masterslave/Forwarder.java
deleted file mode 100644 (file)
index 3c4542c..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* 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 masterslave;
-
-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 Forwarder extends Process {
-  public Forwarder(Host host, String name, String[]args) {
-    super(host,name,args);
-  }
-  public void main(String[] args) throws MsgException {
-    if (args.length < 3) {
-      Msg.info("Forwarder needs 3 arguments (input mailbox, first output mailbox, last one)");
-      Msg.info("Got "+args.length+" instead");
-      System.exit(1);
-    }
-    int input = Integer.valueOf(args[0]).intValue();    
-    int firstOutput = Integer.valueOf(args[1]).intValue();    
-    int lastOutput = Integer.valueOf(args[2]).intValue();    
-
-    int taskCount = 0;
-    int slavesCount = lastOutput - firstOutput + 1;
-    Msg.info("Receiving on 'slave_"+input+"'");
-    while(true) {
-      Task task = Task.receive("slave_"+input);  
-
-      if (task instanceof FinalizeTask) {
-        Msg.info("Got a finalize task. Let's forward that we're done.");
-
-      for (int cpt = firstOutput; cpt<=lastOutput; cpt++) {
-         Task tf = new FinalizeTask();
-         tf.send("slave_"+cpt);
-      }
-      break;
-    }
-    int dest = firstOutput + (taskCount % slavesCount);
-
-    Msg.info("Sending \"" + task.getName() + "\" to \"slave_" + dest + "\"");
-    task.send("slave_"+dest);
-
-    taskCount++;
-    }
-
-    Msg.info("I'm done. See you!");
-  }
-}
diff --git a/examples/java/masterslave/README b/examples/java/masterslave/README
deleted file mode 100644 (file)
index 9207911..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-This is a somehow basic master/slaves example.
-
-There is 3 kind of processes:
- * Master: creates some tasks, and dispatches them to its slaves
- * Forwarder: get tasks from master, and dispatch them further
- * Slave: get tasks from either master or forwarder, and run them
-At the end of the execution:
- - the master sends FinalizeTask to every known slave to stop them
- - On reception of FT, forwarders send FT to every slave, and stop.
- - On reception of FinalizeTask, slaves stop.
\ No newline at end of file
diff --git a/examples/java/masterslave/deploy.xml b/examples/java/masterslave/deploy.xml
deleted file mode 100644 (file)
index d355b13..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
-  <!-- The master process (with some arguments) -->
-
-  <process host="Jacquelin" function="masterslave.Master">
-     <argument value="10"/>       <!-- Number of tasks -->
-     <argument value="50000000"/>  <!-- Computation size of tasks -->
-     <argument value="1000000"/>   <!-- Communication size of tasks -->
-     <argument value="2"/>  <!-- Number of masterslave.Slaves -->
-  </process>
-  <!-- The masterslave.Slave process (with no argument) -->
-  <process host="Jacquelin" function="masterslave.Slave"><argument value="0"/></process>
-  <process host="Boivin" function="masterslave.Slave" start_time="5"><argument value="1"/></process>
-<!--  <process host="Jean_Yves" function="masterslave.Slave"><argument value="2"/></process>
-  <process host="TeX" function="masterslave.Slave"><argument value="3"/></process>
-  <process host="Geoff" function="masterslave.Slave"><argument value="4"/></process>
-  <process host="Disney" function="masterslave.Slave"><argument value="5"/></process>
-  <process host="iRMX" function="masterslave.Slave"><argument value="6"/></process>
-  <process host="McGee" function="masterslave.Slave"><argument value="7"/></process>
-  <process host="Gatien" function="masterslave.Slave"><argument value="8"/></process>
-  <process host="Laroche" function="masterslave.Slave"><argument value="9"/></process>
-  <process host="Tanguay" function="masterslave.Slave"><argument value="10"/></process>
-  <process host="Morin" function="masterslave.Slave"><argument value="11"/></process>
-  <process host="Ethernet" function="masterslave.Slave"><argument value="12"/></process>
-  <process host="Bellemarre" function="masterslave.Slave"><argument value="13"/></process>
-  <process host="Kuenning" function="masterslave.Slave"><argument value="14"/></process>
-  <process host="Gaston" function="masterslave.Slave"><argument value="15"/></process>
-  <process host="Harry" function="masterslave.Slave"><argument value="16"/></process>
-  <process host="Bousquet" function="masterslave.Slave"><argument value="17"/></process>
-  <process host="Paul" function="masterslave.Slave"><argument value="18"/></process>
-  <process host="St_Jean" function="masterslave.Slave"><argument value="19"/></process>
-  <process host="Jill" function="masterslave.Slave"><argument value="20"/></process>
-  <process host="Marcel" function="masterslave.Slave"><argument value="21"/></process>
-  <process host="Wright" function="masterslave.Slave"><argument value="22"/></process>
-  <process host="Jackson" function="masterslave.Slave"><argument value="23"/></process>
-  <process host="Fernand" function="masterslave.Slave"><argument value="24"/></process>
-  <process host="Soucy" function="masterslave.Slave"><argument value="25"/></process>
-  <process host="Ste_Julie" function="masterslave.Slave"><argument value="26"/></process>
-  <process host="Victoria" function="masterslave.Slave"><argument value="27"/></process>
-  <process host="Lessard" function="masterslave.Slave"><argument value="28"/></process>
-  <process host="Florient" function="masterslave.Slave"><argument value="29"/></process>
-  <process host="Marcoux" function="masterslave.Slave"><argument value="30"/></process>
-  <process host="Gavrel" function="masterslave.Slave"><argument value="31"/></process>
-  <process host="Bescherelle" function="masterslave.Slave"><argument value="32"/></process>
-  <process host="Pierre" function="masterslave.Slave"><argument value="33"/></process>
-  <process host="Jamie" function="masterslave.Slave"><argument value="34"/></process>
-  <process host="Rubin" function="masterslave.Slave"><argument value="35"/></process>
-  <process host="Olivier" function="masterslave.Slave"><argument value="36"/></process>
-  <process host="Boucherville" function="masterslave.Slave"><argument value="37"/></process>
-  <process host="Pointe_Claire" function="masterslave.Slave"><argument value="38"/></process>
-  <process host="Kansas" function="masterslave.Slave"><argument value="39"/></process>
-  <process host="King" function="masterslave.Slave"><argument value="40"/></process>
-  <process host="Lapointe" function="masterslave.Slave"><argument value="41"/></process>
-  <process host="Julian" function="masterslave.Slave"><argument value="42"/></process>
-  <process host="Lafontaine" function="masterslave.Slave"><argument value="43"/></process>
-  <process host="Gordon" function="masterslave.Slave"><argument value="44"/></process>
-  <process host="Drouin" function="masterslave.Slave"><argument value="45"/></process>
-  <process host="Robert" function="masterslave.Slave"><argument value="46"/></process>
-  <process host="Jocelyne" function="masterslave.Slave"><argument value="47"/></process>
-  <process host="Stephen" function="masterslave.Slave"><argument value="48"/></process>
-  <process host="Provost" function="masterslave.Slave"><argument value="49"/></process>
-  <process host="Juneau" function="masterslave.Slave"><argument value="50"/></process>
-  <process host="Casavant" function="masterslave.Slave"><argument value="51"/></process>
-  <process host="St_Antoine" function="masterslave.Slave"><argument value="52"/></process>
-  <process host="Louis" function="masterslave.Slave"><argument value="53"/></process>
-  <process host="Julien" function="masterslave.Slave"><argument value="54"/></process>
-  <process host="St_Paul" function="masterslave.Slave"><argument value="55"/></process>
-  <process host="Mathematica" function="masterslave.Slave"><argument value="56"/></process>
-  <process host="LaTeX" function="masterslave.Slave"><argument value="57"/></process>
-  <process host="Sirois" function="masterslave.Slave"><argument value="58"/></process>
-  <process host="Monique" function="masterslave.Slave"><argument value="59"/></process>
-  <process host="Audy" function="masterslave.Slave"><argument value="60"/></process>
-  <process host="Bourassa" function="masterslave.Slave"><argument value="61"/></process>
-  <process host="OHara" function="masterslave.Slave"><argument value="62"/></process>
-  <process host="Boston" function="masterslave.Slave"><argument value="63"/></process>
-  <process host="Papineau" function="masterslave.Slave"><argument value="64"/></process>
-  <process host="Fraser" function="masterslave.Slave"><argument value="65"/></process>
-  <process host="Browne" function="masterslave.Slave"><argument value="66"/></process>
-  <process host="SunOS" function="masterslave.Slave"><argument value="67"/></process>
-  <process host="Varennes" function="masterslave.Slave"><argument value="68"/></process>
-  <process host="Jacques" function="masterslave.Slave"><argument value="69"/></process>
-  <process host="Thierry" function="masterslave.Slave"><argument value="70"/></process>
-  <process host="Lachapelle" function="masterslave.Slave"><argument value="71"/></process>
-  <process host="kV" function="masterslave.Slave"><argument value="72"/></process>
-  <process host="Yolande" function="masterslave.Slave"><argument value="73"/></process>
-  <process host="Pronovost" function="masterslave.Slave"><argument value="74"/></process>
-  <process host="SPICE" function="masterslave.Slave"><argument value="75"/></process>
-  <process host="Europe" function="masterslave.Slave"><argument value="76"/></process>
-  <process host="Roy" function="masterslave.Slave"><argument value="77"/></process>
-  <process host="Amadeus" function="masterslave.Slave"><argument value="78"/></process>
-  <process host="Intel" function="masterslave.Slave"><argument value="79"/></process>
-  <process host="Cambridge" function="masterslave.Slave"><argument value="80"/></process>
-  <process host="Tremblay" function="masterslave.Slave"><argument value="81"/></process>
-  <process host="UNIX" function="masterslave.Slave"><argument value="82"/></process>
-  <process host="Domey" function="masterslave.Slave"><argument value="83"/></process>
-  <process host="St_Bruno" function="masterslave.Slave"><argument value="84"/></process>
-  <process host="Jean_Claude" function="masterslave.Slave"><argument value="85"/></process>
-  <process host="Doyon" function="masterslave.Slave"><argument value="86"/></process>
-  <process host="Fafard" function="masterslave.Slave"><argument value="87"/></process>
-  <process host="Croteau" function="masterslave.Slave"><argument value="88"/></process>
-  <process host="Dodge" function="masterslave.Slave"><argument value="89"/></process>
-  <process host="Jacquelin" function="masterslave.Slave"><argument value="90"/></process>
-  <process host="Boivin" function="masterslave.Slave"><argument value="91"/></process>
-  <process host="Jean_Yves" function="masterslave.Slave"><argument value="92"/></process>
-  <process host="TeX" function="masterslave.Slave"><argument value="93"/></process>
-  <process host="Geoff" function="masterslave.Slave"><argument value="94"/></process>
-  <process host="Disney" function="masterslave.Slave"><argument value="95"/></process>
-  <process host="iRMX" function="masterslave.Slave"><argument value="96"/></process>
-  <process host="McGee" function="masterslave.Slave"><argument value="97"/></process>
-  <process host="Gatien" function="masterslave.Slave"><argument value="98"/></process>
-  <process host="Laroche" function="masterslave.Slave"><argument value="99"/></process>
-  <process host="Tanguay" function="masterslave.Slave"><argument value="100"/></process> -->
-</platform>
diff --git a/examples/java/masterslave/masterslave.tesh b/examples/java/masterslave/masterslave.tesh
deleted file mode 100644 (file)
index 189988d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#! tesh
-
-! output sort 19
-
-$ java -classpath ${classpath:=.} masterslave/Masterslave ${srcdir:=.}/../platforms/platform.xml ${srcdir:=.}/masterslave/masterslaveDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [  0.000000] (0:maestro@) Using regular java threads.
-> [  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.851467] (2:masterslave.Forwarder@Jackson) Sending "Task_0" to "slave_7"
-> [  2.208482] (3:masterslave.Forwarder@Casavant) Sending "Task_1" to "slave_9"
-> [  2.720407] (11:masterslave.Slave@Sirois) Received "Task_1". Processing it.
-> [  3.553979] (9:masterslave.Slave@Stephen) Received "Task_0". Processing it.
-> [  5.252157] (4:masterslave.Slave@iRMX) Received "Task_2". Processing it.
-> [  6.266855] (5:masterslave.Slave@Bousquet) Received "Task_3". Processing it.
-> [  7.710549] (1:masterslave.Master@Jacquelin) All tasks have been dispatched. Let's tell everybody the computation is over.
-> [  7.710549] (6:masterslave.Slave@Soucy) Received "Task_4". Processing it.
-> [  8.562012] (2:masterslave.Forwarder@Jackson) Got a finalize task. Let's forward that we're done.
-> [  9.919019] (3:masterslave.Forwarder@Casavant) Got a finalize task. Let's forward that we're done.
-> [ 10.430937] (11:masterslave.Slave@Sirois) Received Finalize. I'm done. See you!
-> [ 11.264486] (9:masterslave.Slave@Stephen) Received Finalize. I'm done. See you!
-> [ 11.318423] (12:masterslave.Slave@Monique) Received Finalize. I'm done. See you!
-> [ 11.318423] (3:masterslave.Forwarder@Casavant) I'm done. See you!
-> [ 12.962677] (4:masterslave.Slave@iRMX) Received Finalize. I'm done. See you!
-> [ 13.907575] (10:masterslave.Slave@Robert) Received Finalize. I'm done. See you!
-> [ 13.907575] (2:masterslave.Forwarder@Jackson) I'm done. See you!
-> [ 13.977355] (5:masterslave.Slave@Bousquet) Received Finalize. I'm done. See you!
-> [ 15.421041] (6:masterslave.Slave@Soucy) Received Finalize. I'm done. See you!
-> [ 16.278350] (7:masterslave.Slave@Kuenning) Received Finalize. I'm done. See you!
-> [ 17.251680] (0:maestro@) MSG_main finished; Cleaning up the simulation...
-> [ 17.251680] (1:masterslave.Master@Jacquelin) Goodbye now!
-> [ 17.251680] (8:masterslave.Slave@Browne) Received Finalize. I'm done. See you!
diff --git a/examples/java/masterslave/masterslaveDeployment.xml b/examples/java/masterslave/masterslaveDeployment.xml
deleted file mode 100644 (file)
index 5f249f1..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
-  <process host="Jacquelin" function="masterslave.Master">
-     <argument value="5"/>     <!-- Amount of tasks to dispatch -->
-     <argument value="50000"/> <!-- Computation size of each task -->
-     <argument value="10"/>    <!-- Communication size of each one -->
-     <argument value="7"/>     <!-- Amount of slaves waiting for orders -->
-  </process>
-
-  <process host="Jackson" function="masterslave.Forwarder">
-     <argument value="0"/>  <!-- Input mailbox -->
-     <argument value="7"/>  <!-- First output mailbox -->
-     <argument value="8"/>  <!-- Last output mailbox -->
-  </process>
-  <process host="Casavant" function="masterslave.Forwarder">
-     <argument value="1"/>  <!-- Input mailbox -->
-     <argument value="9"/>  <!-- First output mailbox -->
-     <argument value="10"/> <!-- Last output mailbox -->
-  </process>
-
-  <process host="iRMX" function="masterslave.Slave">      <argument value="2"/>  <!-- Input mailbox --> </process>
-  <process host="Bousquet" function="masterslave.Slave">  <argument value="3"/>  <!-- Input mailbox --> </process>
-  <process host="Soucy" function="masterslave.Slave">     <argument value="4"/>  <!-- Input mailbox --> </process>
-  <process host="Kuenning" function="masterslave.Slave">  <argument value="5"/>  <!-- Input mailbox --> </process>
-  <process host="Browne" function="masterslave.Slave">    <argument value="6"/>  <!-- Input mailbox --> </process>
-  <process host="Stephen" function="masterslave.Slave">   <argument value="7"/>  <!-- Input mailbox --> </process>
-  <process host="Robert" function="masterslave.Slave">    <argument value="8"/>  <!-- Input mailbox --> </process>
-  <process host="Sirois" function="masterslave.Slave">    <argument value="9"/>  <!-- Input mailbox --> </process>
-  <process host="Monique" function="masterslave.Slave">   <argument value="10"/> <!-- Input mailbox --> </process>
-</platform>
diff --git a/examples/java/masterworker/CMakeLists.txt b/examples/java/masterworker/CMakeLists.txt
new file mode 100644 (file)
index 0000000..54ad08f
--- /dev/null
@@ -0,0 +1,20 @@
+set(example java_masterworker)
+set(sources ${CMAKE_CURRENT_SOURCE_DIR}/Main.java  ${CMAKE_CURRENT_SOURCE_DIR}/Master.java ${CMAKE_CURRENT_SOURCE_DIR}/Worker.java) 
+
+if(enable_java)
+  add_custom_command(
+    COMMENT "Building ${example}..."
+    OUTPUT ${example}_compiled
+    DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
+    COMMAND ${JAVA_COMPILE} -classpath ${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)
+  ADD_TESH(java-masterworker --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/masterworker/masterworker.tesh)
+endif()
+
+set(tesh_files   ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/masterworker.tesh           PARENT_SCOPE)
+set(xml_files    ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/masterworkerDeployment.xml  PARENT_SCOPE)
+set(examples_src ${examples_src}  ${sources}                                              PARENT_SCOPE)
+set(txt_files    ${txt_files}  ${CMAKE_CURRENT_SOURCE_DIR}/README                         PARENT_SCOPE)
similarity index 93%
rename from examples/java/masterslave/Masterslave.java
rename to examples/java/masterworker/Main.java
index 236b97d..289c932 100644 (file)
@@ -4,14 +4,14 @@
 /* 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;
+package masterworker;
 
 import java.io.File;
 
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.NativeException;
 
-public class Masterslave {
+public class Main {
   public static final int TASK_COMP_SIZE = 10000000;
   public static final int TASK_COMM_SIZE = 10000000;
   /* This only contains the launcher. If you do nothing more than than you can run java simgrid.msg.Msg
@@ -23,7 +23,7 @@ public class Masterslave {
     Msg.init(args);
 
     String platf  = args.length > 1 ? args[0] : "examples/java/platform.xml";
-    String deploy =  args.length > 1 ? args[1] : "examples/java/masterslave/masterslaveDeployment.xml";
+    String deploy =  args.length > 1 ? args[1] : "examples/java/masterworker/masterworkerDeployment.xml";
 
     Msg.verb("Platform: "+platf+"; Deployment:"+deploy+"; Current directory: "+new File(".").getAbsolutePath());
 
similarity index 73%
rename from examples/java/masterslave/Master.java
rename to examples/java/masterworker/Master.java
index b3ce6d1..ea4589a 100644 (file)
@@ -6,7 +6,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 masterslave;
+package masterworker;
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
@@ -27,21 +27,21 @@ public class Master extends Process {
     double taskComputeSize = Double.valueOf(args[1]).doubleValue();
     double taskCommunicateSize = Double.valueOf(args[2]).doubleValue();
 
-    int slavesCount = Integer.valueOf(args[3]).intValue();
+    int workersCount = Integer.valueOf(args[3]).intValue();
 
-    Msg.info("Hello! Got "+  slavesCount + " slaves and "+tasksCount+" tasks to process");
+    Msg.info("Hello! Got "+  workersCount + " workers and "+tasksCount+" tasks to process");
 
     for (int i = 0; i < tasksCount; i++) {
       Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize); 
-      //Msg.info("Sending \"" + task.getName()+ "\" to \"slave_" + i % slavesCount + "\"");
-      task.send("slave_"+(i%slavesCount));
+      //Msg.info("Sending \"" + task.getName()+ "\" to \"worker_" + i % workersCount + "\"");
+      task.send("worker_"+(i%workersCount));
     }
 
     Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over.");
 
-    for (int i = 0; i < slavesCount; i++) {
-      FinalizeTask task = new FinalizeTask();
-      task.send("slave_"+(i%slavesCount));
+    for (int i = 0; i < workersCount; i++) {
+      Task task = new Task("finalize", 0, 0);
+      task.send("worker_"+(i%workersCount));
     }
 
     Msg.info("Goodbye now!");
diff --git a/examples/java/masterworker/README b/examples/java/masterworker/README
new file mode 100644 (file)
index 0000000..14bc4c4
--- /dev/null
@@ -0,0 +1,9 @@
+This is a somehow basic master/workers example.
+
+There is 2 kind of processes:
+ * Master: creates some tasks, and dispatches them to its slaves
+ * Worker: get tasks from the master and run them
+
+At the end of the execution:
+ - the master sends a Task whose name is "finalize" to every known worker to stop them
+ - On reception of such tasks workers stop.
\ No newline at end of file
similarity index 81%
rename from examples/java/masterslave/Slave.java
rename to examples/java/masterworker/Worker.java
index c2ffe37..b681e4a 100644 (file)
@@ -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 masterslave;
+package masterworker;
 
 import org.simgrid.msg.Host;
 import org.simgrid.msg.HostFailureException;
@@ -15,13 +15,13 @@ import org.simgrid.msg.TimeoutException;
 import org.simgrid.msg.TransferFailureException;
 import org.simgrid.msg.Process;
 
-public class Slave extends Process {
-  public Slave(Host host, String name, String[]args) {
+public class Worker extends Process {
+  public Worker(Host host, String name, String[]args) {
     super(host,name,args);
   }
   public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
     if (args.length < 1) {
-      Msg.info("Slave needs 1 argument (its number)");
+      Msg.info("Worker needs 1 argument (its number)");
       System.exit(1);
     }
 
@@ -29,9 +29,9 @@ public class Slave extends Process {
     //Msg.info("Receiving on 'slave_"+num+"'");
 
     while(true) {  
-      Task task = Task.receive("slave_"+num);  
+      Task task = Task.receive("worker_"+num);
 
-      if (task instanceof FinalizeTask) {
+      if (task.getName().equals("finalize")) {
         break;
       }
       Msg.info("Received \"" + task.getName() +  "\". Processing it.");
diff --git a/examples/java/masterworker/masterworker.tesh b/examples/java/masterworker/masterworker.tesh
new file mode 100644 (file)
index 0000000..47a2e68
--- /dev/null
@@ -0,0 +1,23 @@
+#! tesh
+
+! output sort 19
+
+$ java -classpath ${classpath:=.} masterworker/Main ${srcdir:=.}/../platforms/platform.xml ${srcdir:=.}/masterworker/masterworkerDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:maestro@) Using regular java threads.
+> [  0.000000] (1:masterworker.Master@Jacquelin) Hello! Got 7 workers and 5 tasks to process
+> [  3.043675] (2:masterworker.Worker@iRMX) Received "Task_0". Processing it.
+> [  4.058373] (3:masterworker.Worker@Bousquet) Received "Task_1". Processing it.
+> [  5.502067] (4:masterworker.Worker@Soucy) Received "Task_2". Processing it.
+> [  6.359383] (5:masterworker.Worker@Kuenning) Received "Task_3". Processing it.
+> [  7.332717] (1:masterworker.Master@Jacquelin) All tasks have been dispatched. Let's tell everybody the computation is over.
+> [  7.332717] (6:masterworker.Worker@Browne) Received "Task_4". Processing it.
+> [ 10.376375] (2:masterworker.Worker@iRMX) Received Finalize. I'm done. See you!
+> [ 11.391053] (3:masterworker.Worker@Bousquet) Received Finalize. I'm done. See you!
+> [ 12.834740] (4:masterworker.Worker@Soucy) Received Finalize. I'm done. See you!
+> [ 13.692048] (5:masterworker.Worker@Kuenning) Received Finalize. I'm done. See you!
+> [ 14.665378] (6:masterworker.Worker@Browne) Received Finalize. I'm done. See you!
+> [ 16.536717] (7:masterworker.Worker@Stephen) Received Finalize. I'm done. See you!
+> [ 18.348671] (0:maestro@) MSG_main finished; Cleaning up the simulation...
+> [ 18.348671] (1:masterworker.Master@Jacquelin) Goodbye now!
+> [ 18.348671] (8:masterworker.Worker@Robert) Received Finalize. I'm done. See you!
+
diff --git a/examples/java/masterworker/masterworkerDeployment.xml b/examples/java/masterworker/masterworkerDeployment.xml
new file mode 100644 (file)
index 0000000..a2cb8ff
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
+<platform version="4">
+  <process host="Jacquelin" function="masterworker.Master">
+     <argument value="5"/>     <!-- Amount of tasks to dispatch -->
+     <argument value="50000"/> <!-- Computation size of each task -->
+     <argument value="10"/>    <!-- Communication size of each one -->
+     <argument value="7"/>     <!-- Amount of workers waiting for orders -->
+  </process>
+
+  <process host="iRMX" function="masterworker.Worker">      <argument value="0"/>  <!-- Input mailbox --> </process>
+  <process host="Bousquet" function="masterworker.Worker">  <argument value="1"/>  <!-- Input mailbox --> </process>
+  <process host="Soucy" function="masterworker.Worker">     <argument value="2"/>  <!-- Input mailbox --> </process>
+  <process host="Kuenning" function="masterworker.Worker">  <argument value="3"/>  <!-- Input mailbox --> </process>
+  <process host="Browne" function="masterworker.Worker">    <argument value="4"/>  <!-- Input mailbox --> </process>
+  <process host="Stephen" function="masterworker.Worker">   <argument value="5"/>  <!-- Input mailbox --> </process>
+  <process host="Robert" function="masterworker.Worker">    <argument value="6"/>  <!-- Input mailbox --> </process>
+</platform>
index bff93d0..c725a9b 100644 (file)
@@ -934,7 +934,7 @@ set(CMAKEFILES_TXT
   examples/java/io/CMakeLists.txt
   examples/java/kademlia/CMakeLists.txt
   examples/java/master_slave_kill/CMakeLists.txt
-  examples/java/masterslave/CMakeLists.txt
+  examples/java/masterworker/CMakeLists.txt
   examples/java/migration/CMakeLists.txt
   examples/java/mutualExclusion/CMakeLists.txt
   examples/java/pingPong/CMakeLists.txt