Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use send/recv instead of put/get
[simgrid.git] / examples / java / ping_pong / Sender.java
index fd44bb2..846566f 100644 (file)
@@ -1,8 +1,7 @@
 /*
- * $Id$
+ * Sender of basic ping/pong example
  *
- * Copyright 2006,2007 Martin Quinson, Malek Cherier         
- * All rights reserved. 
+ * 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. 
@@ -21,15 +20,15 @@ public class Sender extends simgrid.msg.Process {
         
        int hostCount = args.length;
         
-       Msg.info("host count : " + hostCount);
-       Host hostTable[] = new Host[hostCount]; 
+       Msg.info("host count: " + hostCount);
+       String mailboxes[] = new String[hostCount]; 
        double time;
        double computeDuration = 0;
        PingPongTask task;
         
        for(int pos = 0; pos < args.length ; pos++) {
          try {
-            hostTable[pos] = Host.getByName(args[pos]);
+            mailboxes[pos] = Host.getByName(args[pos]).getName();
          } catch (HostNotFoundException e) {
             Msg.info("Invalid deployment file: " + e.toString());           
             System.exit(1);
@@ -39,12 +38,12 @@ public class Sender extends simgrid.msg.Process {
         for (int pos = 0; pos < hostCount; pos++) { 
           time = Msg.getClock(); 
             
-          Msg.info("sender time : " + time);
+          Msg.info("sender time: " + time);
           
           task = new PingPongTask("no name",computeDuration,commSizeLat);
           task.setTime(time);
             
-          hostTable[pos].put(0,task);
+          task.send(mailboxes[pos]);
         } 
         
         Msg.info("goodbye!");