Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rewrite the example in order to make clear on how a process can create
authorPierre <pierre@erie.imag.fr>
Fri, 14 Oct 2011 13:27:29 +0000 (15:27 +0200)
committerPierre <pierre@erie.imag.fr>
Fri, 14 Oct 2011 13:27:29 +0000 (15:27 +0200)
a process once simulation has started using Java bindings.

CMakeLists.txt
examples/master_slave_bypass/FinalizeTask.java [new file with mode: 0644]
examples/master_slave_bypass/Master.java
examples/master_slave_bypass/MsBypass.java
examples/master_slave_bypass/Slave.java
examples/master_slave_bypass/platform.xml

index ff7ce52..c766956 100644 (file)
@@ -130,6 +130,7 @@ set(JAVA_EXAMPLES
        examples/master_slave_bypass/Master.java
        examples/master_slave_bypass/MsBypass.java
        examples/master_slave_bypass/Slave.java
+       examples/master_slave_bypass/FinalizeTask.java
 )
 
 set(CMAKE_SRC
diff --git a/examples/master_slave_bypass/FinalizeTask.java b/examples/master_slave_bypass/FinalizeTask.java
new file mode 100644 (file)
index 0000000..76f56f9
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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. 
+ */
+
+package master_slave_bypass;
+import org.simgrid.msg.Task;
+
+public class FinalizeTask extends Task {       
+   public FinalizeTask() {
+      super("finalize",0,0);
+   }
+}
+    
\ No newline at end of file
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;  
+                       }
+       }
        }
 }
index 006c63d..cc95c83 100644 (file)
@@ -27,10 +27,9 @@ public class MsBypass {
     /* bypass deploymemt */
     try {
     Master process1 = new Master("bob","process1");
-    Slave process2 = new Slave("alice","process2");
     }
     catch (MsgException e){
-       System.out.println("Mes couilles!!!!!");
+       System.out.println("Create processes failed!");
     }
     
        /*  execute the simulation. */
index 84de81c..3056f1c 100644 (file)
@@ -12,11 +12,16 @@ import org.simgrid.msg.TimeoutException;
 import org.simgrid.msg.TransferFailureException;
 import org.simgrid.msg.Process;
 
+import master_slave_bypass.FinalizeTask;
+
 public class Slave extends Process {
        public Slave(String hostname, String name) throws HostNotFoundException {
                super(hostname, name);
        }
        public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
        Msg.info("Slave Hello!");
+       FinalizeTask task = new FinalizeTask();
+       Msg.info("Send finalize!");
+       task.send("alice");
        }
 }
\ No newline at end of file
index ea46d06..310c6e6 100644 (file)
@@ -4,13 +4,26 @@
 <AS  id="AS0"  routing="Full">
        <host id="bob" power="137333000"/>
        <host id="alice" power="98095000"/>
+       <host id="nono" power="98095000"/>
        
        <link id="1" bandwidth="100000000" latency="0.001"/>
+       <link id="2" bandwidth="100000000" latency="0.001"/>
+       <link id="3" bandwidth="100000000" latency="0.001"/>
        
        <route  src="bob"
                        dst="alice"
                        symmetrical="YES">
                                <link_ctn id="1"/>
+   </route>
+       <route  src="alice"
+                       dst="nono"
+                       symmetrical="YES">
+                               <link_ctn id="2"/>
+   </route>
+       <route  src="bob"
+                       dst="nono"
+                       symmetrical="YES">
+                               <link_ctn id="3"/>
    </route>
 </AS>
 </platform>
\ No newline at end of file