Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make a REAL and simple dsend test
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 1 Apr 2016 09:15:49 +0000 (11:15 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 1 Apr 2016 09:15:49 +0000 (11:15 +0200)
15 files changed:
.gitignore
examples/java/CMakeLists.txt
examples/java/async/CMakeLists.txt [deleted file]
examples/java/async/FinalizeTask.java [deleted file]
examples/java/async/Forwarder.java [deleted file]
examples/java/async/Master.java [deleted file]
examples/java/async/README [deleted file]
examples/java/async/Slave.java [deleted file]
examples/java/async/async.tesh [deleted file]
examples/java/async/asyncDeployment.xml [deleted file]
examples/java/async/dsend/Main.java [moved from examples/java/async/AsyncTest.java with 51% similarity]
examples/java/async/dsend/Receiver.java [new file with mode: 0644]
examples/java/async/dsend/Sender.java [new file with mode: 0644]
examples/java/async/dsend/async_dsend.tesh [new file with mode: 0644]
tools/cmake/DefinePackages.cmake

index 5242aee..2f8b7eb 100644 (file)
@@ -974,7 +974,7 @@ examples/java/app/bittorrent/java_app_bittorrent_compiled
 examples/java/app/centralizedmutex/java_app_centralizedmutex_compiled
 examples/java/app/masterworker/java_app_masterworker_compiled
 examples/java/app/pingpong/java_app_pingpong_compiled
-examples/java/async/java_async_compiled
+examples/java/async/dsend/java_async_dsend_compiled
 examples/java/dht/chord/java_dht_chord_compiled
 examples/java/dht/kademlia/java_dht_kademlia_compiled
 examples/java/cloud/masterworker/java_cloud_masterworker_compiled
index 5cb858a..bcc30d7 100644 (file)
@@ -14,6 +14,9 @@ set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/app/pingpong)
 set(app_pingpong_sources       ${srcdir}/Main.java  ${srcdir}/PingPongTask.java ${srcdir}/Receiver.java 
                                ${srcdir}/Sender.java) 
 
+set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/async/dsend)
+set(async_dsend_sources        ${srcdir}/Main.java  ${srcdir}/Receiver.java ${srcdir}/Sender.java)
+
 set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/cloud/masterworker)
 set(cloud_masterworker_sources ${srcdir}/Main.java  ${srcdir}/Master.java ${srcdir}/Worker.java)
 
@@ -64,9 +67,9 @@ set(process_suspend_sources    ${srcdir}/Main.java  ${srcdir}/DreamMaster.java
 set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}/task/priority)
 set(task_priority_sources      ${srcdir}/Main.java  ${srcdir}/Test.java)
 
-foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong cloud_migration cloud_masterworker 
-         dht_chord dht_kademlia energy_consumption energy_vm io_file io_storage process_kill process_migration
-         process_startkilltime process_suspend task_priority trace_pingpong)
+foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong async_dsend
+         cloud_migration cloud_masterworker dht_chord dht_kademlia energy_consumption energy_vm io_file io_storage 
+         process_kill process_migration process_startkilltime process_suspend task_priority trace_pingpong)
   string (REPLACE "_" "/" example_dir ${example})
   if(enable_java)
     add_custom_command(
@@ -84,9 +87,9 @@ foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpo
   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example_dir}/${example}.tesh)
 endforeach()
 
