1 /* Bindings to the MSG hosts */
3 /* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved. */
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. */
8 package org.simgrid.msg;
10 import org.simgrid.msg.Storage;
13 * A host object represents a location (any possible place) where a process may run.
14 * Thus it is represented as a physical resource with computing capabilities, some
15 * mailboxes to enable running process to communicate with remote ones, and some private
16 * data that can be only accessed by local process. An instance of this class is always
17 * bound with the corresponding native host. All the native hosts are automatically created
18 * during the call of the method Msg.createEnvironment(). This method take as parameter a
19 * platform file which describes all elements of the platform (host, link, root..).
20 * You cannot create a host yourself.
22 * The best way to get an host instance is to call the static method
25 * For example to get the instance of the host. If your platform
26 * file description contains an host named "Jacquelin" :
32 jacquelin = Host.getByName("Jacquelin");
33 } catch(HostNotFoundException e) {
34 System.err.println(e.toString());
43 * This attribute represents a bind between a java host object and
44 * a native host. Even if this attribute is public you must never
45 * access to it. It is set automatically during the call of the
46 * static method Host.getByName().
48 * @see Host.getByName().
51 protected String name;
61 public String toString (){
66 * This static method gets an host instance associated with a native
67 * host of your platform. This is the best way to get a java host object.
69 * @param name The name of the host to get.
71 * @return The host object with the given name.
72 * @exception HostNotFoundException if the name of the host is not valid.
74 public static native Host getByName(String name) throws HostNotFoundException;
75 /** Counts the installed hosts. */
76 public static native int getCount();
78 /** Returns the host of the current process. */
79 public static native Host currentHost();
81 /** Returns all hosts of the installed platform. */
82 public static native Host[] all();
85 * This static method sets a mailbox to receive in asynchronous mode.
87 * All messages sent to this mailbox will be transferred to
88 * the receiver without waiting for the receive call.
89 * The receive call will still be necessary to use the received data.
90 * If there is a need to receive some messages asynchronously, and some not,
91 * two different mailboxes should be used.
93 * @param mailboxName The name of the mailbox
95 public static native void setAsyncMailbox(String mailboxName);
97 public String getName() {
101 public void setData(Object data) {
105 public Object getData() {
108 /** Returns true if the host has an associated data object. */
109 public boolean hasData() {
110 return null != this.data;
113 /** Starts the host if it is off */
114 public native void on();
115 /** Stops the host if it is on */
116 public native void off();
119 * This method returns the speed of the processor of a host (in flops),
120 * regardless of the current load of the machine.
122 public native double getSpeed();
123 public native double getCoreNumber();
125 public native String getProperty(String name);
126 public native void setProperty(String name, String value);
127 /** Tests if an host is up and running. */
128 public native boolean isOn();
130 /** Returns the list of mount point names on an host */
131 public native Storage[] getMountedStorage();
132 /** This methods returns the list of storages (names) attached to an host */
133 public native String[] getAttachedStorage();
135 /** After this call, sg_host_get_consumed_energy() will not interrupt your process
136 * (until after the next clock update).
138 public static native void updateAllEnergyConsumptions();
139 /** Returns the amount of Joules consumed by that host so far
141 * Please note that since the consumption is lazily updated, it may require a simcall to update it.
142 * The result is that the actor requesting this value will be interrupted,
143 * the value will be updated in kernel mode before returning the control to the requesting actor.
145 public native double getConsumedEnergy();
147 /** Returns the current load of the host, as a ratio = achieved_flops / (core_current_speed * core_amount)
149 * See simgrid::plugin::HostLoad::get_current_load() for the full documentation.
151 public native double getCurrentLoad();
152 /** Returns the number of flops computed of the host since the beginning of the simulation */
153 public native double getComputedFlops();
154 /** Returns the average load of the host as a ratio since the beginning of the simulation*/
155 public native double getAvgLoad();
157 /** Returns the current pstate */
158 public native int getPstate();
159 /** Changes the current pstate */
160 public native void setPstate(int pstate);
161 public native int getPstatesCount();
162 /** Returns the speed of the processor (in flop/s) at the current pstate. See also @ref plugin_energy. */
163 public native double getCurrentPowerPeak();
164 /** Returns the speed of the processor (in flop/s) at a given pstate. See also @ref plugin_energy. */
165 public native double getPowerPeakAt(int pstate);
167 /** Returns the current computation load (in flops per second) */
168 public native double getLoad();
170 /** Class initializer, to initialize various JNI stuff */
171 private static native void nativeInit();