Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rewrite the example in order to make clear on how a process can create
[simgrid.git] / examples / master_slave_bypass / Master.java
index 67499fa..393d896 100644 (file)
@@ -12,18 +12,34 @@ import org.simgrid.msg.HostNotFoundException;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
 import org.simgrid.msg.Process;
+import org.simgrid.msg.Task;
+
+import master_slave_bypass.FinalizeTask;
 
 public class Master extends Process {
        public Master(String hostname, String name) throws HostNotFoundException {
                super(hostname, name);
        }
        public void main(String[] args) throws MsgException {
-               Msg.info("Master Hello!");
-/*     try {
+       Msg.info("Master Hello!");
+       
+       //Create a slave on host "alice"
+       try {
+                       Msg.info("Create process on host 'alice'");
                Slave process2 = new Slave("alice","process2");
            }
        catch (MsgException e){
-                       System.out.println("Mes couilles!!!!!");
-           } */
+                       System.out.println("Process2!");
+           }
+       
+       //Wait for slave "alice"
+       while(true)
+       {  
+                       Task task = Task.receive("alice");
+                       if (task instanceof FinalizeTask) {
+                               Msg.info("Received Finalize. I'm done. See you!");
+                               break;  
+                       }
+       }
        }
 }