-set(examples_src  ${examples_src}                                                          PARENT_SCOPE)
-set(tesh_files    ${tesh_files}                                                            PARENT_SCOPE)
-set(bin_files     ${bin_files}     ${CMAKE_CURRENT_SOURCE_DIR}/app/bittorrent/generate.py  PARENT_SCOPE)
+set(examples_src  ${examples_src}                                                                          PARENT_SCOPE)
+set(tesh_files    ${tesh_files}                                                                            PARENT_SCOPE)
+set(bin_files     ${bin_files}     ${CMAKE_CURRENT_SOURCE_DIR}/app/bittorrent/generate.py                  PARENT_SCOPE)
 set(txt_files     ${txt_files}     ${CMAKE_CURRENT_SOURCE_DIR}/app/masterworker/README
                                    ${CMAKE_CURRENT_SOURCE_DIR}/cloud/migration/README                      PARENT_SCOPE)
 set(xml_files     ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/app/bittorrent/bittorrent.xml
@@ -98,9 +101,9 @@ set(xml_files     ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/app/bittorrent/bi
                                    ${CMAKE_CURRENT_SOURCE_DIR}/task/priority/priority.xml                  PARENT_SCOPE)
 
 if(enable_java)
-  foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong cloud_migration cloud_masterworker 
-           dht_chord dht_kademlia energy_consumption energy_vm io_file io_storage process_kill process_migration
-           process_startkilltime process_suspend task_priority trace_pingpong)
+  foreach (example app_bittorrent app_centralizedmutex app_masterworker app_pingpong async_dsend
+           cloud_migration cloud_masterworker dht_chord dht_kademlia energy_consumption energy_vm io_file io_storage 
+           process_kill process_migration process_startkilltime process_suspend task_priority trace_pingpong)
     string (REPLACE "_" "/" example_dir ${example})
     ADD_TESH(java-${example}  --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/${example_dir}/${example}.tesh)
   endforeach()
