X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8be7ea3f9e71cd563e91b6aba63f5c70f043fbd5..077d899a2c6627b30846e848b4a029da720b7ea0:/examples/java/cloud/Slave.java diff --git a/examples/java/cloud/Slave.java b/examples/java/cloud/Slave.java index 4d9963e251..b8b3728da2 100644 --- a/examples/java/cloud/Slave.java +++ b/examples/java/cloud/Slave.java @@ -1,47 +1,44 @@ -/* - * Copyright (c) 2012-2013. The SimGrid Team. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. - */ +/* Copyright (c) 2012-2016. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + package cloud; -import org.simgrid.msg.Host; import org.simgrid.msg.Msg; -import org.simgrid.msg.MsgException; -import org.simgrid.msg.Process; +import org.simgrid.msg.Host; import org.simgrid.msg.Task; +import org.simgrid.msg.Process; +import org.simgrid.msg.MsgException; public class Slave extends Process { - private int number; - public Slave(Host host, int number) { - super(host,"Slave " + number,null); - this.number = number; - } - public void main(String[] args) throws MsgException { - while(true) { - Msg.info("Receiving on " + "slave_" + number); - Task task; - try { - task = Task.receive("slave_"+number); - } catch (MsgException e) { - Msg.debug("Received failed. I'm done. See you!"); - break; - } - if (task instanceof FinalizeTask) { - Msg.info("Received Finalize. I'm done. See you!"); - break; - } - Msg.info("Received \"" + task.getName() + "\". Processing it."); - try { - task.execute(); - } catch (MsgException e) { - - } - Msg.info("\"" + task.getName() + "\" done "); - } + private int number; + public Slave(Host host, int number) { + super(host,"WRK0" + number,null); + this.number = number; + } - - } -} \ No newline at end of file + public void main(String[] args) throws MsgException { + Msg.info(this.getName() +" is listenning on MBOX:WRK0"+ number); + while(true) { + Task task; + try { + task = Task.receive("MBOX:WRK0"+number); + } catch (MsgException e) { + Msg.debug("Received failed. I'm done. See you!"); + break; + } + if (task instanceof FinalizeTask) { + Msg.info("Received Finalize. I'm done. See you!"); + break; + } + Msg.info("Received \"" + task.getName() + "\". Processing it."); + try { + task.execute(); + } catch (MsgException e) { + } + Msg.info(this.getName() +" executed task (" + task.getName()+")"); + } + } +}