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.
14 import java.lang.String;
17 * A host object represents a location (any possible place) where a process may run.
18 * Thus it is represented as a physical resource with computing capabilities, some
19 * mailboxes to enable running process to communicate with remote ones, and some private
20 * data that can be only accessed by local process. An instance of this class is always
21 * binded with the corresponding native host. All the native hosts are automaticaly created
22 * during the call of the method Msg.createEnvironment(). This method take as parameter a
23 * platform file which describes all elements of the platform (host, link, root..).
24 * You never need to create an host your self.
26 * The best way to get an host instance is to call the static method
29 * For example to get the instance of the host. If your platform
30 * file description contains an host named "Jacquelin" :
35 * jacquelin = Host.getByName("Jacquelin");
36 * } catch(HostNotFoundException e) {
37 * System.err.println(e.toString());
41 * @author Abdelmalek Cherier
42 * @author Martin Quinson
43 * @version 1.00, 07/05/01
52 * This attribute represents a bind between a java host object and
53 * a native host. Even if this attribute is public you must never
54 * access to it. It is set automaticatly during the call of the
55 * static method Host.getByName().
57 * @see Host.getByName().
72 * This static method gets an host instance associated with a native
73 * host of your platform. This is the best way to get a java host object.
75 * @param name The name of the host to get.
77 * @exception HostNotFoundException if the name of the host is not valid.
78 * MsgException if the native version of this method failed.
80 public static Host getByName(String name)
81 throws HostNotFoundException, NativeException, JniException {
83 return Msg.hostGetByName(name);
86 * This static method returns the number of the installed hosts.
88 * @return The number of the installed hosts.
90 */ public static int getNumber() throws NativeException, JniException {
91 return Msg.hostGetNumber();
94 * This static method return an instance to the host of the current process.
96 * @return The host on which the current process is executed.
98 * @exception MsgException if the native version of this method failed.
99 */ public static Host currentHost() throws JniException {
100 return Msg.hostSelf();
103 * This static method returns all of the hosts of the installed platform.
105 * @return An array containing all the hosts installed.
107 * @exception MsgException if the native version of this method failed.
108 */ public static Host[] all() throws JniException, NativeException {
109 return Msg.allHosts();
112 * This method returns the name of a host.
114 * @return The name of the host.
116 * @exception InvalidHostException if the host is not valid.
117 */ public String getName() throws NativeException, JniException {
118 return Msg.hostGetName(this);
121 * This method sets the data of the host.
123 */ public void setData(Object data) {
128 * This method gets the data of the host.
130 public Object getData() {
135 * This function tests if a host has data.
137 public boolean hasData() {
138 return null != this.data;
142 * This method returns the number of tasks currently running on a host.
143 * The external load is not taken in account.
145 * @return The number of tasks currently running on a host.
147 * @exception InvalidHostException if the host is invalid.
150 public int getLoad() throws JniException {
151 return Msg.hostGetLoad(this);
154 * This method returns the speed of the processor of a host,
155 * regardless of the current load of the machine.
157 * @return The speed of the processor of the host in flops.
159 * @exception InvalidHostException if the host is not valid.
161 */ public double getSpeed() throws JniException {
162 return Msg.hostGetSpeed(this);
165 * This method tests if a host is avail.
167 * @return If the host is avail the method returns true.
168 * Otherwise the method returns false.
170 * @exception JniException if the host is not valid.
173 */ public boolean isAvail() throws JniException {
174 return Msg.hostIsAvail(this);