diff --git a/examples/java/async/CMakeLists.txt b/examples/java/async/CMakeLists.txt
deleted file mode 100644 (file)
index 4167099..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-set(example java_async)
-set(sources ${CMAKE_CURRENT_SOURCE_DIR}/AsyncTest.java  ${CMAKE_CURRENT_SOURCE_DIR}/FinalizeTask.java
-            ${CMAKE_CURRENT_SOURCE_DIR}/Forwarder.java  ${CMAKE_CURRENT_SOURCE_DIR}/Master.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-async --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/async/async.tesh)
-endif()
-
-
-set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/async.tesh           PARENT_SCOPE)
-set(xml_files     ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/asyncDeployment.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/async/FinalizeTask.java b/examples/java/async/FinalizeTask.java
deleted file mode 100644 (file)
index 39b1a4f..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Copyright (c) 2006-2014, 2016. 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 async;
-import org.simgrid.msg.Task;
-
-public class FinalizeTask extends Task {
-  public FinalizeTask() {
-    super("finalize",0,0);
-  }
-}
diff --git a/examples/java/async/Forwarder.java b/examples/java/async/Forwarder.java
deleted file mode 100644 (file)
index 965bb8c..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright (c) 2006-2014, 2016. 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 async;
-import org.simgrid.msg.Msg;
-import org.simgrid.msg.Host;
-import org.simgrid.msg.Task;
-import org.simgrid.msg.Process;
-import org.simgrid.msg.MsgException;
-
-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 (asynchronously) that we're done, and then sleep 20 seconds"+
-                 " so that nobody gets a message from a terminated process.");
-
-        for (int cpt = firstOutput; cpt<=lastOutput; cpt++) {
-          Task tf = new FinalizeTask();
-          tf.dsend("slave_"+cpt);
-        }
-        waitFor(20);
-        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/async/Master.java b/examples/java/async/Master.java
deleted file mode 100644 (file)
index 19e66ea..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright (c) 2006-2014, 2016. 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 async;
-import java.util.ArrayList;
-
-import org.simgrid.msg.Msg;
-import org.simgrid.msg.Comm;
-import org.simgrid.msg.Host;
-import org.simgrid.msg.Task;
-import org.simgrid.msg.Process;
-import org.simgrid.msg.MsgException;
-
-public class Master extends Process {
-  public Master(Host host, String name, String[]args) {
-    super(host,name,args);
-  }
-
-  public void main(String[] args) throws MsgException {
-    if (args.length < 4) {
-      Msg.info("Master needs 4 arguments");
-      System.exit(1);
-    }
-
-    int tasksCount = Integer.valueOf(args[0]).intValue();    
-    double taskComputeSize = Double.valueOf(args[1]).doubleValue();    
-    double taskCommunicateSize = Double.valueOf(args[2]).doubleValue();
-
-    int slavesCount = Integer.valueOf(args[3]).intValue();
-
-    Msg.info("Hello! Got "+  slavesCount + " slaves and "+tasksCount+" tasks to process");
-    ArrayList<Comm> comms = new ArrayList<Comm>();
-
-    for (int i = 0; i < tasksCount; i++) {
-      Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize); 
-      Msg.info("Sending \"" + task.getName()+ "\" to \"slave_" + i % slavesCount + "\"");
-      Comm comm = task.isend("slave_"+(i%slavesCount));
-      comms.add(comm);
-    }
-
-    while (comms.size() > 0) {
-      for (int i = 0; i < comms.size(); i++) {
-        try {
-          if (comms.get(i).test()) {
-            comms.remove(i);
-            i--;
-          }
-        }
-        catch (Exception e) {
-          e.printStackTrace();
-        }
-      }
-      waitFor(1);
-    }
-    Msg.info("All tasks have been dispatched. Let's tell (asynchronously) everybody the computation is over,"+
-             " and sleep 20s so that nobody gets a message from a terminated process.");
-
-    for (int i = 0; i < slavesCount; i++) {
-      FinalizeTask task = new FinalizeTask();
-      task.dsend("slave_"+(i%slavesCount));
-    }
-    waitFor(20);
-
-    Msg.info("Goodbye now!");
-  }
-}
diff --git a/examples/java/async/README b/examples/java/async/README
deleted file mode 100644 (file)
index 0d6dcc2..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-This is another version of the master/slaves example, using asynchronous communications.
-
-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,
-   using dsend instead of send. That's non-blocking with no way to
-   know if/when the communication succeeds. It is intended for
-   communications where you don't care to know whether your message got 
-   received or not. The process then sleeps 20 seconds because we have
-   a strange bug for now when the receiver gets a message from a
-   terminated process. This should not be the case, actually, that's a
-   JAVA specific bug, but I don't really have the time to dig in right
-   now.
-
- - On reception of FT, forwarders dsend FT to every slave, and stop
-   after a little while.
- - On reception of FinalizeTask, slaves stop.
-Other non-blocking primitives will get used here as soon as they are 
-added to the bindings.
\ No newline at end of file
diff --git a/examples/java/async/Slave.java b/examples/java/async/Slave.java
deleted file mode 100644 (file)
index 3d32d2a..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Copyright (c) 2006-2007, 2010, 2013-2014, 2016. 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 async;
-import org.simgrid.msg.Msg;
-import org.simgrid.msg.Comm;
-import org.simgrid.msg.Host;
-import org.simgrid.msg.Task;
-import org.simgrid.msg.Process;
-import org.simgrid.msg.HostFailureException;
-import org.simgrid.msg.TaskCancelledException;
-import org.simgrid.msg.TimeoutException;
-import org.simgrid.msg.TransferFailureException;
-
-public class Slave extends Process {
-  public Slave(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)");
-      System.exit(1);
-    }
-    int num = Integer.valueOf(args[0]).intValue();
-    Comm comm = null;
-    boolean slaveFinished = false;
-    while(!slaveFinished) {  
-      try {
-        if (comm == null) {
-          Msg.info("Receiving on 'slave_" + num + "'");
-          comm = Task.irecv("slave_" + num);
-        } else {
-          if (comm.test()) {
-            Task task = comm.getTask();
-
-            if (task instanceof FinalizeTask) {
-              comm = null;
-              break;
-            }
-            Msg.info("Received a task");
-            Msg.info("Received \"" + task.getName() +  "\". Processing it.");
-            try {
-              task.execute();
-            } catch (TaskCancelledException e) {
-            
-            }
-            comm = null;
-          } else {
-            waitFor(1);
-          }
-        }
-      }
-      catch (Exception e) {
-        e.printStackTrace();
-      }
-    }
-    Msg.info("Received Finalize. I'm done. See you!");
-    waitFor(20);
-  }
-}
\ No newline at end of file
diff --git a/examples/java/async/async.tesh b/examples/java/async/async.tesh
deleted file mode 100644 (file)
index 8a33bbb..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#! tesh
-
-! output sort 19
-! timeout 30
-$ java -classpath ${classpath:=.} async/AsyncTest ${srcdir:=.}/../platforms/platform.xml ${srcdir:=.}/async/asyncDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [  0.000000] (0:maestro@) Using regular java threads.
-> [  0.000000] (10:async.Slave@Robert) Receiving on 'slave_8'
-> [  0.000000] (11:async.Slave@Sirois) Receiving on 'slave_9'
-> [  0.000000] (12:async.Slave@Monique) Receiving on 'slave_10'
-> [  0.000000] (1:async.Master@Jacquelin) Hello! Got 7 slaves and 5 tasks to process
-> [  0.000000] (1:async.Master@Jacquelin) Sending "Task_0" to "slave_0"
-> [  0.000000] (1:async.Master@Jacquelin) Sending "Task_1" to "slave_1"
-> [  0.000000] (1:async.Master@Jacquelin) Sending "Task_2" to "slave_2"
-> [  0.000000] (1:async.Master@Jacquelin) Sending "Task_3" to "slave_3"
-> [  0.000000] (1:async.Master@Jacquelin) Sending "Task_4" to "slave_4"
-> [  0.000000] (2:async.Forwarder@Jackson) Receiving on 'slave_0'
-> [  0.000000] (3:async.Forwarder@Casavant) Receiving on 'slave_1'
-> [  0.000000] (4:async.Slave@iRMX) Receiving on 'slave_2'
-> [  0.000000] (5:async.Slave@Bousquet) Receiving on 'slave_3'
-> [  0.000000] (6:async.Slave@Soucy) Receiving on 'slave_4'
-> [  0.000000] (7:async.Slave@Kuenning) Receiving on 'slave_5'
-> [  0.000000] (8:async.Slave@Browne) Receiving on 'slave_6'
-> [  0.000000] (9:async.Slave@Stephen) Receiving on 'slave_7'
-> [  0.851467] (2:async.Forwarder@Jackson) Sending "Task_0" to "slave_7"
-> [  1.357014] (3:async.Forwarder@Casavant) Sending "Task_1" to "slave_9"
-> [  2.000000] (11:async.Slave@Sirois) Received a task
-> [  2.000000] (11:async.Slave@Sirois) Received "Task_1". Processing it.
-> [  2.000000] (5:async.Slave@Bousquet) Received a task
-> [  2.000000] (5:async.Slave@Bousquet) Received "Task_3". Processing it.
-> [  2.000000] (6:async.Slave@Soucy) Received a task
-> [  2.000000] (6:async.Slave@Soucy) Received "Task_4". Processing it.
-> [  2.000364] (6:async.Slave@Soucy) Receiving on 'slave_4'
-> [  2.000437] (11:async.Slave@Sirois) Receiving on 'slave_9'
-> [  2.001165] (5:async.Slave@Bousquet) Receiving on 'slave_3'
-> [  4.000000] (4:async.Slave@iRMX) Received a task
-> [  4.000000] (4:async.Slave@iRMX) Received "Task_2". Processing it.
-> [  4.000000] (9:async.Slave@Stephen) Received a task
-> [  4.000000] (9:async.Slave@Stephen) Received "Task_0". Processing it.
-> [  4.000728] (4:async.Slave@iRMX) Receiving on 'slave_2'
-> [  4.000728] (9:async.Slave@Stephen) Receiving on 'slave_7'
-> [  5.000000] (1:async.Master@Jacquelin) All tasks have been dispatched. Let's tell (asynchronously) everybody the computation is over, and sleep 20s so that nobody gets a message from a terminated process.
-> [  5.851463] (2:async.Forwarder@Jackson) Got a finalize task. Let's forward (asynchronously) that we're done, and then sleep 20 seconds so that nobody gets a message from a terminated process.
-> [  6.000000] (7:async.Slave@Kuenning) Received Finalize. I'm done. See you!
-> [  6.000000] (8:async.Slave@Browne) Received Finalize. I'm done. See you!
-> [  6.357007] (3:async.Forwarder@Casavant) Got a finalize task. Let's forward (asynchronously) that we're done, and then sleep 20 seconds so that nobody gets a message from a terminated process.
-> [  7.000364] (6:async.Slave@Soucy) Received Finalize. I'm done. See you!
-> [  7.000437] (11:async.Slave@Sirois) Received Finalize. I'm done. See you!
-> [  7.001165] (5:async.Slave@Bousquet) Received Finalize. I'm done. See you!
-> [  8.000000] (12:async.Slave@Monique) Received Finalize. I'm done. See you!
-> [  9.000000] (10:async.Slave@Robert) Received Finalize. I'm done. See you!
-> [  9.000728] (4:async.Slave@iRMX) Received Finalize. I'm done. See you!
-> [  9.000728] (9:async.Slave@Stephen) Received Finalize. I'm done. See you!
-> [ 25.000000] (1:async.Master@Jacquelin) Goodbye now!
-> [ 25.851463] (2:async.Forwarder@Jackson) I'm done. See you!
-> [ 26.357007] (3:async.Forwarder@Casavant) I'm done. See you!
-> [ 29.000728] (0:maestro@) MSG_main finished; Cleaning up the simulation...
diff --git a/examples/java/async/asyncDeployment.xml b/examples/java/async/asyncDeployment.xml
deleted file mode 100644 (file)
index 7ef4d13..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
-  <process host="Jacquelin" function="async.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="async.Forwarder">
-     <argument value="0"/>  <!-- Input mailbox -->
-     <argument value="7"/>  <!-- First output mailbox -->
-     <argument value="8"/>  <!-- Last output mailbox -->
-  </process>
-  <process host="Casavant" function="async.Forwarder">
-     <argument value="1"/>  <!-- Input mailbox -->
-     <argument value="9"/>  <!-- First output mailbox -->
-     <argument value="10"/> <!-- Last output mailbox -->
-  </process>
-
-  <process host="iRMX" function="async.Slave">
-     <argument value="2"/>  <!-- Input mailbox -->
-  </process>
-  <process host="Bousquet" function="async.Slave">
-     <argument value="3"/>  <!-- Input mailbox -->
-  </process>  
-  <process host="Soucy" function="async.Slave">
-     <argument value="4"/>  <!-- Input mailbox -->
-  </process>  
-  <process host="Kuenning" function="async.Slave">
-     <argument value="5"/>  <!-- Input mailbox -->
-  </process>  
-  <process host="Browne" function="async.Slave">
-     <argument value="6"/>  <!-- Input mailbox -->
-  </process>  
-  <process host="Stephen" function="async.Slave">
-     <argument value="7"/>  <!-- Input mailbox -->
-  </process>  
-  <process host="Robert" function="async.Slave">
-     <argument value="8"/>  <!-- Input mailbox -->
-  </process>  
-  <process host="Sirois" function="async.Slave">
-     <argument value="9"/>  <!-- Input mailbox -->
-  </process>  
-  <process host="Monique" function="async.Slave">
-     <argument value="10"/>  <!-- Input mailbox -->
-  </process>  
-</platform>
similarity index 51%
rename from examples/java/async/AsyncTest.java
rename to examples/java/async/dsend/Main.java
index 0c6d1fe..09d441a 100644 (file)
@@ -4,25 +4,30 @@
 /* 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 async;
+package async.dsend;
 
 import org.simgrid.msg.Msg;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.NativeException;
+import org.simgrid.msg.HostNotFoundException;
 
-public class AsyncTest {
-  public static void main(String[] args) throws NativeException {
+public class Main {
+  public static void main(String[] args) throws NativeException, HostNotFoundException {
     Msg.init(args);
 
-    if (args.length < 2) {
-    Msg.info("Usage   : AsyncTest platform_file deployment_file");
-    Msg.info("example : AsyncTest ../platforms/platform.xml asyncDeployment.xml");
+    if (args.length < 1) {
+    Msg.info("Usage   : Main platform_file");
+    Msg.info("example : Main ../platforms/small_platform.xml");
     System.exit(1);
   }
 
     /* construct the platform and deploy the application */
     Msg.createEnvironment(args[0]);
