Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adapatation for fault tolerance with the Mapping library.
authorSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Thu, 18 Feb 2010 14:58:43 +0000 (15:58 +0100)
committerSébastien Miquée <sebastien.miquee@univ-fcomte.fr>
Thu, 18 Feb 2010 14:58:43 +0000 (15:58 +0100)
- Changing some mechanisms in order to keep all fault tolerance
  mechanisms with the inclusion and usage of the Mapping library.

- Adaptation of the mechanisms concerning the connection of a new
  SuperNode and the load balancing of Deamons attached to them.

src/jaceP2P/JaceSuperNodeInterface.java
src/jaceP2P/JaceSuperNodeServer.java
src/jaceP2P/TokenThread.java

index 9779ef3..3b1ef20 100644 (file)
@@ -2,6 +2,7 @@ package jaceP2P;
 
 import java.rmi.Remote;
 import java.rmi.RemoteException;
+import java.util.ArrayList;
 import java.util.Vector;
 
 import and.Mapping.Algo;
@@ -37,7 +38,7 @@ public interface JaceSuperNodeInterface extends Remote {
 
        public void updateCountNode(String IP, int nb) throws RemoteException;
 
-       public void sendSurplus(Vector<?> nodes) throws RemoteException;
+       public void sendSurplus(Vector<?> nodes, ArrayList<GNode> _gnodes) throws RemoteException;
 
        public void removeSuperNode(SuperNodeData d) throws RemoteException;
 
@@ -55,6 +56,8 @@ public interface JaceSuperNodeInterface extends Remote {
        public void setMapping( Algo al ) throws RemoteException ;
 
        public void updateMappedNode(GNode dead, GNode remp) throws RemoteException ;
+
+       public ArrayList<GNode> getGNodes() throws RemoteException ;
 }
 
 /** ! **/
index 1b06066..c954257 100644 (file)
@@ -58,7 +58,7 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                SuperNodeListe.Instance().viewAll();
        }
 
-       public void sendSurplus(Vector<?> nodes) throws RemoteException {
+       public void sendSurplus(Vector<?> nodes, ArrayList<GNode> _gnodes) throws RemoteException {
                System.out.println("Recieved " + nodes.size() + " nodes");
 
                for (int i = 0; i < nodes.size(); i++) {
@@ -81,6 +81,12 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                                                + e);
                        }
                }
+               
+               /** Updating gnodes **/
+               if( _gnodes != null )
+               {
+                       gnodes = _gnodes ;
+               }
        }
 
        public void setToken() throws RemoteException {
@@ -155,7 +161,9 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                                .setNbOfNodes(Register.Instance().getSize());
                SuperNodeListe.Instance().forwardCountNode();
                
+               authorized = true ;
                SuperNodeListe.Instance().addGNode( g ) ;
+               authorized = false ;
                
                operating = false ;
        }
@@ -612,6 +620,12 @@ public class JaceSuperNodeServer extends UnicastRemoteObject implements
                        return true ;
                }
        }
+
+       @Override
+       public ArrayList<GNode> getGNodes() throws RemoteException 
+       {
+               return gnodes ;
+       }
        
 }
 
index 531a009..1f11e73 100644 (file)
@@ -1,6 +1,9 @@
 package jaceP2P;
 
+import java.rmi.RemoteException;
+import java.util.ArrayList;
 import java.util.Vector;
+import and.Mapping.*;
 
 public class TokenThread extends Thread {
 
@@ -62,6 +65,16 @@ public class TokenThread extends Thread {
                int nbLocal = Register.Instance().getSize();
                int totalDaemons;
                Vector liste = SuperNodeListe.Instance().getListe();
+               
+               /******* Sébastien Miquée ********/
+               ArrayList<GNode> gnodes = null ;
+               try {
+                       gnodes = SuperNodeListe.Instance().getStubOf(LocalHost.Instance().getIP()).getGNodes() ;
+               } catch (RemoteException e1) {
+                       System.err.println( "Unable to retrieve local gnodes list !" ) ;
+                       e1.printStackTrace();
+               }
+               
                synchronized (SuperNodeListe.Instance()) {
                        synchronized (Register.Instance()) {
                                if (nbLocal > 5) {
@@ -83,7 +96,7 @@ public class TokenThread extends Thread {
                                                                                newVector.add(nodes.elementAt(j));
                                                                        }
                                                                        ((SuperNodeData) liste.get(i)).getStub()
-                                                                                       .sendSurplus(newVector);
+                                                                                       .sendSurplus(newVector, gnodes);
                                                                        for (int j = 0; j < amountToSend; j++)
                                                                                nodes.remove(0);
                                                                        int index = SuperNodeListe.Instance()