Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill tracing-gtnets examples
[simgrid.git] / examples / java / masterslave / Forwarder.java
index f6b8f5b..3c4542c 100644 (file)
@@ -12,46 +12,43 @@ 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++;
+  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);
       }
-      
-        
-      Msg.info("I'm done. See you!");
-   }
-}
+      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!");
+  }
+}