Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Modifying functions manipulating Grid classes.
authorSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Fri, 19 Feb 2010 18:03:31 +0000 (19:03 +0100)
committerSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Fri, 19 Feb 2010 18:03:31 +0000 (19:03 +0100)
- Allowing to remove dead nodes from the Grid class in the Algo object.

src/jaceP2P/JaceSuperNode.java
src/jaceP2P/JaceSuperNodeInterface.java
src/jaceP2P/JaceSuperNodeServer.java
src/jaceP2P/SuperNodeListe.java

index c4238b7..4dcd3e9 100644 (file)
@@ -1,8 +1,7 @@
 package jaceP2P;
 
 import java.rmi.Naming;
-
-import and.Mapping.GNode;
+import java.rmi.RemoteException;
 
 public class JaceSuperNode {
        final int NB_HEART_DECONNECT = 3;
@@ -152,8 +151,13 @@ public class JaceSuperNode {
                                                        index)).setNbOfNodes(Register.Instance().getSize());
                                        SuperNodeListe.Instance().forwardCountNode();
                                        
-                                       GNode deadGNode = snodeServer.delGNodeFromList( host, 0 ) ;
-                                       SuperNodeListe.Instance().removeGNode( deadGNode ) ;
+                                       try {
+                                               snodeServer.delGNodeFromList( host, 0 ) ;
+                                       } catch (RemoteException e) {
+                                               System.err.println( "Unable to remove the dead node from the list !" ) ;
+                                               e.printStackTrace();
+                                       }
+//                                     SuperNodeListe.Instance().removeGNode( deadGNode ) ;
 
                                        // Register.Instance().viewAll();
                                        // SuperNodeListe.Instance().viewAll();
index 3b1ef20..c5f2e3a 100644 (file)
@@ -49,7 +49,9 @@ public interface JaceSuperNodeInterface extends Remote {
        /** ! **/
        public void addGNode( GNode _g ) throws RemoteException ;
        
-       public void removeGNode( GNode _g ) throws RemoteException ;
+//     public void removeGNode( GNode _g ) throws RemoteException ;
+       
+       public GNode delGNodeFromList( Node _n, int _mode ) throws RemoteException ;
 
        public boolean blockForMapping() throws RemoteException ;
        
index c954257..5e67a4c 100644 (file)
@@ -77,7 +77,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                                                .setNbOfNodes(Register.Instance().getSize());
                                new ForwardCount().start();
                        } catch (Exception e) {
-                               System.out.println("Error changing Server in SendSurplus : "
+                               System.err.println("Error changing Server in SendSurplus : "
                                                + e);
                        }
                }
@@ -99,7 +99,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
 
                        System.out.println("Put token to true");
                } catch (Exception e) {
-                       System.out
+                       System.err
                                        .println("Unable to heartBeat the next SuperNode with the new Token : "
                                                        + e);
                }
@@ -123,7 +123,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        public synchronized void workerRegistering(JaceInterface workerStub,
                        String workerIP, String workerName, int port, GNode g)
                        throws RemoteException {
-               System.out.println("CONNEXION of " + workerName);
+               System.out.println("CONNECTION of " + workerName);
 
                // Create the node
                Node noeud = new Node(workerStub);
@@ -200,6 +200,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        /** Mapping !! Sébastien Miquée **/
        /*********************************/
 
+       @Override
        public Register getRegisterSpawner(String spawnerIP, int nbTasks, Task t,
                        int nbNoeuds, int algo, double paramAlgo) throws RemoteException {
 
@@ -299,7 +300,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
 
                        authorized = true ;
                        
-                       for (int i = 0; i < ag.size(); i++) {
+                       for( int i = 0; i < ag.size(); i++ ) {
                                reg.addNode((Node) ag.get(i).getNode());
                                delGNodeFromList( (Node) ag.get(i).getNode(), 0 ) ;
 //                             gnodes.remove(ag.get(i));
@@ -329,26 +330,20 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
 
                } 
                
-//             daemonListChange = false ;
-
-               System.out.println( "Spawner returned reg: " + reg ) ;
+//             System.out.println( "Spawner returned reg: " + reg ) ;
                
                /** Mapping distribution over other Super Nodes */
                SuperNodeListe.Instance().setMapping( al ) ;
                
                operating = false ;
                
-               /* Returning result */
+               /** Returning result **/
                return reg ;
        }
 
-       /*****************************************/
-       /****        Sébastien Miquée         ****/
-       /**                                     **/
-       /**      Recherche nouveau noeud        **/
-       /*****************************************/
        
-       protected GNode delGNodeFromList( Node _n, int _mode )
+       @Override
+       public GNode delGNodeFromList( Node _n, int _mode ) throws RemoteException
        {
                GNode removedGNode = null ;
                
@@ -392,10 +387,10 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                                }       
                        }
                        
-               
-//             daemonListChange = true ;
-               
-                       SuperNodeListe.Instance().removeGNode( removedGNode ) ;
+                       /** Removing the dead node from the Grid **/
+                       al.getGrid().removeGNode( removedGNode ) ;
+                       
+                       SuperNodeListe.Instance().removeGNode( removedGNode, _mode ) ;
                        
                        if( free )
                        {
@@ -439,7 +434,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                inDemand = false ;
        }
 
-               
+       @Override
        public Node getNewNode( String _spawnerIP, Node _deadNode ) throws RemoteException
        {
                Node node = null ;
@@ -558,34 +553,34 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
        }
        
 
-       @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 ;
-               }
-               
-       }
+//     @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 ;
+//             }
+//             
+//     }
        
 
        @Override
index df26230..017128a 100644 (file)
@@ -369,7 +369,7 @@ public class SuperNodeListe implements Cloneable {
                }
        }
        
-       public void removeGNode( GNode _g )
+       public void removeGNode( GNode _g, int _mode )
        {
                if( _g != null )
                {
@@ -385,7 +385,7 @@ public class SuperNodeListe implements Cloneable {
                                        // if not me, I inform the other super nodes
                                        remoteStub = d.getStub() ;
                                        try {
-                                               remoteStub.removeGNode( _g ) ;
+                                               remoteStub.delGNodeFromList( (Node)_g.getNode(), _mode ) ;
                                        } catch( Exception e ) {
                                                System.err.println( "Unable to remove GNode on SuperNode " + d.getIP() ) ;
                                        }