+
+ /**
+ * Replace a node in the cluster (in case of a reconnection for example).
+ * @param _g The node to be replaced
+ */
+ public void replaceGNode( GNode _g )
+ {
+ if( _g != null )
+ {
+ removeGNode( _g ) ;
+ addGNode( _g ) ;
+ }
+ }
+
+
+ /**
+ * Search and return the better (most powerful) available node
+ * of the cluster.
+ * @return The best available node
+ */
+ public GNode getBetterFreeGNode()
+ {
+ GNode ret = null ;
+
+ if( freenodes.size() > 0 )
+ {
+ ret = freenodes.get( 0 ) ;
+ }
+
+ for( int i = 1 ; i < freenodes.size() ; i++ )
+ {
+ if( freenodes.get( i ).getPower() > ret.getPower() )
+ {
+ ret = freenodes.get( i ) ;
+ }
+ }
+
+ return ret ;
+ }
+
+
+ /**
+ * Construct and return a copy of the current Cluster.
+ * @return A copy of the cluster
+ */
+ public Cluster clone()
+ {
+ Cluster copy = new Cluster() ;
+
+ copy.setName( name ) ;
+ copy.setSite( site ) ;
+
+ for( int i = 0 ; i < nodes.size() ; i++ )
+ {
+ GNode newgn = (GNode) nodes.get( i ).clone() ;
+ newgn.setCluster( copy ) ;
+ copy.addGNode( newgn ) ;
+ }
+
+ return copy ;
+ }
+