Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reindent, and use default platf and deploy if none is passed
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 3 May 2010 10:04:30 +0000 (10:04 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 3 May 2010 10:04:30 +0000 (10:04 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7661 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/java/basic/BasicTest.java
examples/java/basic/Master.java
examples/java/basic/Slave.java

index 89921ae..e6c6a8f 100644 (file)
@@ -19,17 +19,23 @@ public class BasicTest {
        /* initialize the MSG simulation. Must be done before anything else (even logging). */
        Msg.init(args);
 
-       if(args.length < 2) {
+       if(args.length == 0) {
+               Msg.createEnvironment("basic_platform.xml");
+               Msg.deployApplication("basic_deployment.xml");
+          
+       } else if (args.length < 2) {
+
                
          Msg.info("Usage   : Basic platform_file deployment_file");
          Msg.info("example : Basic basic_platform.xml basic_deployment.xml");
          System.exit(1);
-       }
+       } else {
                
        /* construct the platform and deploy the application */
        Msg.createEnvironment(args[0]);
        Msg.deployApplication(args[1]);
-               
+       }
+       
        /*  execute the simulation. */
         Msg.run();
     }
index eab3bf5..021220c 100644 (file)
 import simgrid.msg.*;
 
 public class Master extends simgrid.msg.Process {
-   public void main(String[] args) throws MsgException {
-      if (args.length < 4) {
-        Msg.info("Master needs 4 arguments");
-        System.exit(1);
-      }
-      
-      int tasksCount = Integer.valueOf(args[0]).intValue();            
-      double taskComputeSize = Double.valueOf(args[1]).doubleValue();          
-      double taskCommunicateSize = Double.valueOf(args[2]).doubleValue();
-      
-      int slavesCount = Integer.valueOf(args[3]).intValue();
-      
-      Msg.info("Hello! Got "+  slavesCount + " slaves and "+tasksCount+" tasks to process");
-      
-      for (int i = 0; i < tasksCount; i++) {
-        Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize); 
-        Msg.info("Sending \"" + task.getName()+ "\" to \"slave_" + i % slavesCount + "\"");
-        task.send("slave_"+(i%slavesCount));
-      }
-      
-      Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over.");
-      
-      for (int i = 0; i < slavesCount; i++) {
-        FinalizeTask task = new FinalizeTask();
-        task.send("slave_"+(i%slavesCount));
-      }
-      
-      Msg.info("Goodbye now!");
-    }
+       public void main(String[] args) throws MsgException {
+               if (args.length < 4) {
+                       Msg.info("Master needs 4 arguments");
+                       System.exit(1);
+               }
+
+               int tasksCount = Integer.valueOf(args[0]).intValue();           
+               double taskComputeSize = Double.valueOf(args[1]).doubleValue();         
+               double taskCommunicateSize = Double.valueOf(args[2]).doubleValue();
+
+               int slavesCount = Integer.valueOf(args[3]).intValue();
+
+               Msg.info("Hello! Got "+  slavesCount + " slaves and "+tasksCount+" tasks to process");
+
+               for (int i = 0; i < tasksCount; i++) {
+                       Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize); 
+                       //Msg.info("Sending \"" + task.getName()+ "\" to \"slave_" + i % slavesCount + "\"");
+                       task.send("slave_"+(i%slavesCount));
+               }
+
+               Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over.");
+
+               for (int i = 0; i < slavesCount; i++) {
+                       FinalizeTask task = new FinalizeTask();
+                       task.send("slave_"+(i%slavesCount));
+               }
+
+               Msg.info("Goodbye now!");
+       }
 }
index 6d8eb6c..d55ae0a 100644 (file)
@@ -5,33 +5,38 @@
  * under the terms of the license (GNU LGPL) which comes with this package. 
  */
 
-import simgrid.msg.*;
+import simgrid.msg.HostFailureException;
+import simgrid.msg.Msg;
+import simgrid.msg.Task;
+import simgrid.msg.TaskCancelledException;
+import simgrid.msg.TimeoutException;
+import simgrid.msg.TransferFailureException;
 
 public class Slave extends simgrid.msg.Process {
-   public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
-      if (args.length < 1) {
-        Msg.info("Slave needs 1 argument (its number)");
-        System.exit(1);
-      }
+       public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
+               if (args.length < 1) {
+                       Msg.info("Slave needs 1 argument (its number)");
+                       System.exit(1);
+               }
 
-      int num = Integer.valueOf(args[0]).intValue();
-      Msg.info("Receiving on 'slave_"+num+"'");
-      
-      while(true) { 
-        Task task = Task.receive("slave_"+num);        
-        
-        if (task instanceof FinalizeTask) {
-           break;
-        }
-        Msg.info("Received \"" + task.getName() +  "\". Processing it.");
-        try {
-        task.execute();
-        } catch (TaskCancelledException e) {
-                
-        }
-        Msg.info("\"" + task.getName() + "\" done ");
-       }
-       
-      Msg.info("Received Finalize. I'm done. See you!");
-    }
+               int num = Integer.valueOf(args[0]).intValue();
+               //Msg.info("Receiving on 'slave_"+num+"'");
+
+               while(true) {  
+                       Task task = Task.receive("slave_"+num); 
+
+                       if (task instanceof FinalizeTask) {
+                               break;
+                       }
+                       Msg.info("Received \"" + task.getName() +  "\". Processing it.");
+                       try {
+                               task.execute();
+                       } catch (TaskCancelledException e) {
+
+                       }
+               //      Msg.info("\"" + task.getName() + "\" done ");
+               }
+
+               //Msg.info("Received Finalize. I'm done. See you!");
+       }
 }
\ No newline at end of file