1 /* Bindings to the MSG hosts */
3 /* Copyright (c) 2006-2014. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 package org.simgrid.msg;
11 import org.simgrid.msg.Storage;
14 * A host object represents a location (any possible place) where a process may run.
15 * Thus it is represented as a physical resource with computing capabilities, some
16 * mailboxes to enable running process to communicate with remote ones, and some private
17 * data that can be only accessed by local process. An instance of this class is always
18 * bound with the corresponding native host. All the native hosts are automatically created
19 * during the call of the method Msg.createEnvironment(). This method take as parameter a
20 * platform file which describes all elements of the platform (host, link, root..).
21 * You cannot create a host yourself.
23 * The best way to get an host instance is to call the static method
26 * For example to get the instance of the host. If your platform
27 * file description contains an host named "Jacquelin" :
33 jacquelin = Host.getByName("Jacquelin");
34 } catch(HostNotFoundException e) {
35 System.err.println(e.toString());
44 * This attribute represents a bind between a java host object and
45 * a native host. Even if this attribute is public you must never
46 * access to it. It is set automatically during the call of the
47 * static method Host.getByName().
49 * @see Host.getByName().
55 protected String name;
70 public String toString (){
76 * This static method gets an host instance associated with a native
77 * host of your platform. This is the best way to get a java host object.
79 * @param name The name of the host to get.
81 * @return The host object with the given name.
82 * @exception HostNotFoundException if the name of the host is not valid.
83 * NativeException if the native version of this method failed.
85 public native static Host getByName(String name)
86 throws HostNotFoundException, NullPointerException;
88 * This static method returns the count of the installed hosts.
90 * @return The count of the installed hosts.
92 public native static int getCount();
95 * This static method return an instance to the host of the current process.
97 * @return The host on which the current process is executed.
99 public native static Host currentHost();
102 * This static method returns all of the hosts of the installed platform.
104 * @return An array containing all the hosts installed.
107 public native static Host[] all();
110 * This static method sets a mailbox to receive in asynchronous mode.
112 * All messages sent to this mailbox will be transferred to
113 * the receiver without waiting for the receive call.
114 * The receive call will still be necessary to use the received data.
115 * If there is a need to receive some messages asynchronously, and some not,
116 * two different mailboxes should be used.
118 * @param mailboxName The name of the mailbox
120 public static native void setAsyncMailbox(String mailboxName);
124 * This method returns the name of a host.
125 * @return The name of the host.
128 public String getName() {
133 * Sets the data of the host.
136 public void setData(Object data) {
140 * Gets the data of the host.
142 * @return The data object associated with the host.
144 public Object getData() {
149 * Checks whether a host has data.
151 * @return True if the host has an associated data object.
153 public boolean hasData() {
154 return null != this.data;
158 * This method start the host if it is off
160 public native void on();
163 * This method stop the host if it is on
165 public native void off();
169 * This method returns the speed of the processor of a host,
170 * regardless of the current load of the machine.
172 * @return The speed of the processor of the host in flops.
175 public native double getSpeed();
178 * This method returns the number of core of a host.
180 * @return The speed of the processor of the host in flops.
183 public native double getCoreNumber();
186 * Returns the value of a given host property.
188 public native String getProperty(String name);
191 * Change the value of a given host property.
193 public native void setProperty(String name, String value);
195 /** This method tests if a host is up and running.
196 * @return True if the host is available.
198 public native boolean isOn();
200 /** This methods returns the list of mount point names on an host
201 * @return An array containing all mounted storages on the host
203 public native Storage[] getMountedStorage();
205 /** This methods returns the list of storages attached to an host
206 * @return An array containing all storages (name) attached to the host
208 public native String[] getAttachedStorage();
210 /** Returns the amount of Joules consumed by that host so far */
211 public native double getConsumedEnergy();
214 * Class initializer, to initialize various JNI stuff
216 public static native void nativeInit();