Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e52dd93733ee37592599369adb6680003b43bd88
[simgrid.git] / examples / java / master_slave_kill / Slave.java
1 /*
2  * Copyright 2006-2012. The SimGrid Team. All rights reserved. 
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. 
6  */
7 package master_slave_kill;
8 import org.simgrid.msg.HostFailureException;
9 import org.simgrid.msg.HostNotFoundException;
10 import org.simgrid.msg.Msg;
11 import org.simgrid.msg.MsgException;
12 import org.simgrid.msg.Task;
13 import org.simgrid.msg.TimeoutException;
14 import org.simgrid.msg.TransferFailureException;
15 import org.simgrid.msg.Process;
16
17 import master_slave_kill.FinalizeTask;
18
19 public class Slave extends Process {
20         public Slave(String hostname, String name) throws HostNotFoundException {
21                 super(hostname, name);
22         }
23         public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
24         Msg.info("Slave Hello!");
25         
26         FinalizeTask task = new FinalizeTask();
27         Msg.info("Send Mail1!");
28         task.send("mail1");
29         
30         Task task2;
31         try {
32                 task2 = Task.receive("mail2");
33         } catch (MsgException e) {
34                 Msg.debug("Received failed");
35                 return;
36         }
37         Msg.info("Receive Mail2!");
38   }
39 }