1 #include "Forwarder.hpp"
2 #include "BasicTask.hpp"
3 #include "FinalizeTask.hpp"
5 #include <HostNotFoundException.hpp>
9 MSG_IMPLEMENT_DYNAMIC(Forwarder, Process)
12 int Forwarder::main(int argc, char** argv)
16 int slavesCount = argc;
18 Host* slaves = new Host[slavesCount];
20 for (int i = 0; i < argc; i++)
24 slaves[i] = Host::getByName(argv[i]);
26 catch (HostNotFoundException e)
28 error(TEXT_(e.toString()));
29 error("Buggy deployment file");
38 Task* t = Task::get(0);
40 if(t->isInstanceOf("FinalizeTask"))
42 info("All tasks have been dispatched. Let's tell everybody the computation is over.");
44 for (int cpt = 0; cpt< slavesCount; cpt++)
45 slaves[cpt].put(0, new FinalizeTask());
52 info(TEXT_("Received \"") + TEXT_(t->getName()) + TEXT_("\" "));
54 info(TEXT_("Sending \"") + TEXT_(t->getName()) + TEXT_("\" to \"") + TEXT_(slaves[taskCount % slavesCount].getName()) + TEXT_("\""));
56 slaves[taskCount % slavesCount].put(0, t);
62 info("I'm done. See you!");