2 * simgrid.msg.Host.java 1.00 07/05/01
4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
7 * This program is free software; you can redistribute
8 * it and/or modify it under the terms of the license
9 *(GNU LGPL) which comes with this package.
13 import java.lang.String;
16 * A host object represents a location (any possible place) where a process may run.
17 * Thus it is represented as a physical resource with computing capabilities, some
18 * mailboxes to enable running process to communicate with remote ones, and some private
19 * data that can be only accessed by local process. An instance of this class is always
20 * binded with the corresponding native host. All the native hosts are automaticaly created
21 * during the call of the method Msg.createEnvironment(). This method take as parameter a
22 * platform file which describes all elements of the platform (host, link, root..).
23 * You never need to create an host your self.
25 * The best way to get an host instance is to call the static method
28 * For example to get the instance of the host. If your platform
29 * file description contains an host named "Jacquelin" :
35 * jacquelin = Host.getByName("Jacquelin");
36 * } catch(HostNotFoundException e) {
37 * System.err.println(e.toString());
42 * @author Abdelmalek Cherier
43 * @author Martin Quinson
49 * This attribute represents a bind between a java host object and
50 * a native host. Even if this attribute is public you must never
51 * access to it. It is set automaticatly during the call of the
52 * static method Host.getByName().
54 * @see Host.getByName().
69 * This static method gets an host instance associated with a native
70 * host of your platform. This is the best way to get a java host object.
72 * @param name The name of the host to get.
74 * @exception HostNotFoundException if the name of the host is not valid.
75 * MsgException if the native version of this method failed.
77 public static Host getByName(String name)
78 throws HostNotFoundException, NativeException, JniException {
79 return MsgNative.hostGetByName(name);
83 * This static method returns the number of the installed hosts.
85 * @return The number of the installed hosts.
88 public static int getNumber() throws NativeException, JniException {
89 return MsgNative.hostGetNumber();
93 * This static method return an instance to the host of the current process.
95 * @return The host on which the current process is executed.
97 * @exception MsgException if the native version of this method failed.
99 public static Host currentHost() throws JniException {
100 return MsgNative.hostSelf();
104 * This static method returns all of the hosts of the installed platform.
106 * @return An array containing all the hosts installed.
108 * @exception MsgException if the native version of this method failed.
110 public static Host[] all() throws JniException, NativeException {
111 return MsgNative.allHosts();
115 * This method returns the name of a host.
117 * @return The name of the host.
119 * @exception InvalidHostException if the host is not valid.
121 public String getName() throws NativeException, JniException {
122 return MsgNative.hostGetName(this);
126 * This method sets the data of the host.
129 public void setData(Object data) {
133 * This method gets the data of the host.
135 public Object getData() {
140 * This function tests if a host has data.
142 public boolean hasData() {
143 return null != this.data;
147 * This method returns the number of tasks currently running on a host.
148 * The external load is not taken in account.
150 * @return The number of tasks currently running on a host.
152 * @exception InvalidHostException if the host is invalid.
155 public int getLoad() throws JniException {
156 return MsgNative.hostGetLoad(this);
160 * This method returns the speed of the processor of a host,
161 * regardless of the current load of the machine.
163 * @return The speed of the processor of the host in flops.
165 * @exception InvalidHostException if the host is not valid.
168 public double getSpeed() throws JniException {
169 return MsgNative.hostGetSpeed(this);
173 * This method tests if a host is avail.
175 * @exception JniException if the host is not valid.
177 public boolean isAvail() throws JniException {
178 return MsgNative.hostIsAvail(this);
181 /** Send the given task to the given channel of the host */
183 public void put(int channel, Task task) throws JniException,
185 MsgNative.hostPut(this, channel, task, -1);
187 /** Send the given task to the given channel of the host (waiting at most #timeout seconds) */
189 public void put(int channel, Task task,
190 double timeout) throws JniException, NativeException {
191 MsgNative.hostPut(this, channel, task, timeout);
193 /** Send the given task to the given channel of the host (capping the emision rate to #maxrate) */
195 public void putBounded(int channel, Task task,
196 double maxrate) throws JniException,
198 MsgNative.hostPutBounded(this, channel, task, maxrate);