Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
leak--
[simgrid.git] / examples / scala / master_slave_bypass / Master.scala
1 /*
2  * Master of a basic master/slave example in Java
3  *
4  * Copyright (c) 2006-2013. The SimGrid Team.
5  * All rights reserved.
6  *
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. 
9  */
10
11 package master_slave_bypass
12
13 import Stream._
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
19
20 class Master(hostname:String, name:String) extends Process(hostname,name) {
21   
22   def main(args:Array[String]) {
23     Msg.info("Master Hello!")
24         
25     //Create a slave on host "alice"
26     try {
27       Msg.info("Create process on host 'alice'")
28       new Slave("alice","process2").start()
29     } catch {
30       case e:MsgException => println("Process2!")
31     }
32         
33     //Wait for slave "alice"
34     continually({Task.receive("alice")})
35       .takeWhile(!_.isInstanceOf[FinalizeTask])
36       .force // to force the list to be compute
37
38     Msg.info("Received Finalize. I'm done. See you!")
39   }
40 }