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;
12 * A host object represents a location (any possible place) where a process may run.
13 * Thus it is represented as a physical resource with computing capabilities, some
14 * mailboxes to enable running process to communicate with remote ones, and some private
15 * data that can be only accessed by local process. An instance of this class is always
16 * bound with the corresponding native host. All the native hosts are automatically created
17 * during the call of the method Msg.createEnvironment(). This method take as parameter a
18 * platform file which describes all elements of the platform (host, link, root..).
19 * You cannot create a host yourself.
21 * The best way to get an host instance is to call the static method
24 * For example to get the instance of the host. If your platform
25 * file description contains an host named "Jacquelin" :
31 jacquelin = Host.getByName("Jacquelin");
32 } catch(HostNotFoundException e) {
33 System.err.println(e.toString());
42 * This attribute represents a bind between a java host object and
43 * a native host. Even if this attribute is public you must never
44 * access to it. It is set automatically during the call of the
45 * static method Host.getByName().
47 * @see Host.getByName().
53 protected String name;
67 public String toString (){
73 * This static method gets an host instance associated with a native
74 * host of your platform. This is the best way to get a java host object.
76 * @param name The name of the host to get.
78 * @return The host object with the given name.
79 * @exception HostNotFoundException if the name of the host is not valid.
80 * NativeException if the native version of this method failed.
82 public native static Host getByName(String name)
83 throws HostNotFoundException, NullPointerException;
85 * This static method returns the count of the installed hosts.
87 * @return The count of the installed hosts.
89 public native static int getCount();
92 * This static method return an instance to the host of the current process.
94 * @return The host on which the current process is executed.
96 public native static Host currentHost();
99 * This static method returns all of the hosts of the installed platform.
101 * @return An array containing all the hosts installed.
104 public native static Host[] all();
107 * This static method sets a mailbox to receive in asynchronous mode.
109 * All messages sent to this mailbox will be transferred to
110 * the receiver without waiting for the receive call.
111 * The receive call will still be necessary to use the received data.
112 * If there is a need to receive some messages asynchronously, and some not,
113 * two different mailboxes should be used.
115 * @param mailboxName The name of the mailbox
117 public static native void setAsyncMailbox(String mailboxName);
121 * This method returns the name of a host.
122 * @return The name of the host.
125 public String getName() {
130 * Sets the data of the host.
133 public void setData(Object data) {
137 * Gets the data of the host.
139 * @return The data object associated with the host.
141 public Object getData() {
146 * Checks whether a host has data.
148 * @return True if the host has an associated data object.
150 public boolean hasData() {
151 return null != this.data;
155 * This method start the host if it is off
157 public native void on();
160 * This method stop the host if it is on
162 public native void off();
166 * This method returns the number of tasks currently running on a host.
167 * The external load is not taken in account.
169 * @return The number of tasks currently running on a host.
171 public native int getLoad();
174 * This method returns the speed of the processor of a host,
175 * regardless of the current load of the machine.
177 * @return The speed of the processor of the host in flops.
180 public native double getSpeed();
183 * This method returns the number of core of a host.
185 * @return The speed of the processor of the host in flops.
188 public native double getCoreNumber();
191 * Returns the value of a given host property.
193 public native String getProperty(String name);
196 * Change the value of a given host property.
198 public native void setProperty(String name, String value);
200 /** This method tests if a host is available.
201 * @return True if the host is available.
203 public native boolean isAvail();
206 * Class initializer, to initialize various JNI stuff
208 public static native void nativeInit();