Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correction of grid modification methods.
[jaceP2P.git] / src / jaceP2P / JaceSuperNodeServer.java
index 0200806..d2f5786 100644 (file)
@@ -499,10 +499,6 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                                
                                delGNodeFromList( (Node) remp.getNode(), 2 ) ;
                                
-                               /** Updating all mapping **/
-                               updateMappedNode( gnode, remp ) ;
-                               propagateReplaceNode( gnode, remp ) ;
-                               
                                authorized = false ;
                                
                                SuperNodeListe.Instance().forwardCountNode();
@@ -516,6 +512,8 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        {
                                System.out.println( "Other new node found." ) ;
 
+                               remp.setMapped( true ) ;
+                               
                                authorized = true ;
                                
                                delGNodeFromList( (Node) remp.getNode(), 2 ) ;
@@ -528,6 +526,12 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        }
                }
                
+               
+               /** Updating all mapping **/
+               updateMappedNode( gnode, remp ) ;
+               propagateReplaceNode( gnode, remp ) ;
+               
+               
                /** Free the gnodes use **/
                operating = false ;
                
@@ -546,22 +550,27 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        @Override
        public void updateMappedNode( GNode _dead, GNode _remp ) 
        {
-               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 ;
                
-               /** Changing the node in the mapping **/
-               al.getMapping().getMapping().get( pos ).setGNode( _remp ) ;
+                       pos = al.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 **/
+                               al.getMapping().getMapping().get( pos ).setGNode( _remp ) ;
+                               
+                               System.out.println( "Succesfully replacing the fallen node in the mapping." ) ;
+                       }               
+                       
+                       /** Changing the status in the grid **/
+                       al.getGrid().setMappedStatus( _remp, true ) ;
+               
+                       al.updateGrid() ;
+               } else {
+                       System.err.println( "The new GNode is null!" ) ;
+               }
        }
 
        
@@ -574,7 +583,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
         */
        private void propagateReplaceNode( GNode _dead, GNode _remp ) throws RemoteException
        {
-               if( _dead != null && _remp != null )
+               if( _remp != null )
                {       
                        SuperNodeListe.Instance().propagateReplaceNode( _dead, _remp ) ;
                }