Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill tracing-gtnets examples
[simgrid.git] / examples / java / master_slave_bypass / Master.java
1 /* Master of a basic master/slave example in Java */
2
3 /* Copyright (c) 2006-2014. The SimGrid Team.
4  * 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 package master_slave_bypass;
10 import org.simgrid.msg.HostNotFoundException;
11 import org.simgrid.msg.Msg;
12 import org.simgrid.msg.MsgException;
13 import org.simgrid.msg.Process;
14 import org.simgrid.msg.Task;
15
16 import master_slave_bypass.FinalizeTask;
17
18 public class Master extends Process {
19         public Master(String hostname, String name) throws HostNotFoundException {
20                 super(hostname, name);
21         }
22         public void main(String[] args) throws MsgException {
23         Msg.info("Master Hello!");
24
25         //Create a slave on host "alice"
26         try {
27                         Msg.info("Create process on host 'Jacquelin'");
28                 new Slave("Jacquelin","process2").start();
29             }
30         catch (MsgException e){
31                         System.out.println("Process2!");
32             }
33
34         //Wait for slave "alice"
35         while(true)
36         {
37                         Task task = Task.receive("Jacquelin");
38                         if (task instanceof FinalizeTask) {
39                                 Msg.info("Received Finalize. I'm done. See you!");
40                                 break;
41                         }
42         }
43         }
44 }