Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correction of grid modifications.
authorSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Mon, 22 Feb 2010 20:58:46 +0000 (21:58 +0100)
committerSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Mon, 22 Feb 2010 20:58:46 +0000 (21:58 +0100)
- Integration of the grid modification when a node is mapped or
  disconnected.

- Adding some javadoc comments.

src/jaceP2P/JaceSuperNodeServer.java

index 5e67a4c..0200806 100644 (file)
@@ -12,7 +12,6 @@ import and.Mapping.GTask;
 import and.Mapping.Graph;
 import and.Mapping.Grid;
 import and.Mapping.LSM;
 import and.Mapping.Graph;
 import and.Mapping.Grid;
 import and.Mapping.LSM;
-import and.Mapping.Mapping;
 import and.Mapping.QM;
 import and.Mapping.Simple;
 import and.Mapping.Utils;
 import and.Mapping.QM;
 import and.Mapping.Simple;
 import and.Mapping.Utils;
@@ -137,12 +136,13 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                noeud.setId( count ) ;
                noeud.setId( Long.parseLong( workerIP.replace( ".", "" ) ) ) ;
 
                noeud.setId( count ) ;
                noeud.setId( Long.parseLong( workerIP.replace( ".", "" ) ) ) ;
 
-               g.setNode(noeud);
+               g.setNode( noeud ) ;
                g.setId( noeud.getId() ) ;
                g.setId( noeud.getId() ) ;
+               g.setMapped( false ) ;
                
                workingOnGnodes() ;
                
                
                workingOnGnodes() ;
                
-               gnodes.add(g);
+               gnodes.add( g ) ;
                
 //             daemonListChange = true ;
 
                
 //             daemonListChange = true ;
 
@@ -200,6 +200,21 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        /** Mapping !! Sébastien Miquée **/
        /*********************************/
 
        /** Mapping !! Sébastien Miquée **/
        /*********************************/
 
+       /**
+        * Search and return to the requester spawner a register containing
+        * computation nodes plus some extra nodes if needed. This method requires
+        * as parameters the mapping algorithm choice and its parameters, and the
+        * amount of requested nodes and the task to be used, in order to 
+        * construct the tasks graph.
+        * @param spawnerIP IP of the requester
+        * @param nbTasks Amount of tasks
+        * @param t Tasks to be executed
+        * @param nbNoeuds Total amount of requested nodes
+        * @param algo Identifier of the mapping algorithm
+        * @param paramAlgo Parameter of the mapping algorithm 
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e        
+        */
        @Override
        public Register getRegisterSpawner(String spawnerIP, int nbTasks, Task t,
                        int nbNoeuds, int algo, double paramAlgo) throws RemoteException {
        @Override
        public Register getRegisterSpawner(String spawnerIP, int nbTasks, Task t,
                        int nbNoeuds, int algo, double paramAlgo) throws RemoteException {
@@ -224,7 +239,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                
                /** Initialization of Grid architecture (G5K for now) **/
                Grid grid = Utils.createGridG5k(gnodes);
                
                /** Initialization of Grid architecture (G5K for now) **/
                Grid grid = Utils.createGridG5k(gnodes);
-               grid.initClusters();
+//             grid.initClusters();
                
 
                /** Creation of tasks GTask **/
                
 
                /** Creation of tasks GTask **/
@@ -291,18 +306,14 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        al.map();
 
 
                        al.map();
 
 
-                       /** Transforming mapping in register **/
-                       Mapping mp = al.getMapping();
-                       
-                       
                        /** Creating the register **/
                        /** Creating the register **/
-                       ArrayList<GNode> ag = mp.getMappedGNodes();
+                       ArrayList<GNode> ag = al.getMapping().getMappedGNodes();
 
                        authorized = true ;
                        
                        for( int i = 0; i < ag.size(); i++ ) {
                                reg.addNode((Node) ag.get(i).getNode());
 
                        authorized = true ;
                        
                        for( int i = 0; i < ag.size(); i++ ) {
                                reg.addNode((Node) ag.get(i).getNode());
-                               delGNodeFromList( (Node) ag.get(i).getNode(), 0 ) ;
+                               delGNodeFromList( (Node) ag.get(i).getNode(), 2 ) ;
 //                             gnodes.remove(ag.get(i));
 //                             Register.Instance().removeNode((Node) ag.get(i).getNode());
                        }
 //                             gnodes.remove(ag.get(i));
 //                             Register.Instance().removeNode((Node) ag.get(i).getNode());
                        }
@@ -318,7 +329,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                                {
                                        sup = al.getOtherGNode( gnodes ) ;
                                        reg.addNodeBeg( (Node) sup.getNode() ) ;
                                {
                                        sup = al.getOtherGNode( gnodes ) ;
                                        reg.addNodeBeg( (Node) sup.getNode() ) ;
-                                       delGNodeFromList( (Node) sup.getNode(), 0 ) ;
+                                       delGNodeFromList( (Node) sup.getNode(), 2 ) ;
                                }
                        }
                        
                                }
                        }
                        
