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