2 * Master of a basic master/slave example in Java
4 * Copyright (c) 2006-2013. The SimGrid Team.
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.
12 import org.simgrid.msg.Host;
13 import org.simgrid.msg.Msg;
14 import org.simgrid.msg.MsgException;
15 import org.simgrid.msg.Task;
16 import org.simgrid.msg.Process;;
18 class Master(host:Host, name:String, args:Array[String]) extends Process(host,name,args) {
19 def main(args:Array[String]) {
20 if (args.length < 4) {
21 Msg.info("Master needs 4 arguments")
25 val tasksCount = args(0).toInt
26 val taskComputeSize = args(1).toDouble
27 val taskCommunicateSize = args(2).toDouble
28 val slavesCount = args(3).toInt
30 Msg.info("Hello! Got " + slavesCount + " slaves and " + tasksCount + " tasks to process")
32 for (i <- 0 until tasksCount) {
33 val task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize)
34 task.send("slave_"+(i%slavesCount))
37 Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over.")
39 for (i <- 0 until slavesCount) {
40 val task = new FinalizeTask()
41 task.send("slave_"+(i%slavesCount))
44 Msg.info("Goodbye now!")