Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / examples / java / trace / pingpong / Main.java
1 /* Copyright (c) 2006-2007, 2012-2014, 2016. The SimGrid Team.
2  * 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 trace.pingpong;
8 import org.simgrid.msg.Msg;
9 import org.simgrid.trace.Trace;
10 import org.simgrid.msg.MsgException;
11 import org.simgrid.msg.NativeException;
12
13 public class Main  {
14   private Main() {
15     throw new IllegalAccessError("Utility class");
16   }
17
18   public static void main(String[] args) throws MsgException, NativeException {
19     Msg.init(args);
20     if(args.length < 1) {
21       Msg.info("Usage   : Main platform_file");
22       Msg.info("example : Main ../platforms/platform.xml");
23       System.exit(1);
24     }
25
26     /* construct the platform and deploy the application */
27     Msg.createEnvironment(args[0]);
28     new Sender("Jacquelin", "Sender", new String[] {"Boivin", "Marcel"}).start();
29     new Receiver ("Boivin", "Receiver", null).start();
30     new Receiver ("Marcel", "Receiver", null).start();
31
32     /* Initialize some state for the hosts */
33     Trace.hostStateDeclare ("PM_STATE"); 
34     Trace.hostStateDeclareValue ("PM_STATE", "waitingPing", "0 0 1");
35     Trace.hostStateDeclareValue ("PM_STATE", "sendingPong", "0 1 0");
36     Trace.hostStateDeclareValue ("PM_STATE", "sendingPing", "0 1 1");
37     Trace.hostStateDeclareValue ("PM_STATE", "waitingPong", "1 0 0");
38
39     /*  execute the simulation. */
40     Msg.run();
41   }
42 }