From: Sébastien Miquée Date: Wed, 24 Feb 2010 08:59:04 +0000 (+0100) Subject: Adding some new functions. X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/mapping.git/commitdiff_plain/c2eae60162c5550cd94b772f4b67e0dcd4a1191f Adding some new functions. - Adding of functions to facilitate the (re)initialization of nodes' status. -Correction of some bugs. --- diff --git a/src/and/Mapping/Algo.java b/src/and/Mapping/Algo.java index a06171e..608c667 100644 --- a/src/and/Mapping/Algo.java +++ b/src/and/Mapping/Algo.java @@ -99,14 +99,16 @@ public abstract class Algo implements Serializable /** * Update the grid status after having done the mapping. */ - protected void updateGrid() + public void updateGrid() { - if( mp.getMappedGNodes().size() >= 0 ) + if( mp.getMappedGNodes().size() > 0 ) { ArrayList temp = mp.getMappedGNodes() ; for( int i = 0 ; i < temp.size() ; i++ ) { gl.getClusterOfNode( temp.get( i ) ).setGNodeStatus( temp.get( i ), true ) ; + + gl.setMappedStatus( temp.get( i ), true ) ; } } } diff --git a/src/and/Mapping/Cluster.java b/src/and/Mapping/Cluster.java index a9abe87..39c48bd 100644 --- a/src/and/Mapping/Cluster.java +++ b/src/and/Mapping/Cluster.java @@ -209,7 +209,7 @@ public class Cluster implements Serializable // } if( freenodes.size() > 0 ) { - ret = freenodes.remove( 0 ) ; + ret = freenodes.get( 0 ) ; } return ret ; @@ -274,6 +274,26 @@ public class Cluster implements Serializable { return freenodes.size() ; } + + + /** + * Initialization of computing nodes in this cluster. Set all + * of these nodes to be not mapped on. + */ + public void initGNodes() + { + /** Initialization of local nodes **/ + /** and reconstruction of the freenodes list **/ + freenodes = null ; + freenodes = new ArrayList() ; + + for( int i = 0 ; i < nodes.size() ; i++ ) + { + nodes.get( i ).setMapped( false ) ; + + freenodes.add( nodes.get( i ) ) ; + } + } } diff --git a/src/and/Mapping/DefaultMapping.java b/src/and/Mapping/DefaultMapping.java index 1b21ea6..e03cfce 100644 --- a/src/and/Mapping/DefaultMapping.java +++ b/src/and/Mapping/DefaultMapping.java @@ -85,6 +85,8 @@ public class DefaultMapping extends Algo if( _ag.size() > 0 ) { ret = _ag.get( 0 ) ; + + } else { System.err.println( "Not enought available nodes in gnodes to replace one !" ) ; return null ; diff --git a/src/and/Mapping/Grid.java b/src/and/Mapping/Grid.java index 0370940..877ac33 100644 --- a/src/and/Mapping/Grid.java +++ b/src/and/Mapping/Grid.java @@ -408,6 +408,49 @@ public class Grid implements Serializable return hd ; } + /** + * Initialization of computing nodes in the grid. Set all + * of these nodes to be not mapped on, and do the same thing in each + * of its clusters. + */ + public void initGNodes() + { + /** Initialization of the local nodes **/ + for( int i = 0 ; i < gnodesList.size() ; i++ ) + { + gnodesList.get( i ).setMapped( false ) ; + } + + /** Initialization in clusters **/ + for( int i = 0 ; i < clusters.size() ; i++ ) + { + clusters.get( i ).initGNodes() ; + } + } + + + + /** + * Initialization of a set of computing nodes in the grid. Set all + * of these given nodes to be not mapped on, and propagates in each + * of its clusters. + * @param _ag The nodes' list to initialize + */ + public void initGNodes( ArrayList _ag ) + { + if( _ag != null && _ag.size() > 0 ) + { + /** Initialization of the local and clusters nodes **/ + for( int i = 0 ; i < _ag.size() ; i++ ) + { + setMappedStatus( _ag.get( i ), false ) ; + + getClusterOfNode( _ag.get( i ) ).setGNodeStatus( _ag.get( i ), false ) ; + } + } + } + + /** * Print a comprehensible text version of the grid. diff --git a/src/and/Mapping/LSM.java b/src/and/Mapping/LSM.java index c193bc8..75657c3 100644 --- a/src/and/Mapping/LSM.java +++ b/src/and/Mapping/LSM.java @@ -408,16 +408,39 @@ public class LSM extends Algo @Override public GNode replaceNode( GNode _dead, ArrayList _ag ) { + GNode ret = null ; + + /** Updating the grid if there is any modification **/ + if( _ag != null && _ag.size() != 0 ) + { + gl.updateGrid( _ag ) ; + } + + /** If something has to be done **/ + if( _dead != null ) + { + ArrayList ac = new ArrayList() ; + + for( int i = 0 ; i < gl.getNbCluster() ; i++ ) + { + if( gl.getClusters().get( i ).getNbFreeNodes() > 0 ) + { + ac.add( gl.getClusters().get( i ).nextGNode() ) ; + } + } + } + /** Update in cluster the status of nodes **/ updateGrid() ; - return null; + return ret ; } @Override - public GNode getOtherGNode( ArrayList _ag ) { - // TODO Auto-generated method stub + public GNode getOtherGNode( ArrayList _ag ) + { + return null; } diff --git a/src/and/Mapping/Mapping.java b/src/and/Mapping/Mapping.java index c6ee73a..9429df4 100644 --- a/src/and/Mapping/Mapping.java +++ b/src/and/Mapping/Mapping.java @@ -59,9 +59,17 @@ public class Mapping implements Serializable } /** For the usage of algorithms which map groups of tasks on cluster **/ + GNode tmp = null ; for( int i = 0 ; i < at.size() ; i++ ) { - insertMapping( new Association( c.nextGNode(), at.get( i ) ) ) ; + tmp = c.nextGNode() ; + if( tmp != null ) + { + insertMapping( new Association( tmp, at.get( i ) ) ) ; + } else { + System.err.println( "Error during reception of the next GNode !" ) ; + break ; + } } }