@@ -332,7 +343,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                
 //             System.out.println( "Spawner returned reg: " + reg ) ;
                
                
 //             System.out.println( "Spawner returned reg: " + reg ) ;
                
-               /** Mapping distribution over other Super Nodes */
+               /** Mapping distribution over other SuperNodes */
                SuperNodeListe.Instance().setMapping( al ) ;
                
                operating = false ;
                SuperNodeListe.Instance().setMapping( al ) ;
                
                operating = false ;
@@ -342,6 +353,16 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        }
 
        
        }
 
        
+       /**
+        * 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
+        * a computation node. After having done the local suppression of the node
+        * it propagates the suppression to other SuperNodes.
+        * @param _n The fallen node
+        * @param _mode Choice of the list (0: gnodes, 1: mapping, 2:just mapped)
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e        
+        */
        @Override
        public GNode delGNodeFromList( Node _n, int _mode ) throws RemoteException
        {
        @Override
        public GNode delGNodeFromList( Node _n, int _mode ) throws RemoteException
        {
@@ -358,7 +379,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        }
                        
                        /** The dead node is not in the mapping **/
                        }
                        
                        /** The dead node is not in the mapping **/
-                       if( _mode == 0 )
+                       if( _mode == 0 || _mode == 2)
                        {
                                for( int i = 0 ; i < gnodes.size() ; i++ )
                                {
                        {
                                for( int i = 0 ; i < gnodes.size() ; i++ )
                                {
@@ -388,8 +409,11 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        }
                        
                        /** Removing the dead node from the Grid **/
                        }
                        
                        /** Removing the dead node from the Grid **/
-                       al.getGrid().removeGNode( removedGNode ) ;
+                       if( _mode == 0 || _mode == 1 ) {
+                               al.getGrid().removeGNode( removedGNode ) ;
+                       }
                        
                        
+                       /** Propagation of the deletion **/
                        SuperNodeListe.Instance().removeGNode( removedGNode, _mode ) ;
                        
                        if( free )
                        SuperNodeListe.Instance().removeGNode( removedGNode, _mode ) ;
                        
                        if( free )
@@ -403,6 +427,13 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        }
        
        
        }
        
        
