Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reindent, no change at all
[simgrid.git] / src / java / simgrid / msg / Host.java
1 /*
2  * simgrid.msg.Host.java        1.00 07/05/01
3  *
4  * Copyright 2006,2007 Martin Quinson, Malek Cherier           
5  * All right reserved. 
6  *
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. 
10  *
11  */
12 package simgrid.msg;
13
14 import java.lang.String;
15
16 /**
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.
25  *
26  * The best way to get an host instance is to call the static method 
27  * Host.getByName().
28  *
29  * For example to get the instance of the host. If your platform
30  * file description contains an host named "Jacquelin" :
31  *
32  *      Host jacquelin;
33  *
34  *      try { 
35  *              jacquelin = Host.getByName("Jacquelin");
36  *      } catch(HostNotFoundException e) {
37  *              System.err.println(e.toString());
38  *      }
39  *      ...
40  *
41  * @author  Abdelmalek Cherier
42  * @author  Martin Quinson
43  * @version 1.00, 07/05/01
44  * @see Grid
45  * @see Simulation
46  * @see Process
47  * @since SimGrid 3.3
48  * @since JDK1.5011
49  */
50 public class Host {
51         /**
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().
56          *
57          * @see                         Host.getByName().
58          */
59   public long bind;
60
61         /**
62          * User data.
63          */
64   private Object data;
65
66   protected Host() {
67     this.bind = 0;
68     this.data = null;
69   };
70
71         /**
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.
74          *
75          * @param name          The name of the host to get.
76          *
77          * @exception           HostNotFoundException if the name of the host is not valid.
78          *                                      MsgException if the native version of this method failed.
79          */
80   public static Host getByName(String name)
81   throws HostNotFoundException, NativeException, JniException {
82
83     return Msg.hostGetByName(name);
84   }
85         /**
86          * This static method returns the number of the installed hosts.
87          *
88          * @return                      The number of the installed hosts.
89          *
90          */ public static int getNumber() throws NativeException, JniException {
91     return Msg.hostGetNumber();
92   }
93         /**
94          * This static method return an instance to the host of the current process.
95          *
96          * @return                      The host on which the current process is executed.
97          *
98          * @exception           MsgException if the native version of this method failed.
99          */ public static Host currentHost() throws JniException {
100     return Msg.hostSelf();
101   }
102         /**
103          * This static method returns all of the hosts of the installed platform.
104          *
105          * @return                      An array containing all the hosts installed.
106          *
107          * @exception           MsgException if the native version of this method failed.
108          */ public static Host[] all() throws JniException, NativeException {
109     return Msg.allHosts();
110   }
111         /**
112          * This method returns the name of a host.
113          *
114          * @return                      The name of the host.
115          *
116          * @exception           InvalidHostException if the host is not valid.
117          */ public String getName() throws NativeException, JniException {
118     return Msg.hostGetName(this);
119   }
120         /**
121          * This method sets the data of the host.
122          *
123          */ public void setData(Object data) {
124     this.data = data;
125   }
126
127         /**
128          * This method gets the data of the host.
129          */
130   public Object getData() {
131     return this.data;
132   }
133
134         /**
135          * This function tests if a host has data.
136          */
137   public boolean hasData() {
138     return null != this.data;
139   }
140
141         /**
142          * This method returns the number of tasks currently running on a host.
143          * The external load is not taken in account.
144          *
145          * @return                      The number of tasks currently running on a host.
146          *
147          * @exception           InvalidHostException if the host is invalid.
148          *
149          */
150   public int getLoad() throws JniException {
151     return Msg.hostGetLoad(this);
152   }
153         /**
154          * This method returns the speed of the processor of a host,
155          * regardless of the current load of the machine.
156          *
157          * @return                      The speed of the processor of the host in flops.
158          *
159          * @exception           InvalidHostException if the host is not valid.
160          *
161          */ public double getSpeed() throws JniException {
162     return Msg.hostGetSpeed(this);
163   }
164         /**
165          * This method tests if a host is avail.
166          * 
167          * @return                      If the host is avail the method returns true.
168          *                                      Otherwise the method returns false.
169          *
170          * @exception           JniException if the host is not valid.
171          *
172          *
173          */ public boolean isAvail() throws JniException {
174     return Msg.hostIsAvail(this);
175 }}