X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/mapping.git/blobdiff_plain/919cd5f7e473b8b22b46a6b6c221341ca8cd738b..b927e5a90765eb39b8f2b02706e522c7db8fce3e:/src/and/Mapping/Grid.java diff --git a/src/and/Mapping/Grid.java b/src/and/Mapping/Grid.java index b9a6efa..eb3fb4f 100644 --- a/src/and/Mapping/Grid.java +++ b/src/and/Mapping/Grid.java @@ -30,7 +30,7 @@ public class Grid implements Serializable nb_cluster = 0 ; nb_node = 0 ; clusters = new ArrayList() ; - gnodesList = null ; + gnodesList = new ArrayList() ; gnodesList_done = false ; } @@ -58,11 +58,19 @@ public class Grid implements Serializable { if( al != null ) { + int nbCLusterNodes = 0 ; + for( int i = 0 ; i < al.size() ; i++ ) { clusters.add( al.get( i ) ) ; nb_cluster ++ ; - nb_node += al.get( i ).getNbGNode() ; + nbCLusterNodes = al.get( i ).getNbGNode() ; + nb_node += nbCLusterNodes ; + + for( int j = 0 ; j < nbCLusterNodes ; j++ ) + { + gnodesList.add( al.get( i ).getGNodes().get( j ) ) ; + } } } } @@ -188,8 +196,8 @@ public class Grid implements Serializable /** - * Plop !! - * @param _gnodes + * Upgrade the grid with new nodes. + * @param _gnodes The list of new nodes */ public void updateGrid( ArrayList _gnodes ) { @@ -197,7 +205,55 @@ public class Grid implements Serializable { 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 ; @@ -220,7 +276,7 @@ public class Grid implements Serializable 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 )) @@ -232,7 +288,7 @@ public class Grid implements Serializable } } - /* 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() ) @@ -250,14 +306,48 @@ public class Grid implements Serializable /** * Compute the heterogeneity degree of the grid. - * This is based on a ratio between the average and the - * standard deviation of computing nodes' power. + * This is based on the relative standard deviation. * @return The heterogeneity degree of the grid */ public double getHeterogenityDegre() { + if( nb_node != gnodesList.size() ) + { + System.err.println( "Mapping - Heterogeneity degree computation! " + + "List's size not corresponding!" ) ; + return -1 ; + } + double hd = -1 ; + double average = 0 ; + double std = 0 ; + double temp = 0 ; + + /** Computation of the average power of computing nodes **/ + for( int i = 0 ; i < nb_node ; i++ ) + { + temp += gnodesList.get(i).getPower() ; + } + + average = temp / nb_node ; + + /** Computation of the variance **/ + temp = 0 ; + for( int i = 0 ; i < nb_node ; i++ ) + { + temp += Math.pow( ( gnodesList.get(i).getPower() - average ), 2 ) ; + } + + /** Computation of the standard deviation **/ + temp = temp / nb_node ; + std = Math.sqrt( temp ) ; + + /** Computation of the relative standard deviation + * plus modifications + */ + hd = 100 * std / average / 10 ; + return hd ; }