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.
11 package master_slave_kill
14 import org.simgrid.msg.HostNotFoundException
15 import org.simgrid.msg.Msg
16 import org.simgrid.msg.MsgException
17 import org.simgrid.msg.Process
18 import org.simgrid.msg.Task
20 class Master(hostname:String, name:String) extends Process(hostname, name) {
21 def main(args:Array[String]) {
22 Msg.info("Master Hello!")
23 var process2:Slave = null
25 //Create a slave on host "alice"
27 Msg.info("Create process on host 'alice'")
28 process2 = new Slave("alice","slave")
31 case e:MsgException => println("Process2!")
34 //Wait for slave "alice"
35 continually({Task.receive("mail1")})
36 .takeWhile(!_.isInstanceOf[FinalizeTask])
37 .force // to force the list to be compute
39 Msg.info("Received mail1!")
41 Msg.info("Process2 is now killed, should exit now")