2 * Master of a basic master/slave example in Java
4 * Copyright 2006-2012 The SimGrid Team. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package.
10 package master_slave_kill
13 import org.simgrid.msg.HostNotFoundException
14 import org.simgrid.msg.Msg
15 import org.simgrid.msg.MsgException
16 import org.simgrid.msg.Process
17 import org.simgrid.msg.Task
19 class Master(hostname:String, name:String) extends Process(hostname, name) {
20 def main(args:Array[String]) {
21 Msg.info("Master Hello!")
22 var process2:Slave = null
24 //Create a slave on host "alice"
26 Msg.info("Create process on host 'alice'")
27 process2 = new Slave("alice","slave")
30 case e:MsgException => println("Process2!")
33 //Wait for slave "alice"
34 continually({Task.receive("mail1")})
35 .takeWhile(!_.isInstanceOf[FinalizeTask])
36 .force // to force the list to be compute
38 Msg.info("Received mail1!")
40 Msg.info("Process2 is now killed, should exit now")