Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New version of MAHEVE plus corrections.
[mapping.git] / src / and / Mapping / GNode.java
1 package and.Mapping ;
2
3 import java.io.Serializable;
4
5
6 /**
7  * Class representing a computing node
8  * @author Sébastien Miquée
9  *
10  */
11 public class GNode implements Serializable
12 {
13         private static final long serialVersionUID = 1L;
14         
15         private String name ;
16         private int nb_cores ;
17         private int frequency ;
18         private int mflops ;
19         private int memory ;
20         private Object node ;
21         private long id ;
22         private boolean mapped ;
23         private boolean inCluster ;
24         private String clusterName ;
25         private String siteName ;
26         private String ip ;
27         private Cluster cluster ;
28         
29         
30         /**
31          * Default constructor.
32          */
33         public GNode()
34         {
35                 name = "" ;
36                 clusterName = "" ;
37                 siteName = "" ;
38                 nb_cores = 0 ;
39                 frequency = 0 ;
40                 mflops = 0 ;
41                 memory = 0 ;
42                 node = null ;
43                 id = -1 ;
44                 mapped = false ;
45                 inCluster = false ;
46                 cluster = null ;
47         }
48         
49         
50         public void setCluster( Cluster _cl )
51         {
52                 cluster = _cl ;
53         }
54         
55         public Cluster getCluster()
56         {
57                 return cluster ;
58         }
59         
60         
61         /**
62          * Set the cluster's name in which the computing node is.
63          * @param _c The name of the cluster containing the node
64          */
65         public void setClusterName( String _cn )
66         {
67                 clusterName = _cn ;
68         }
69         
70         
71         /**
72          * Return the cluster's name in which the node is.
73          * @return The cluster's name
74          */
75         public String getClusterName()
76         {
77                 return clusterName ;
78         }
79         
80         
81         /**
82          * Set the site's name in which the computing node is.
83          * @param _s The site's name
84          */
85         public void setSiteName( String _s )
86         {
87                 siteName = _s ;
88         }
89         
90         
91         /**
92          * Return the name of the site in which the computing node is.
93          * @return The site's name
94          */
95         public String getSiteName()
96         {
97                 return siteName ;
98         }
99
100         
101         /**
102          * Change the status of the node concerning its participation in the computation.
103          * @param _b The status of its participation
104          */
105         public void setMapped( boolean _b )
106         {
107                 mapped = _b ;
108         }
109         
110         
111         /**
112          * Return the status of the participation of the computing node.
113          * @return The status of the node
114          */
115         public boolean getMapped()
116         {
117                 return mapped ;
118         }
119         
120         
121         /**
122          * Set the status of the computing node in order to know if
123          * it is in cluster or not. 
124          * @param _b The status of the node
125          */
126         public void setInCluster( boolean _b ) 
127         {
128                 inCluster = _b ;
129         }
130         
131         
132         /**
133          * Return the status of the computing node concerning its
134          * presence, or not, in a cluster.
135          * @return The status of the node
136          */
137         public boolean getInCluster()
138         {
139                 return inCluster ;
140         }
141
142
143         /**
144          * Set the name of the computing node.
145          * @param _name The node's name
146          */
147         public void setName( String _name ) 
148         {
149                 name = _name ;
150         }
151
152
153         /**
154          * Return the name of the computing node
155          * @return The node's name
156          */
157         public String getName() 
158         {
159                 return name ;
160         }
161
162
163         /**
164          * Set the external representation of the node. This object 
165          * represents the node in application using this library.
166          * @param n The external representation of the node
167          */
168         public void setNode( Object n )
169         {
170                 node = n ;
171         }
172         
173         
174         /**
175          * Return the external representation of the node.
176          * @return The external representation of the node
177          */
178         public Object getNode()
179         {
180                 return node ;
181         }
182         
183
184
185         /**
186          * Set the amount of computing cores of the computing node.
187          * @param _nb_cores The amount of cores
188          */
189         public void setNb_cores( int _nb_cores ) 
190         {
191                 nb_cores = _nb_cores;
192         }
193
194         
195         /**
196          * Return the amount of computing cores of the computing node.
197          * @return The amount of cores
198          */
199         public int getNb_cores() 
200         {
201                 return nb_cores;
202         }
203
204
205         /**
206          * Set the frequency of computing cores of the computing node.
207          * @param _freq The frequency of cores
208          */
209         public void setFrequency( int _freq ) 
210         {
211                 frequency = _freq ;
212         }
213
214
215         /**
216          * Return the frequency of computing cores of the computing node.
217          * @return The frequency of cores
218          */
219         public int getFrequency() 
220         {
221                 return frequency ;
222         }
223
224         
225         /**
226          * Set the MFlops of each computing core of the computing node.
227          * @param _mflops The MFlops of cores
228          */
229         public void setMFlops( int _mflops ) 
230         {
231                 mflops = _mflops ;
232         }
233
234
235         /**
236          * Return the MFlops of each computing core of the computing node.
237          * @return The MFlops of cores
238          */
239         public int getMFlops() 
240         {
241                 return mflops ;
242         }
243
244         /**
245          * Set the amount of available memory of the computing node.
246          * @param _mem Amount of memory
247          */
248         public void setMemory( int _mem ) 
249         {
250                 memory = _mem ;
251         }
252         
253         
254         /**
255          * Return the amount of the available memory of the computing node.
256          * @return The amount  of memory
257          */
258         public int getMemory() 
259         {
260                 return memory ;
261         }
262
263
264         /**
265          * Return the computational power of the computing node. It includes
266          * the multiplication of cores by frequency.
267          * @return The computational power of the computing node
268          */
269         public int getPower()
270         {
271                 if( mflops != 0 )
272                 {
273                         return ( nb_cores * mflops ) ;
274                 } else {
275                         return ( nb_cores * frequency ) ;
276                 }
277         }
278         
279         
280         /**
281          * Set the uniq identifier of the computing node.
282          * @param _id The identifier of the node
283          */
284         public void setId( long _id ) 
285         {
286                 id = _id ;
287         }
288         
289         
290         /**
291          * Return the uniq identifier of the computing node.
292          * @return The identifier of the node
293          */
294         public long getId() 
295         {
296                 return id ;
297         }
298         
299         
300         /**
301          * Return the name of the node for the use of the node in a string.
302          * @return The name of the node
303          */
304         public String toString()
305         {
306                 return name ;
307         }
308         
309         
310         /**
311          * Return the IP address of the GNode.
312          * @return The IP address
313          */
314         public String getIP()
315         {
316                 return ip ;
317         }
318         
319         
320         /**
321          * Set the IP address of the GNode.
322          * @param _ip The IP address
323          */
324         public void setIP( String _ip )
325         {
326                 ip = _ip ;
327         }
328         
329         
330         /**
331          * Construct and return a copy of the current GNode.
332          * @return A copy of this node
333          */
334         public GNode clone()
335         {
336                 GNode copy = new GNode() ;
337                 
338                 copy.setName( name ) ;
339                 copy.setNb_cores( nb_cores ) ;
340                 copy.setFrequency( frequency ) ;
341                 copy.setMFlops( mflops ) ;
342                 copy.setMemory( memory ) ;
343                 copy.setNode( node ) ;
344                 copy.setId( id ) ;
345                 copy.setMapped( mapped ) ;
346                 copy.setInCluster( inCluster ) ;
347                 copy.setClusterName( clusterName ) ;
348                 copy.setSiteName( siteName ) ;
349                 copy.setIP( ip ) ;
350
351                 return copy ;
352         }
353         
354 }
355
356 /** La programmation est un art, respectons ceux qui la pratiquent !! **/