Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Minor corrections.
[jaceP2P.git] / src / jaceP2P / JaceSuperNodeServer.java
index 0200806..8bee6cf 100644 (file)
@@ -7,14 +7,14 @@ import java.util.Vector;
 
 import and.Mapping.Algo;
 import and.Mapping.DefaultMapping;
+import and.Mapping.FT_AIAC_QM;
+import and.Mapping.FT_FEC;
 import and.Mapping.GNode;
 import and.Mapping.GTask;
 import and.Mapping.Graph;
 import and.Mapping.Grid;
-import and.Mapping.LSM;
-import and.Mapping.QM;
+import and.Mapping.Maheve;
 import and.Mapping.Simple;
-import and.Mapping.Utils;
 
 
 public class JaceSuperNodeServer extends UnicastRemoteObject implements
@@ -24,10 +24,8 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        // Attributes
        private int beat;
        private ArrayList<GNode> gnodes = null;
-       private Algo al = null ;
-       private int count = 0 ;
+       private ArrayList<Algo> algos = null ;
        private boolean inDemand = false, operating = false, authorized = false ;
-//     private boolean daemonListChange ;
        
        // Constructors
 
@@ -35,7 +33,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                super() ;
                beat = timeBeat ;
                gnodes = new ArrayList<GNode>() ;
-//             daemonListChange = true ;
+               algos = new ArrayList<Algo>() ;
        }
 
        public int getSuperNodeBeat() throws RemoteException {
@@ -127,24 +125,26 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                // Create the node
                Node noeud = new Node(workerStub);
                noeud.setName(workerName);
-               noeud.setIP(workerIP);
+               noeud.setIP(g.getIP());
                noeud.setAliveFlag(true);
                noeud.setAliveTime();
                noeud.setPort(port);
                noeud.setAppliName(null);
                noeud.setNbOfBeats(0);
-               noeud.setId( count ) ;
-               noeud.setId( Long.parseLong( workerIP.replace( ".", "" ) ) ) ;
+               
+               String sid = workerIP.replace( ".", "" ) + port ;
+               Long id = Long.parseLong( sid ) ;
+               noeud.setId( id ) ;
 
                g.setNode( noeud ) ;
-               g.setId( noeud.getId() ) ;
+               g.setId( id ) ;
                g.setMapped( false ) ;
                
                workingOnGnodes() ;
                
                gnodes.add( g ) ;
+               updateGrids( g ) ;
                
-//             daemonListChange = true ;
 
                // Insert the node in the Register.Instance() of the Super Node
                Register.Instance().addNode(noeud);
@@ -168,6 +168,25 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                operating = false ;
        }
 
+       
+       /**
+        * Update all mapping algorithms with a new node.
+        * @param _g The new node
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e
+        */
+       private synchronized void updateGrids( GNode _g )
+       {
+               if( _g != null )
+               {
+                       for( int i = 0 ; i < algos.size() ; i++ )
+                       {
+                               algos.get( i ).getGrid().addGNode( _g ) ;
+                       }
+               }
+               
+       }
+
        /****************************************************/
        /****************************************************/
 
@@ -216,18 +235,18 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
         * @author S&eacute;bastien Miqu&eacute;e        
         */
        @Override
