Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / bindings / java / org / simgrid / msg / Msg.java
1 /* JNI interface to C code for MSG. */
2
3 /* Copyright (c) 2006-2022. The SimGrid Team. All rights reserved.          */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 package org.simgrid.msg;
9
10 public final class Msg {
11
12         /** Retrieves the simulation time */
13         public static final native double getClock();
14         /** Issue a debug logging message. */
15         public static final native void debug(String msg);
16         /** Issue a verbose logging message. */
17         public static final native void verb(String msg);
18         /** Issue an information logging message */
19         public static final native void info(String msg);
20         /** Issue a warning logging message. */
21         public static final native void warn(String msg);
22         /** Issue an error logging message. */
23         public static final native void error(String msg);
24         /** Issue a critical logging message. */
25         public static final native void critical(String s);
26
27         private Msg() {
28                 throw new IllegalAccessError("Utility class");
29         }
30
31         /*********************************************************************************
32          * Deployment and initialization related functions                               *
33          *********************************************************************************/
34
35         /** Initialize a MSG simulation.
36          *
37          * @param args            The arguments of the command line of the simulation.
38          */
39         public static final native void init(String[]args);
40
41         /** Tell the kernel that you want to use the energy plugin */
42         public static final native void energyInit();
43
44     /** Tell the kernel that you want to use the filesystem plugin. */
45         public static final native void fileSystemInit();
46
47     /** Initializes the HostLoad plugin.
48      *
49          * The HostLoad plugin provides an API to get the current load of each host.
50      */
51         public static final native void loadInit();
52
53         /** Run the MSG simulation.
54          *
55          * After the simulation, you can freely retrieve the information that you want..
56          * In particular, retrieving the status of a process or the current date is perfectly ok.
57          */
58         public static final native void run() ;
59
60         /** Create the simulation environment by parsing a platform file. */
61         public static final native void createEnvironment(String platformFile);
62
63         public static final native As environmentGetRoutingRoot();
64
65         /** Starts your processes by parsing a deployment file. */
66         public static final native void deployApplication(String deploymentFile);
67
68         /** Example launcher. You can use it or provide your own launcher, as you wish
69          * @param args
70          */
71         public static void main(String[]args) {
72                 /* initialize the MSG simulation. Must be done before anything else (even logging). */
73                 Msg.init(args);
74
75                 if (args.length < 2) {
76                         Msg.info("Usage: Msg platform_file deployment_file");
77                         System.exit(1);
78                 }
79
80                 /* Load the platform and deploy the application */
81                 Msg.createEnvironment(args[0]);
82                 Msg.deployApplication(args[1]);
83                 /* Execute the simulation */
84                 Msg.run();
85         }
86
87         /* Class initializer, to initialize various JNI stuff */
88         static {
89                 org.simgrid.NativeLib.nativeInit();
90         }
91 }