- Implementing the update of the grid architecture with new nodes.
- Allowing to remove nodes from the grid.
{
return mp ;
}
+
+
+ /**
+ * Return the grid used in the algorithm.
+ * @return The Grid
+ */
+ public Grid getGrid()
+ {
+ return gl ;
+ }
+
+
+ /**
+ * Return the graph used in the algorithm.
+ * @return The Graph
+ */
+ public Graph getGraph()
+ {
+ return gr ;
+ }
}
/** La programmation est un art, respectons ceux qui la pratiquent !! **/
{
if( _g != null )
{
- if( nodes.contains( _g ) )
+ for( int i = 0; i < nodes.size(); i ++ )
{
- return true ;
+ if( nodes.get( i ).getId() == _g.getId() )
+ return true ;
}
}
return id ;
}
+
+ /**
+ * Return the name of the node for the use of the node in a string.
+ * @return The name of the node
+ */
+ public String toString()
+ {
+ return name ;
+ }
+
}
/** La programmation est un art, respectons ceux qui la pratiquent !! **/
/**
- * Plop !!
- * @param _gnodes
+ * Upgrade the grid with new nodes.
+ * @param _gnodes The list of new nodes
*/
public void updateGrid( ArrayList<GNode> _gnodes )
{
{
for( int i = 0 ; i < _gnodes.size() ; i++ )
{
+ /** Searching the cluster in which the node should be added **/
+ int j = 0 ;
+ for( j = 0; j < clusters.size(); j++ )
+ {
+ if( _gnodes.get( i ).getCluster().equalsIgnoreCase( clusters.get( j ).getName() ) )
+ {
+ if( ! clusters.get( j ).isIn( _gnodes.get( i ) ) )
+ {
+ _gnodes.get( i ).setCluster( clusters.get( j ).getName() ) ;
+ _gnodes.get( i ).setSite( clusters.get( j ).getSite() ) ;
+ _gnodes.get( i ).setInCluster( true ) ;
+ _gnodes.get( i ).setMapped( false ) ;
+
+ clusters.get( i ).addGNode( _gnodes.get( j ) ) ;
+ nb_node++ ;
+ gnodesList.add( _gnodes.get( i ) ) ;
+ }
+
+ break ;
+ }
+ }
+ /** The cluster was not found, so it is a new one **/
+ if( j == clusters.size() )
+ {
+ String site = "", cluster = "" ;
+ Cluster nClust = new Cluster() ;
+
+
+ String names[] = Utils.decodeG5Knames( _gnodes.get( i ).getName() ) ;
+
+ cluster = names[ 1 ] ;
+ site = names[ 2 ] ;
+
+ nClust.setName( cluster ) ;
+ nClust.setSite( site ) ;
+
+ _gnodes.get( i ).setInCluster( true ) ;
+ _gnodes.get( i ).setMapped( false ) ;
+ _gnodes.get( i ).setSite( site ) ;
+ _gnodes.get( i ).setCluster( cluster ) ;
+
+ nClust.addGNode( _gnodes.get( i ) ) ;
+ nb_cluster++ ;
+
+ clusters.add( nClust ) ;
+ nb_node++ ;
+ gnodesList.add( _gnodes.get( i ) ) ;
+ }
}
gnodesList_done = false ;
site = _dead.getSite() ;
cluster = _dead.getCluster() ;
- /* Removing GNode from its cluster */
+ /** Removing GNode from its cluster **/
for( int j = 0 ; j < clusters.size() ; j++ )
{
if( clusters.get( j ).getName().equals( cluster ) && clusters.get( j ).getSite().equals( site ))
}
}
- /* Removing the dead node from the global list */
+ /** Removing the dead node from the global list **/
for( int i = 0 ; i < nb_node ; i++ )
{
if( _dead.getId() == gnodesList.get( i ).getId() )
if( _an != null )
{
- String temp ;
- String nom, cluster, site ;
-
+ String cluster = "", site = "" ;
ArrayList<Cluster> clusters = new ArrayList<Cluster>() ;
for( int i = 0 ; i < _an.size() ; i++ )
{
/* Variables edition */
- String tab[] = new String[ 5 ] ;
-
- temp = _an.get( i ).getName().trim().replace('.', '!' ) ;
-
- tab = temp.split( "!" ) ;
-
- nom = tab[ 0 ] ;
- site = tab[ 1 ] ;
-
- tab = nom.split( "-" ) ;
- // IUT
- //cluster = "iut" ;
+ String names[] = decodeG5Knames( _an.get( i ).getName() ) ;
- // G5K
- cluster = tab[ 0 ] ;
+ cluster = names[ 1 ] ;
+ site = names[ 2 ] ;
- //System.out.println( nom + " dans " + cluster + " du site " + site ) ;
-
-
- /* Insertion du noeud dans son cluster */
+ /* Insertion of the node in its cluster */
boolean trouve = false ;
for( int j = 0 ; j < clusters.size() ; j++ )
if( clusters.get( j ).getName().equals( cluster ) && clusters.get( j ).getSite().equals( site ))
{
_an.get( i ).setInCluster( true ) ;
+ _an.get( i ).setMapped( false ) ;
_an.get( i ).setSite( clusters.get( j ).getSite() ) ;
_an.get( i ).setCluster( clusters.get( j ).getName() ) ;
clusters.get( j ).addGNode( _an.get( i ) ) ;
cl.setSite( site ) ;
_an.get( i ).setInCluster( true ) ;
+ _an.get( i ).setMapped( false ) ;
_an.get( i ).setSite( site ) ;
_an.get( i ).setCluster( cluster ) ;
}
+ /**
+ * Return the three parts of the name of a node on Grid'5000.
+ * @param _name The full name of the G5K node
+ * @return The three parts of the name
+ */
+ protected static String[] decodeG5Knames( String _name )
+ {
+ String temp = "" ;
+ String tab[] = new String[ 5 ] ;
+ String ret[] = new String[ 3 ] ;
+
+ temp = _name.replace('.', '!' ) ;
+
+ tab = temp.split( "!" ) ;
+
+ ret[0] = tab[ 0 ] ;
+ ret[2] = tab[ 1 ] ;
+
+ tab = ret[0].split( "-" ) ;
+
+ ret[ 1 ] = tab[ 0 ] ;
+
+ return ret ;
+ }
+
+
/**
* Write the Grid object in an XML file.
* @param _gl Grid graph to be write