Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill an unimplemented function. Fix #14
[simgrid.git] / src / bindings / java / org / simgrid / msg / Host.java
1 /* Bindings to the MSG hosts */
2
3 /* Copyright (c) 2006-2014. The SimGrid Team.
4  * All rights reserved.                                                     */
5
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. */
8
9 package org.simgrid.msg;
10
11 import org.simgrid.msg.Storage;
12
13 /**
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.
22  *
23  * The best way to get an host instance is to call the static method 
24  * Host.getByName().
25  *
26  * For example to get the instance of the host. If your platform
27  * file description contains an host named "Jacquelin" :
28  *
29  * \verbatim
30 Host jacquelin;
31
32 try { 
33         jacquelin = Host.getByName("Jacquelin");
34 } catch(HostNotFoundException e) {
35         System.err.println(e.toString());
36 }
37 ...
38 \endverbatim
39  *
40  */ 
41 public class Host {
42
43         /**
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().
48          *
49          * @see                         Host.getByName().
50          */ 
51         private long bind;
52         /**
53          * Host name
54          */
55         protected String name;
56
57         /**
58          * User data.
59          */ 
60         private Object data;
61         /**
62          *
63          */
64         protected Host() {
65                 this.bind = 0;
66                 this.data = null;
67         };
68
69         public String toString (){
70                 return this.name; 
71
72         }
73
74         /**
75          * This static method gets an host instance associated with a native
76          * host of your platform. This is the best way to get a java host object.
77          *
78          * @param name          The name of the host to get.
79          *
80          * @return              The host object with the given name.
81          * @exception           HostNotFoundException if the name of the host is not valid.
82          *                                      NativeException if the native version of this method failed.
83          */ 
84         public native static Host getByName(String name) 
85                         throws HostNotFoundException, NullPointerException;
86         /**
87          * This static method returns the count of the installed hosts.
88          *
89          * @return                      The count of the installed hosts.
90          */ 
91         public native static int getCount();
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         public native static Host currentHost();
99
100         /**
101          * This static method returns all of the hosts of the installed platform.
102          *
103          * @return                      An array containing all the hosts installed.
104          *
105          */ 
106         public native static Host[] all();
107
108         /** 
109          * This static method sets a mailbox to receive in asynchronous mode.
110          * 
111          * All messages sent to this mailbox will be transferred to 
112          * the receiver without waiting for the receive call. 
113          * The receive call will still be necessary to use the received data.
114          * If there is a need to receive some messages asynchronously, and some not, 
115          * two different mailboxes should be used.
116          *
117          * @param mailboxName The name of the mailbox
118          */
119         public static native void setAsyncMailbox(String mailboxName);
120
121
122         /**
123          * This method returns the name of a host.
124          * @return                      The name of the host.
125          *
126          */ 
127         public String getName() {
128                 return name;
129         }
130
131         /**
132          * Sets the data of the host.
133          * @param data
134          */
135         public void setData(Object data) {
136                 this.data = data;
137         } 
138         /**
139          * Gets the data of the host.
140          *
141          * @return The data object associated with the host.
142          */
143         public Object getData() {
144                 return this.data;
145         }
146
147         /**
148          * Checks whether a host has data.
149          *
150          * @return True if the host has an associated data object.
151          */
152         public boolean hasData() {
153                 return null != this.data;
154         }
155
156         /**
157          * This method start the host if it is off
158          */ 
159         public native void on();
160
161         /**
162          * This method stop the host if it is on
163          */ 
164         public native void off();
165
166
167         /**
168          * This method returns the number of tasks currently running on a host.
169          * The external load is not taken in account.
170          *
171          * @return                      The number of tasks currently running on a host.
172          */ 
173         public native int getLoad();
174
175         /**
176          * This method returns the speed of the processor of a host,
177          * regardless of the current load of the machine.
178          *
179          * @return                      The speed of the processor of the host in flops.
180          *
181          */ 
182         public native double getSpeed();
183
184         /**
185          * This method returns the number of core of a host.
186          *
187          * @return                      The speed of the processor of the host in flops.
188          *
189          */ 
190         public native double getCoreNumber();
191
192         /**
193          * Returns the value of a given host property. 
194          */
195         public native String getProperty(String name);
196
197         /**
198          * Change the value of a given host property. 
199          */
200         public native void setProperty(String name, String value);
201
202         /** This method tests if a host is up and running.
203          * @return True if the host is available.
204          */
205         public native boolean isOn();
206
207         /** This methods returns the list of mount point names on an host
208          * @return An array containing all mounted storages on the host
209          */
210         public native Storage[] getMountedStorage();
211
212         /** This methods returns the list of storages attached to an host
213          * @return An array containing all storages (name) attached to the host
214          */
215         public native String[] getAttachedStorage();
216
217
218         /**
219          * Class initializer, to initialize various JNI stuff
220          */
221         public static native void nativeInit();
222         static {
223                 nativeInit();
224         }       
225