1 /* Master of a basic master/slave example in Java */
3 /* Copyright (c) 2006-2014. The SimGrid Team.
4 * 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. */
9 package master_slave_kill;
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;
16 import master_slave_kill.FinalizeTask;
18 public class Master extends Process {
19 public Master(String hostname, String name) throws HostNotFoundException {
20 super(hostname, name);
22 public void main(String[] args) throws MsgException {
23 Msg.info("Master Hello!");
24 Process process2 = null;
25 //Create a slave on host "alice"
27 Msg.info("Create process on host 'alice'");
28 process2 = new Slave("alice","slave");
30 } catch (MsgException e){
31 System.out.println("Process2!");
34 //Wait for slave "alice"
37 Task task = Task.receive("mail1");
38 if (task instanceof FinalizeTask) {
39 Msg.info("Received mail1!");
45 Msg.info("Process2 is now killed, should exit now");