-    Msg.deployApplication(args[1]);
-
+    Host[] hosts = Host.all();
+    new Sender(hosts[0],"Sender").start();
+    for (int i=1; i < hosts.length; i++){
+      new Receiver(hosts[i], "Receiver").start();
+    }
     /*  execute the simulation. */
     Msg.run();
   }
diff --git a/examples/java/async/dsend/Receiver.java b/examples/java/async/dsend/Receiver.java
new file mode 100644 (file)
index 0000000..4f6c3f0
--- /dev/null
@@ -0,0 +1,28 @@
+/* Copyright (c) 2006-2007, 2010, 2013-2014, 2016. 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 async.dsend;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Comm;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.HostFailureException;
+import org.simgrid.msg.TaskCancelledException;
+import org.simgrid.msg.TimeoutException;
+import org.simgrid.msg.TransferFailureException;
+
+public class Receiver extends Process {
+  public Receiver (Host host, String name) {
+    super(host,name);
+  }
+
+  public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
+    Msg.info("Receiving on '"+ getHost().getName() + "'");
+    Task.receive(getHost().getName());
+    Msg.info("Received a task. I'm done. See you!");
+  }
+}
\ No newline at end of file
diff --git a/examples/java/async/dsend/Sender.java b/examples/java/async/dsend/Sender.java
new file mode 100644 (file)
index 0000000..d80429a
--- /dev/null
@@ -0,0 +1,43 @@
+/* Copyright (c) 2006-2014, 2016. 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 async.dsend;
+import java.util.ArrayList;
+
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Comm;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
+
+public class Sender extends Process {
+  public Sender (Host host, String name){
+    super(host,name);
+  }
+
+  public void main(String[] args) throws MsgException {
+    double taskComputeSize =0;
+    double taskCommunicateSize = 5000000;
+    Host[] hosts = Host.all();
+    int receiverCount = hosts.length - 1;
+
+    Msg.info("Hello! Got "+ receiverCount + " receivers to contact");
+
+    for (int i = 1; i <= receiverCount; i++) {
+      Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize); 
+      Msg.info("Sending \"" + task.getName()+ "\" to \"" + hosts[i].getName() + "\"");
+      task.dsend(hosts[i].getName());
+    }
+
+    Msg.info("All tasks have been (asynchronously) dispatched."+
+             " Let's sleep for 10s so that nobody gets a message from a terminated process.");
+
+    waitFor(10);
+
+    Msg.info("Goodbye now!");
+  }
+}
diff --git a/examples/java/async/dsend/async_dsend.tesh b/examples/java/async/dsend/async_dsend.tesh
new file mode 100644 (file)
index 0000000..484f90b
--- /dev/null
@@ -0,0 +1,22 @@
+#! tesh
+
+! output sort 19
+! timeout 30
+$ java -classpath ${classpath:=.} async/dsend/Main ${srcdir:=.}/../platforms/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [  0.000000] (0:maestro@) Using regular java threads.
+> [  0.000000] (1:Sender@Fafard) Hello! Got 4 receivers to contact
+> [  0.000000] (1:Sender@Fafard) Sending "Task_1" to "Tremblay"
+> [  0.000000] (1:Sender@Fafard) Sending "Task_2" to "Bourassa"
+> [  0.000000] (1:Sender@Fafard) Sending "Task_3" to "Jupiter"
+> [  0.000000] (1:Sender@Fafard) Sending "Task_4" to "Ginette"
+> [  0.000000] (1:Sender@Fafard) All tasks have been (asynchronously) dispatched. Let's sleep for 10s so that nobody gets a message from a terminated process.
+> [  0.000000] (2:Receiver@Tremblay) Receiving on 'Tremblay'
+> [  0.000000] (3:Receiver@Bourassa) Receiving on 'Bourassa'
+> [  0.000000] (4:Receiver@Jupiter) Receiving on 'Jupiter'
+> [  0.000000] (5:Receiver@Ginette) Receiving on 'Ginette'
+> [  1.947550] (3:Receiver@Bourassa) Received a task. I'm done. See you!
+> [  2.084248] (5:Receiver@Ginette) Received a task. I'm done. See you!
+> [  2.432373] (2:Receiver@Tremblay) Received a task. I'm done. See you!
+> [  2.690554] (4:Receiver@Jupiter) Received a task. I'm done. See you!
+> [ 10.000000] (0:maestro@) MSG_main finished; Cleaning up the simulation...
+> [ 10.000000] (1:Sender@Fafard) Goodbye now!
index eee8900..f217ec6 100644 (file)
@@ -924,7 +924,6 @@ set(txt_files
 # Add your CMakeLists file here to see your subdir built.
 set(CMAKEFILES_TXT
   examples/java/CMakeLists.txt
-    examples/java/async/CMakeLists.txt
   examples/msg/CMakeLists.txt
     examples/msg/cloud/CMakeLists.txt
     examples/msg/mc/CMakeLists.txt