Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ca5ecaf085250cab78bd4f694e36393d4548c448
[simgrid.git] / examples / cloud / Slave.java
1 /*
2  * Copyright 2012. The SimGrid Team. All rights reserved. 
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. 
6  */
7 package cloud;
8
9 import org.simgrid.msg.Host;
10 import org.simgrid.msg.Msg;
11 import org.simgrid.msg.MsgException;
12 import org.simgrid.msg.Process;
13 import org.simgrid.msg.Task;
14 import org.simgrid.msg.TaskCancelledException;
15
16 public class Slave extends Process {
17         private int number;
18         public Slave(Host host, int number) {
19                 super(host,"Slave " + number,null);
20                 this.number = number;
21         }
22         public void main(String[] args) throws MsgException {
23                 while(true) {  
24                         Task task = Task.receive("slave_"+number);      
25
26                         if (task instanceof FinalizeTask) {
27                                 break;
28                         }
29                         Msg.info("Received \"" + task.getName() +  "\". Processing it.");
30                         try {
31                                 task.execute();
32                         } catch (TaskCancelledException e) {
33
34                         }
35                 //      Msg.info("\"" + task.getName() + "\" done ");
36                 }
37
38                 Msg.info("Received Finalize. I'm done. See you!");
39                 
40         }
41 }