From: Sébastien Miquée Date: Thu, 18 Feb 2010 14:58:43 +0000 (+0100) Subject: Adapatation for fault tolerance with the Mapping library. X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/jaceP2P.git/commitdiff_plain/9e956705309c9875a2550b863127892b1a52723c Adapatation for fault tolerance with the Mapping library. - 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. --- diff --git a/src/jaceP2P/JaceSuperNodeInterface.java b/src/jaceP2P/JaceSuperNodeInterface.java index 9779ef3..3b1ef20 100644 --- a/src/jaceP2P/JaceSuperNodeInterface.java +++ b/src/jaceP2P/JaceSuperNodeInterface.java @@ -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 _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 getGNodes() throws RemoteException ; } /** ! **/ diff --git a/src/jaceP2P/JaceSuperNodeServer.java b/src/jaceP2P/JaceSuperNodeServer.java index 1b06066..c954257 100644 --- a/src/jaceP2P/JaceSuperNodeServer.java +++ b/src/jaceP2P/JaceSuperNodeServer.java @@ -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 _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 getGNodes() throws RemoteException + { + return gnodes ; + } } diff --git a/src/jaceP2P/TokenThread.java b/src/jaceP2P/TokenThread.java index 531a009..1f11e73 100644 --- a/src/jaceP2P/TokenThread.java +++ b/src/jaceP2P/TokenThread.java @@ -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 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()