From: mquinson Date: Sat, 27 Feb 2010 23:05:41 +0000 (+0000) Subject: Rewrite the basic master/slave example to use the send/receive interface instead... X-Git-Tag: SVN~608 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b50ea0bd9bd6661d86b941b9b1742d44606ee9eb Rewrite the basic master/slave example to use the send/receive interface instead of put/get git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7130 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/examples/java/basic/BasicTest.java b/examples/java/basic/BasicTest.java index 8f51245fa1..5d34c69d4a 100644 --- a/examples/java/basic/BasicTest.java +++ b/examples/java/basic/BasicTest.java @@ -29,9 +29,6 @@ public class BasicTest { System.exit(1); } - /* specify a paje output file. */ - Msg.pajeOutput("basic.trace"); - /* construct the platform and deploy the application */ Msg.createEnvironment(args[0]); Msg.deployApplication(args[1]); diff --git a/examples/java/basic/Forwarder.java b/examples/java/basic/Forwarder.java index 4e856bca9d..6d383c9fa9 100644 --- a/examples/java/basic/Forwarder.java +++ b/examples/java/basic/Forwarder.java @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright 2006,2007 Martin Quinson, Malek Cherier + * Copyright 2006,2007,2010 The SimGrid Team * All rights reserved. * * This program is free software; you can redistribute it and/or modify it @@ -13,39 +13,35 @@ import simgrid.msg.*; public class Forwarder extends simgrid.msg.Process { public void main(String[] args) throws JniException, NativeException { - Msg.info("hello!"); - - int slavesCount = args.length; - Host[] slaves = new Host[slavesCount]; - - for (int i = 0; i < args.length; i++) { - try { - slaves[i] = Host.getByName(args[i]); - } catch (HostNotFoundException e) { - Msg.info("Buggy deployment file"); - e.printStackTrace(); - System.exit(1); - } + if (args.length < 3) { + Msg.info("Forwarder needs 3 arguments (input mailbox, first output mailbox, last one)"); + Msg.info("Got "+args.length+" instead"); + System.exit(1); } + int input = Integer.valueOf(args[0]).intValue(); + int firstOutput = Integer.valueOf(args[1]).intValue(); + int lastOutput = Integer.valueOf(args[2]).intValue(); int taskCount = 0; + int slavesCount = lastOutput - firstOutput + 1; + Msg.info("Receiving on 'slave_"+input+"'"); while(true) { - Task t = Task.get(0); + Task t = Task.receive("slave_"+input); if (t instanceof FinalizeTask) { - Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over."); + Msg.info("Got a finalize task. Let's forward that we're done."); - for (int cpt = 0; cpt - - - - - - - - + + + + + - - - - + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +