import java.rmi.RemoteException;
import java.util.ArrayList;
-import java.util.Vector;
import and.Mapping.*;
public class TokenThread extends Thread {
// System.out.println("finished set token");
}
- @SuppressWarnings("unchecked")
+
public void distribute() {
System.out.println("totalDaemons="
+ SuperNodeListe.Instance().getTotalDaemons());
int nbLocal = Register.Instance().getSize();
int totalDaemons;
- Vector liste = SuperNodeListe.Instance().getListe();
+ ArrayList<Object> liste = SuperNodeListe.Instance().getListe();
/******* Sébastien Miquée ********/
ArrayList<GNode> gnodes = null ;
if (((SuperNodeData) liste.get(i)).getNbOfNodes() < nbDaemons)
try {
// System.out.println("Snode="+i+" nodes="+((SuperNodeData)liste.get(i)).getNbOfNodes());
- Vector nodes = Register.Instance()
+ ArrayList<Node> nodes = Register.Instance()
.getListe();
int amountToSend = nbDaemons
- ((SuperNodeData) liste.get(i))
.getNbOfNodes();
- Vector newVector = new Vector();
+ ArrayList<Node> newVector = new ArrayList<Node>() ;
for (int j = 0; j < amountToSend; j++) {
- newVector.add(nodes.elementAt(j));
+ newVector.add(nodes.get(j));
}
((SuperNodeData) liste.get(i)).getStub()
.sendSurplus(newVector, gnodes);
index = (index + 1) % SuperNodeListe.Instance().getListe().size();
// System.out.println("index="+index);
try {
- ((SuperNodeData) liste.elementAt(index)).getStub().setToken();
+ ((SuperNodeData) liste.get(index)).getStub().setToken();
if (index != SuperNodeListe.Instance().existSuperNode(
LocalHost.Instance().getIP()))
token = false;
} catch (Exception e) {
try {
System.err.println("Unable to send Token to "
- + ((SuperNodeData) liste.elementAt(index)).getIP()
+ + ((SuperNodeData) liste.get(index)).getIP()
+ " :" + e);
/*
* SuperNodeListe.Instance().removeSuperNode(((SuperNodeData)