Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adding some new functions.
authorSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Wed, 24 Feb 2010 08:59:04 +0000 (09:59 +0100)
committerSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Wed, 24 Feb 2010 08:59:04 +0000 (09:59 +0100)
- Adding of functions to facilitate the (re)initialization of
  nodes' status.

-Correction of some bugs.

src/and/Mapping/Algo.java
src/and/Mapping/Cluster.java
src/and/Mapping/DefaultMapping.java
src/and/Mapping/Grid.java
src/and/Mapping/LSM.java
src/and/Mapping/Mapping.java

index a06171e..608c667 100644 (file)
@@ -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<GNode> 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 ) ;
                        }
                }
        }
index a9abe87..39c48bd 100644 (file)
@@ -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<GNode>() ;
+               
+               for( int i = 0 ; i < nodes.size() ; i++ )
+               {
+                       nodes.get( i ).setMapped( false ) ;
+                       
+                       freenodes.add( nodes.get( i ) ) ;
+               }
+       }
        
 }
 
index 1b21ea6..e03cfce 100644 (file)
@@ -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 ;
index 0370940..877ac33 100644 (file)
@@ -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<GNode> _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.
index c193bc8..75657c3 100644 (file)
@@ -408,16 +408,39 @@ public class LSM extends Algo
        @Override
        public GNode replaceNode( GNode _dead, ArrayList<GNode> _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<GNode> ac = new ArrayList<GNode>() ;
+               
+                       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<GNode> _ag ) {
-               // TODO Auto-generated method stub
+       public GNode getOtherGNode( ArrayList<GNode> _ag ) 
+       {
+               
                return null;
        }
        
index c6ee73a..9429df4 100644 (file)
@@ -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 ;
+                       }
                }
        }