import java.rmi.Remote;
import java.rmi.RemoteException;
+import java.util.ArrayList;
import java.util.Vector;
import and.Mapping.Algo;
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;
public void setMapping( Algo al ) throws RemoteException ;
public void updateMappedNode(GNode dead, GNode remp) throws RemoteException ;
+
+ public ArrayList<GNode> getGNodes() throws RemoteException ;
}
/** ! **/
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++) {
+ e);
}
}
+
+ /** Updating gnodes **/
+ if( _gnodes != null )
+ {
+ gnodes = _gnodes ;
+ }
}
public void setToken() throws RemoteException {
.setNbOfNodes(Register.Instance().getSize());
SuperNodeListe.Instance().forwardCountNode();
+ authorized = true ;
SuperNodeListe.Instance().addGNode( g ) ;
+ authorized = false ;
operating = false ;
}
return true ;
}
}
+
+ @Override
+ public ArrayList<GNode> getGNodes() throws RemoteException
+ {
+ return gnodes ;
+ }
}
package jaceP2P;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
import java.util.Vector;
+import and.Mapping.*;
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) {
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()