1 /* Copyright (c) 2006-2014. The SimGrid Team.
2 * 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. */
7 package app.masterworker;
9 import org.simgrid.msg.Host;
10 import org.simgrid.msg.HostFailureException;
11 import org.simgrid.msg.Msg;
12 import org.simgrid.msg.Task;
13 import org.simgrid.msg.TaskCancelledException;
14 import org.simgrid.msg.TimeoutException;
15 import org.simgrid.msg.TransferFailureException;
16 import org.simgrid.msg.Process;
18 public class Worker extends Process {
19 public Worker(Host host, String name, String[]args) {
20 super(host,name,args);
22 public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
23 if (args.length < 1) {
24 Msg.info("Worker needs 1 argument (its number)");
28 int num = Integer.parseInt(args[0]);
29 Msg.debug("Receiving on 'worker_"+num+"'");
32 Task task = Task.receive("worker_"+num);
34 if ("finalize".equals(task.getName())) {
37 Msg.info("Received \"" + task.getName() + "\". Processing it.");
40 } catch (TaskCancelledException e) {
45 Msg.info("Received Finalize. I'm done. See you!");