4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package.
13 public class Forwarder extends simgrid.msg.Process {
15 public void main(String[] args) throws JniException, NativeException {
18 int slavesCount = args.length;
19 Host[] slaves = new Host[slavesCount];
21 for (int i = 0; i < args.length; i++) {
23 slaves[i] = Host.getByName(args[i]);
24 } catch (HostNotFoundException e) {
25 Msg.info("Buggy deployment file");
31 Channel channel = new Channel(0);
35 Task t = channel.get();
37 if (t instanceof FinalizeTask) {
38 Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over.");
40 for (int cpt = 0; cpt<slavesCount; cpt++) {
41 channel.put(new FinalizeTask(),slaves[cpt]);
45 BasicTask task = (BasicTask)t;
47 Msg.info("Received \"" + task.getName() + "\" ");
49 Msg.info("Sending \"" + task.getName() + "\" to \"" + slaves[taskCount % slavesCount].getName() + "\"");
50 channel.put(task, slaves[taskCount % slavesCount]);
56 Msg.info("I'm done. See you!");