Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Hello you stupid doxygen. Our inline functions are visible to the users, please don...
[simgrid.git] / examples / java / basic / Slave.java
1 /*
2  * Copyright 2006,2007,2010. 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
8 import simgrid.msg.HostFailureException;
9 import simgrid.msg.Msg;
10 import simgrid.msg.Task;
11 import simgrid.msg.TaskCancelledException;
12 import simgrid.msg.TimeoutException;
13 import simgrid.msg.TransferFailureException;
14
15 public class Slave extends simgrid.msg.Process {
16         public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
17                 if (args.length < 1) {
18                         Msg.info("Slave needs 1 argument (its number)");
19                         System.exit(1);
20                 }
21
22                 int num = Integer.valueOf(args[0]).intValue();
23                 //Msg.info("Receiving on 'slave_"+num+"'");
24
25                 while(true) {  
26                         Task task = Task.receive("slave_"+num); 
27
28                         if (task instanceof FinalizeTask) {
29                                 break;
30                         }
31                         Msg.info("Received \"" + task.getName() +  "\". Processing it.");
32                         try {
33                                 task.execute();
34                         } catch (TaskCancelledException e) {
35
36                         }
37                 //      Msg.info("\"" + task.getName() + "\" done ");
38                 }
39
40                 //Msg.info("Received Finalize. I'm done. See you!");
41         }
42 }