Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge tag 'v3_9_90' into hypervisor
[simgrid.git] / examples / java / cloud / Slave.java
index 8f7cde3..000d1d2 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright 2012. The SimGrid Team. All rights reserved. 
+ * Copyright (c) 2012-2013. 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. 
@@ -15,15 +16,21 @@ import org.simgrid.msg.Task;
 public class Slave extends Process {
        private int number;
        public Slave(Host host, int number) {
-               super(host,"Slave " + number,null);
+               super(host,"WRK0" + number,null);
                this.number = number;
        }
        public void main(String[] args) throws MsgException {
+               Msg.info(this.msgName() +" is listenning on MBOX:WRK0"+ number);
                while(true) {                   
-                       Msg.info("Receiving on " + "slave_" + number);
-                       Task task = Task.receive("slave_"+number);      
-
+                       Task task;
+                        try {
+                                task = Task.receive("MBOX:WRK0"+number);
+                        } catch (MsgException e) {
+                                Msg.debug("Received failed. I'm done. See you!");
+                                break;
+                        }
                        if (task instanceof FinalizeTask) {
+                                Msg.info("Received Finalize. I'm done. See you!");
                                break;
                        }
                        Msg.info("Received \"" + task.getName() +  "\". Processing it.");
@@ -32,10 +39,9 @@ public class Slave extends Process {
                        } catch (MsgException e) {
 
                        }
-                       Msg.info("\"" + task.getName() + "\" done ");
+                       Msg.info(this.msgName() +" executed task (" + task.getName()+")");
                }
 
-               Msg.info("Received Finalize. I'm done. See you!");
                
        }
-}
\ No newline at end of file
+}