Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add kademlia example
[simgrid.git] / examples / async / Slave.java
index f1a8fab..ca06965 100644 (file)
@@ -6,7 +6,9 @@
  */
 package async;
 import org.simgrid.msg.Comm;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.HostFailureException;
+import org.simgrid.msg.HostNotFoundException;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.TaskCancelledException;
@@ -15,6 +17,9 @@ import org.simgrid.msg.TransferFailureException;
 import org.simgrid.msg.Process;
 
 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)");
@@ -22,7 +27,6 @@ public class Slave extends Process {
                }
 
                int num = Integer.valueOf(args[0]).intValue();
-               
                Comm comm = null;
                boolean slaveFinished = false;
                while(!slaveFinished) {  
@@ -40,6 +44,7 @@ public class Slave extends Process {
                                                        comm = null;
                                                        break;
                                                }
+                                               Msg.info("Received a task");
                                                Msg.info("Received \"" + task.getName() +  "\". Processing it.");
                                                try {
                                                        task.execute();
@@ -49,7 +54,7 @@ public class Slave extends Process {
                                                comm = null;                                                    
                                        }
                                        else {
-                                               simulatedSleep(1);
+                                               waitFor(1);
                                        }
                                }
                        }
@@ -58,6 +63,6 @@ public class Slave extends Process {
                        }
                }
                Msg.info("Received Finalize. I'm done. See you!");
-               simulatedSleep(20);
+               waitFor(20);
        }
 }
\ No newline at end of file