+       /**
+        * Determine if this SuperNode can operate on the gnodes list.
+        * It asks other SuperNodes to know if their are working on this list
+        * and set the authorization, or not.
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e        
+        */
        private void workingOnGnodes()
        {
                boolean tmp = true ;    
        private void workingOnGnodes()
        {
                boolean tmp = true ;    
@@ -434,6 +465,15 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                inDemand = false ;
        }
 
                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 _deadNode The failed node
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e
+        */
        @Override
        public Node getNewNode( String _spawnerIP, Node _deadNode ) throws RemoteException
        {
        @Override
        public Node getNewNode( String _spawnerIP, Node _deadNode ) throws RemoteException
        {
@@ -454,9 +494,10 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        if( remp != null )
                        {
                                System.out.println( "Replacing node found." ) ;
                        if( remp != null )
                        {
                                System.out.println( "Replacing node found." ) ;
-                               node = (Node) remp.getNode() ;
                                
                                
-                               delGNodeFromList( node, 0 ) ;
+                               remp.setMapped( true ) ;
+                               
+                               delGNodeFromList( (Node) remp.getNode(), 2 ) ;
                                
                                /** Updating all mapping **/
                                updateMappedNode( gnode, remp ) ;
                                
                                /** Updating all mapping **/
                                updateMappedNode( gnode, remp ) ;
@@ -474,11 +515,10 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        if( remp != null )
                        {
                                System.out.println( "Other new node found." ) ;
                        if( remp != null )
                        {
                                System.out.println( "Other new node found." ) ;
-                               node = (Node) remp.getNode() ;
-                               
+
                                authorized = true ;
                                
                                authorized = true ;
                                
-                               delGNodeFromList( node, 0 ) ;
+                               delGNodeFromList( (Node) remp.getNode(), 2 ) ;
                                
                                authorized = false ;
                                
                                
                                authorized = false ;
                                
@@ -494,6 +534,15 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                return node ;
        }
        
                return node ;
        }
        
+       
+       /**
+        * Replace a failed GNode in the mapping by another one.
+        * This method is called by the SuperNodeList, to broadcast the modification.
+        * @param _dead The failed node
+        * @param _remp The replacing node
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e
+        */
        @Override
        public void updateMappedNode( GNode _dead, GNode _remp ) 
        {
        @Override
        public void updateMappedNode( GNode _dead, GNode _remp ) 
        {
@@ -506,16 +555,22 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        return ;
                }
                
                        return ;
                }
                
-               al.getMapping().getMapping().get( pos ).setGNode( _remp ) ;             
+               /** Changing the node in the mapping **/
+               al.getMapping().getMapping().get( pos ).setGNode( _remp ) ;
+               
+               /** Changing the status in the grid **/
+               al.getGrid().setMappedStatus( _remp, true ) ;
 
                System.out.println( "Succesfully replacing the fallen node in the mapping." ) ;
        }
 
        
        /**
 
                System.out.println( "Succesfully replacing the fallen node in the mapping." ) ;
        }
 
        
        /**
-        * Inform all SuperNodes of the replacement of a fallen computing node.
-        * @param _dead The fallen node
+        * Inform all SuperNodes of the replacement of a failed computing node.
+        * @param _dead The failed node
         * @param _remp The replacing node
         * @param _remp The replacing node
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e        
         */
        private void propagateReplaceNode( GNode _dead, GNode _remp ) throws RemoteException
        {
         */
        private void propagateReplaceNode( GNode _dead, GNode _remp ) throws RemoteException
        {
@@ -528,10 +583,13 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        /**********************************************************/
        /**********************************************************/
 
        /**********************************************************/
        /**********************************************************/
 
+       
        @Override
        /**
         * Add a new node in the list.
         * @param _g The new node
        @Override
        /**
         * Add a new node in the list.
         * @param _g The new node
+        *
+        * @author S&eacute;bastien Miqu&eacute;e        
         */
        public void addGNode( GNode _g ) throws RemoteException 
        {
         */
        public void addGNode( GNode _g ) throws RemoteException 
        {
@@ -583,6 +641,12 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
 //     }
        
 
 //     }
        
 
+       /**
+        * Set the local mapping with another done on an other SuperNode.
+        * @param _al The new mapping
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e
+        */
        @Override
        public void setMapping( Algo _al ) throws RemoteException 
        {
        @Override
        public void setMapping( Algo _al ) throws RemoteException 
        {
@@ -594,8 +658,9 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        /**
         * Allow or deny the use of operations on the gnodes list, in order to
         * do a mapping operation.
        /**
         * Allow or deny the use of operations on the gnodes list, in order to
         * do a mapping operation.
-        * @author miquee
         * @return The authorization or not to block gnodes
         * @return The authorization or not to block gnodes
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e
         */
        public boolean blockForMapping() throws RemoteException
        {
         */
        public boolean blockForMapping() throws RemoteException
        {
@@ -616,6 +681,12 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                }
        }
 
                }
        }
 
+       /**
+        * Return the array containing the current not mapped nodes available.
+        * @return The array of available nodes
+        * 
+        * @author S&eacute;bastien Miqu&eacute;e 
+        */
        @Override
        public ArrayList<GNode> getGNodes() throws RemoteException 
        {
        @Override
        public ArrayList<GNode> getGNodes() throws RemoteException 
        {