2 * Copyright 2006,2007,2010. The SimGrid Team. All rights reserved.
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.
8 import org.simgrid.msg.HostFailureException;
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.Task;
11 import org.simgrid.msg.TaskCancelledException;
12 import org.simgrid.msg.TimeoutException;
13 import org.simgrid.msg.TransferFailureException;
14 import org.simgrid.msg.Process;
16 public class Slave extends Process {
17 public Slave(Host host, String name, String[]args) {
18 super(host,name,args);
20 public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
21 if (args.length < 1) {
22 Msg.info("Slave needs 1 argument (its number)");
26 int num = Integer.valueOf(args[0]).intValue();
27 //Msg.info("Receiving on 'slave_"+num+"'");
30 Task task = Task.receive("slave_"+num);
32 if (task instanceof FinalizeTask) {
35 Msg.info("Received \"" + task.getName() + "\". Processing it.");
38 } catch (TaskCancelledException e) {
41 // Msg.info("\"" + task.getName() + "\" done ");
44 Msg.info("Received Finalize. I'm done. See you!");