Logo AND Algorithmique Numérique Distribuée

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