-       public Register getRegisterSpawner(String spawnerIP, int nbTasks, Task t,
+       public synchronized Register getRegisterSpawner(String spawnerIP, int nbTasks, Task t,
                        int nbNoeuds, int algo, double paramAlgo) throws RemoteException {
 
                // Have we the correct application ?
-               if (t == null) {
-                       System.err.println( "Problem of class transmission !" ) ;
+               if( t == null ) {
+                       System.err.println( "Problem of class transmission!" ) ;
                        return null ;
                }
                
                if( t.getDependencies( 0 ) == null )
                {
-                       System.err.println( "No redifinition of getDependencies() function!" ) ;
+                       System.err.println( "No redifinition of getDependencies() function!" ) ;
                        return null ;
                }
                
@@ -238,32 +257,40 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                workingOnGnodes() ;
                
                /** Initialization of Grid architecture (G5K for now) **/
-               Grid grid = Utils.createGridG5k(gnodes);
-//             grid.initClusters();
+               Grid grid = new Grid() ;
+
+               for( int i = 0 ; i < gnodes.size() ; i++ )
+               {
+                       grid.addGNode( gnodes.get( i ) ) ;
+               }
+               
+               
+               /** Informing about the grid heterogeneity **/
+               System.out.println( "\nHeterogeneity degree of the grid: " + grid.getHeterogenityDegre() + "\n" ) ;
                
 
                /** Creation of tasks GTask **/
                ArrayList<GTask> ts = new ArrayList<GTask>();
-               for (int i = 0; i < nbTasks; i++) {
-                       ts.add(new GTask( i ) ) ;
+               for( int i = 0; i < nbTasks; i++ ) {
+                       ts.add( new GTask( i ) ) ;
                }
 
                /** Research of dependencies **/
-               for (int i = 0; i < nbTasks; i++) {
-                       int dep[] = null;
-                       dep = t.getDependencies(i);
+               for( int i = 0; i < nbTasks; i++ ) {
+                       int dep[] = null ;
+                       dep = t.getDependencies( i ) ;
 
                        /** Adding dependencies to tasks **/
-                       for (int j = 0; j < dep.length; j++) {
-                               if (dep[j] != -1) {
-                                       ts.get(i).addDependance(ts.get(dep[j]));
+                       for( int j = 0; j < dep.length; j++ ) {
+                               if( dep[j] != -1 ) {
+                                       ts.get( i ).addDependance( ts.get( dep[ j ] ) ) ;
                                } else {
-                                       break;
+                                       break ;
                                }
                        }
                }
                
-
+               /** Creation of the application interaction graph **/
                Graph graph = new Graph();
 
                for( int i = 0 ; i < ts.size() ; i++) 
@@ -271,51 +298,61 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        graph.addGTask(ts.get(i));
                }
 
-               // -- debug !
-               // graph.print() ;
-
-               // try {
-               // Thread.sleep(10000) ;
-               // } catch( Exception e ) {}
-
-               // grid.print() ;
-               // 
-               // try {
-               // Thread.sleep( 10000 ) ;
-               // } catch( Exception e ) {}
-
+               /** TODO Loading algorithm class with parameters in a configuration file **/
                /** Selection of the mapping algorithm **/
-               al = null ;
+               Algo al = null ;
 
-               switch (algo) {
+               switch( algo ) {
                case 0:
                        al = new Simple(graph, grid);
                        break;
                case 1:
-                       al = new QM(graph, grid, paramAlgo);
+                       al = new FT_AIAC_QM(graph, grid, paramAlgo);
                        break;
                case 2:
-                       al = new LSM(graph, grid, paramAlgo);
+                       al = new FT_FEC(graph, grid, paramAlgo);
                        break;
+               case 3:
+                       al = new Maheve( graph, grid ) ;
+                       ((Maheve) al).setNbSave((int)paramAlgo);
+                       break ;
                default:
                        al = new DefaultMapping( graph, grid, gnodes ) ;
                }
 
-               if (al != null) {
+               if (al != null) 
+               {
                        /** Launching the Mapping **/
                        al.map();
 
 
                        /** Creating the register **/
                        ArrayList<GNode> ag = al.getMapping().getMappedGNodes();
+                       
+                       System.out.println("NB returned nodes : "+ag.size());
 
+                       
+                       /** Setting the algorithm's identifier **/
+                       al.setIdS( spawnerIP ) ;
+                       
+                       /** Adding the algorithm in the list **/
+                       algos.add( al ) ;
+                       
+                       int idAlgo = searchAlgo( spawnerIP ) ;
+                       
+                       /** Mapping distribution over other SuperNodes */
+                       SuperNodeListe.Instance().setMapping( al ) ;
+                       
+                       
+                       
                        authorized = true ;
                        
                        for( int i = 0; i < ag.size(); i++ ) {
                                reg.addNode((Node) ag.get(i).getNode());
-                               delGNodeFromList( (Node) ag.get(i).getNode(), 2 ) ;
-//                             gnodes.remove(ag.get(i));
-//                             Register.Instance().removeNode((Node) ag.get(i).getNode());
+                               
+                               ag.get(i).setMapped( true ) ;
+                               setMapped( ag.get(i), 1 ) ;
+                               Register.Instance().removeNode((Node) ag.get(i).getNode());
                        }
                        
                        
@@ -327,9 +364,11 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                                
                                for( int i = 0 ; i < nb ; i ++ )
                                {
-                                       sup = al.getOtherGNode( gnodes ) ;
+                                       sup = algos.get(idAlgo).getOtherGNode( gnodes ) ;
+                                       algos.get(idAlgo).getMapping().addOtherNode( sup ) ;
                                        reg.addNodeBeg( (Node) sup.getNode() ) ;
-                                       delGNodeFromList( (Node) sup.getNode(), 2 ) ;
+                                       setMapped( sup, 1 ) ;
+                                       Register.Instance().removeNode((Node) sup.getNode());
                                }
                        }
                        
@@ -341,11 +380,6 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
 
                } 
                
-//             System.out.println( "Spawner returned reg: " + reg ) ;
-               
-               /** Mapping distribution over other SuperNodes */
-               SuperNodeListe.Instance().setMapping( al ) ;
-               
                operating = false ;
                
                /** Returning result **/
@@ -353,6 +387,39 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        }
 
        
+       public synchronized void setMapped( GNode _g, int _mode ) throws RemoteException 
+       {
+               if( _g != null )
+               {
+                       _g.setMapped( true ) ;
+                       
+                       for( int i = 0 ; i < gnodes.size() ; i++ )
+                       {
+                               if( _g.getId() == gnodes.get( i ).getId() )
+                               {
+                                       gnodes.remove( i ) ;
+                                       break ;
+                               }
+                       }
+                       
+                       for( int i = 0 ; i < algos.size() ; i++ )
+                       {
+                               algos.get( i ).getGrid().setMappedStatus( _g, true ) ;
+                       }
+                       
+                       if( _mode == 1 )
+                       {
+                               authorized = true ;
+                       
+                               SuperNodeListe.Instance().setMappedGNode( _g, 0 ) ;
+                       
+                               authorized = false ;
+                       }
+               } else {
+                       System.err.println( "GNode is null is setMapped!" ) ;
+               }
+       }
+
        /**
         * Suppress a node from the gnodes list if this node is free, or remove
         * it from the Mapping class of the mapping algorithm if this node is
@@ -364,7 +431,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
         * @author S&eacute;bastien Miqu&eacute;e        
         */
        @Override
-       public GNode delGNodeFromList( Node _n, int _mode ) throws RemoteException
+       public synchronized GNode delGNodeFromList( Node _n, int _mode, String _spawnerIp ) throws RemoteException
        {
                GNode removedGNode = null ;
                
@@ -377,45 +444,33 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                                workingOnGnodes() ;
                                free = true ;
                        }
-                       
-                       /** The dead node is not in the mapping **/
-                       if( _mode == 0 || _mode == 2)
+
+                       if( _mode == 0 )
                        {
+                               GNode dead = null ;
+                               
                                for( int i = 0 ; i < gnodes.size() ; i++ )
                                {
-                                       if( ((Node)gnodes.get(i).getNode()).getId() == _n.getId() ) 
+                                       if( _n.getId() == ((Node) gnodes.get(i).getNode()).getId() )
                                        {
-                                               removedGNode = gnodes.remove( i ) ;
-                                               Register.Instance().removeNodeOfName( removedGNode.getName() ) ;
+                                               dead = gnodes.remove( i ) ;
                                                break ;
                                        }
                                }
-                       }
-                       
-                       /** The dead node is in the mapping **/
-                       if( _mode == 1 )
-                       {
-                               ArrayList<GNode> temp = al.getMapping().getMappedGNodes() ;
                                
-                               for( int i = 0 ; i < temp.size() ; i++ )
+                               if( dead != null )
                                {
-                                       if( ((Node)temp.get(i).getNode()).getId() == _n.getId() ) 
+                                       for( int i = 0 ; i < algos.size() ; i++ )
                                        {
-                                               removedGNode = temp.get( i ) ;
-                                               Register.Instance().removeNodeOfName( removedGNode.getName() ) ;
-                                               break ;
+                                               algos.get( i ).getGrid().removeGNode( dead ) ;
+                                               Register.Instance().removeNodeOfName( dead.getName() ) ;
+                                               SuperNodeListe.Instance().removeGNode( dead, _mode, _spawnerIp ) ;
                                        }
-                               }       
-                       }
-                       
-                       /** Removing the dead node from the Grid **/
-                       if( _mode == 0 || _mode == 1 ) {
-                               al.getGrid().removeGNode( removedGNode ) ;
+                               } else {
+                                       System.err.println( "The dead node signaled does not exist!" ) ;
+                               }
                        }
                        
-                       /** Propagation of the deletion **/
-                       SuperNodeListe.Instance().removeGNode( removedGNode, _mode ) ;
-                       
                        if( free )
                        {
                                operating = false ;
@@ -427,6 +482,27 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        }
        
        
+       /**
+        * Search the position of the mapping algorithm in the list.
+        * @param _id Identifier of the algorithm
+        * @return The position in the list
+        */
+       private int searchAlgo( String _id ) 
+       {
+               int id = -1 ;
+               
+               for( int i = 0 ; i < algos.size() ; i++ )
+               {
+                       if( algos.get( i ).getIdS().equals( _id ) )
+                       {
+                               id = i ; 
+                               break ;
+                       }
+               }
+               
+               return id ;
+       }
+
        /**
         * Determine if this SuperNode can operate on the gnodes list.
         * It asks other SuperNodes to know if their are working on this list
@@ -434,7 +510,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
         * 
         * @author S&eacute;bastien Miqu&eacute;e        
         */
-       private void workingOnGnodes()
+       private synchronized void workingOnGnodes()
        {
                boolean tmp = true ;    
                
@@ -464,6 +540,58 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                
                inDemand = false ;
        }
+       
+       /**
+        * Search and return a new node when one failed or when JaceP2P needs another
+        * one. For the first case, the given failed node should not be null, and
+        * null in the other case.
+        * @param _spawnerIP IP of the requester
+        * @param _rank The task number number of the dead node
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e
+        */
+       @Override
+       public synchronized Node getNewNode( String _spawnerIP, int _rank ) throws RemoteException
+       {
+               int idNode = -1 ;
+               int idAlgo = searchAlgo( _spawnerIP ) ;
+               
+               if( idAlgo == -1 )
+               {
+                       System.err.println( "No algorithm found for this Spawner!" ) ;
+                       return null ;
+               }
+               
+               /** We have to replace a Spawner **/
+               if( _rank == -2 )
+               {
+                       idNode = -2 ;
+               } else {
+               /** We have to replace a computing node **/
+                       idNode = algos.get( idAlgo ).getMapping().getIdOfAssociation( _rank ) ;
+               }
+               
+               if( idNode == -1 )
+               {
+                       System.err.println( "No tasks corresponds to rank "+_rank+"!" ) ;
+                       return null ;
+               }
+               
+               GNode dead = null ;
+               
+               if( idNode >= 0 ) 
+               {
+                       dead = algos.get( idAlgo ).getMapping().getAssociation( idNode ).getGNode() ;
+               }
+               
+               if( dead == null && idNode >= 0 )
+               {
+                       System.err.println( "The GNode corresponding to the task "+_rank+" is null!" ) ;
+                       System.err.println( "Trying to find a new node for this task (not optimal)..." ) ;
+               }
+               
+               return getNewNode( _spawnerIP, dead ) ;
+       }
 
        /**
         * Search and return a new node when one failed or when JaceP2P needs another
@@ -475,33 +603,48 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
         * @author S&eacute;bastien Miqu&eacute;e
         */
        @Override
-       public Node getNewNode( String _spawnerIP, Node _deadNode ) throws RemoteException
+       public synchronized Node getNewNode( String _spawnerIP, GNode _deadNode ) throws RemoteException
        {
                Node node = null ;
-               GNode remp = null, gnode = null ;
+               GNode remp = null ;
+
+               int idAlgo = searchAlgo( _spawnerIP ) ;
+               
+               if( idAlgo == -1 )
+               {
+                       System.err.println( "No algorithm found for this Spawner!" ) ;
+                       return null ;
+               }
+               
                
                /** Can we use gnodes ?**/
                workingOnGnodes() ;
                
-               if( _deadNode != null )
+               if( _deadNode != null )         
                {
                        authorized = true ;
                        
-                       gnode = delGNodeFromList( _deadNode, 1 ) ;
+                       removeMappedGNode( _deadNode, 1 ) ;
+                       
+                       authorized = false ;
 
-                       remp = al.replaceNode( gnode, gnodes ) ;
+                       remp = algos.get( idAlgo ).replaceNode( _deadNode, gnodes ) ;
                
                        if( remp != null )
                        {
                                System.out.println( "Replacing node found." ) ;
                                
+                               authorized = true ;
+                               
                                remp.setMapped( true ) ;
                                
-                               delGNodeFromList( (Node) remp.getNode(), 2 ) ;
+                               setMapped( remp, 1 ) ;
+                               Register.Instance().removeNodeOfName( remp.getName() ) ;
+                               
                                
                                /** Updating all mapping **/
-                               updateMappedNode( gnode, remp ) ;
-                               propagateReplaceNode( gnode, remp ) ;
+                               updateMappedNode( _deadNode, remp, _spawnerIP ) ;
+                               propagateReplaceNode( _deadNode, remp, _spawnerIP ) ;
                                
                                authorized = false ;
                                
@@ -510,15 +653,18 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                                System.err.println( "Replacing node not found !!" ) ;
                        }
                } else {
-                       remp = al.getOtherGNode( gnodes ) ;
+                       remp = algos.get( idAlgo ).getOtherGNode( gnodes ) ;
                        
                        if( remp != null )
                        {
                                System.out.println( "Other new node found." ) ;
 
+                               remp.setMapped( true ) ;
+                               
                                authorized = true ;
                                
-                               delGNodeFromList( (Node) remp.getNode(), 2 ) ;
+                               setMapped( remp, 1 ) ;
+                               Register.Instance().removeNodeOfName( remp.getName() ) ;
                                
                                authorized = false ;
                                
@@ -528,6 +674,14 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        }
                }
                
+               if( remp != null )
+               {
+                       node = (Node) remp.getNode() ;
+               } else {
+                       System.err.println( "SuperNode: No new node found!" ) ;
+               }
+               
+               
                /** Free the gnodes use **/
                operating = false ;
                
@@ -535,6 +689,24 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        }
        
        
+       public synchronized void removeMappedGNode( GNode _g, int _mode ) throws RemoteException
+       {
+               if( _g != null )
+               {
+                       for( int i = 0 ; i < algos.size() ; i++ )
+                       {
+                               algos.get( i ).getGrid().removeGNode( _g ) ;
+                       }
+                       
+                       if( _mode == 1 )
+                       {
+                               SuperNodeListe.Instance().removeGNode( _g, 0 ) ;
+                       }
+               } else {
+                       System.err.println( "GNode to be deleted is null!" ) ;
+               }
+       }
+       
        /**
         * Replace a failed GNode in the mapping by another one.
         * This method is called by the SuperNodeList, to broadcast the modification.
@@ -544,24 +716,38 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
         * @author S&eacute;bastien Miqu&eacute;e
         */
        @Override
-       public void updateMappedNode( GNode _dead, GNode _remp ) 
+       public synchronized void updateMappedNode( GNode _dead, GNode _remp, String _spawnerIP ) 
        {
-               int pos = 0 ;
-               pos = al.getMapping().getIdOfAssociation( _dead ) ;
-               
-               if( pos == -1 )
+               if( _remp != null )
                {
-                       System.err.println( "GNode "+_dead+" does not exist in the mapping!" ) ;
-                       return ;
-               }
+                       int pos = 0 ;
+                       
+                       int idAlgo = searchAlgo( _spawnerIP ) ;
+                       
+                       if( idAlgo == -1 )
+                       {
+                               System.err.println( "No algorithm found for this Spawner!" ) ;
+                               return ;
+                       }
                
-               /** Changing the node in the mapping **/
-               al.getMapping().getMapping().get( pos ).setGNode( _remp ) ;
+                       pos = algos.get( idAlgo ).getMapping().getIdOfAssociation( _dead ) ;
                
-               /** Changing the status in the grid **/
-               al.getGrid().setMappedStatus( _remp, true ) ;
-
-               System.out.println( "Succesfully replacing the fallen node in the mapping." ) ;
+                       if( pos != -1 )
+                       {
+                               /** Changing the node in the mapping **/
+                               if( algos.get( idAlgo ).getMapping().getMapping().get( pos ).setGNode( _remp ) )
+                               {
+                                       System.out.println( "Succesfully replacing the fallen node in the mapping." ) ;
+                               } else {
+                                       System.err.println( "Failed in replacing the fallen node in the mapping!" ) ;
+                               }
+                       } else {
+                               System.err.println( "The dead node was not found in the mapping!" ) ;
+                       }
+                       
+               } else {
+                       System.err.println( "The new GNode is null!" ) ;
+               }       
        }
 
        
@@ -572,11 +758,13 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
         * 
         * @author S&eacute;bastien Miqu&eacute;e        
         */
-       private void propagateReplaceNode( GNode _dead, GNode _remp ) throws RemoteException
+       private synchronized void propagateReplaceNode( GNode _dead, GNode _remp, String _spawnerIP ) throws RemoteException
        {
-               if( _dead != null && _remp != null )
+               if( _remp != null )
                {       
-                       SuperNodeListe.Instance().propagateReplaceNode( _dead, _remp ) ;
+                       SuperNodeListe.Instance().propagateReplaceNode( _dead, _remp, _spawnerIP ) ;
+               } else {
+                       System.err.println( "The replacement node is null!" ) ;
                }
        }
 
@@ -605,42 +793,14 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        
                        gnodes.add( _g ) ;
                        
+                       updateGrids( _g ) ;
+                       
                        if( free )
                                operating = false ;
                }
        }
        
 
-//     @Override
-//     public void removeGNode( GNode _g ) throws RemoteException 
-//     {
-//             if( _g != null )
-//             {
-//                     boolean free = false ;
-//                     
-//                     if( ! operating )
-//                     {
-//                             workingOnGnodes() ;
-//                             free = true ;
-//                     }
-//                     
-//                     for( int i = 0 ; i < gnodes.size() ; i++ )
-//                     {
-//                             if( ((Node)gnodes.get(i).getNode()).getId() == ((Node)_g.getNode()).getId() ) 
-//                             {
-//                                     gnodes.remove( i ) ;
-//                                     Register.Instance().removeNodeOfName( _g.getName() ) ;
-//                                     break ;
-//                             }
-//                     }
-//                     
-//                     if( free )
-//                             operating = false ;
-//             }
-//             
-//     }
-       
-
        /**
         * Set the local mapping with another done on an other SuperNode.
         * @param _al The new mapping
@@ -648,9 +808,14 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
         * @author S&eacute;bastien Miqu&eacute;e
         */
        @Override
-       public void setMapping( Algo _al ) throws RemoteException 
+       public synchronized void setMapping( Algo _al ) throws RemoteException 
        {
-               al = _al ;              
+               if( searchAlgo( _al.getIdS() ) == -1 )
+               {
+                       algos.add( _al ) ;
+               } else {
+                       System.err.println( "I already have this mapping algorithm!" ) ;
+               }
        }
 
        
@@ -693,6 +858,51 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                return gnodes ;
        }
        
+       
+       /**
+        * Remove a mapping algorithm of the algorithms list.
+        * @param _id The algorithm identifier
+        * @param _mode Indicate if the information should be transmitted
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e
+        */
+       public void removeAlgo( String _id, int _mode ) throws RemoteException
+       {
+               int pos ;
+               
+               pos = searchAlgo( _id ) ;
+               
+               if( pos != -1 )
+               {
+                       algos.remove( pos ) ;
+                       
+                       if( _mode == 0 )
+                       {
+                               SuperNodeListe.Instance().removeAlgo( _id ) ;
+                       }
+               } else {
+                       System.err.println( "The mapping algorithm requested for deletion does not exist!" ) ;
+               }
+       }
+       
+       
+       // ** Tests ** //
+       public Algo getAlgo( String _spID ) throws RemoteException
+       {
+               int pos ;
+               Algo ret = null ;
+               
+               pos = searchAlgo( _spID ) ;
+               
+               if( pos != -1 )
+               {
+                       ret = algos.get( pos ) ;
+               }
+               
+               return ret ;
+       }
+       
+       
 }
 
 /** ! **/