-
-
-// public Node getNewNode(String spawnerIP) throws RemoteException {
-// boolean found = false;
-// int i = 0;
-// Node tmpNode = null;
-// SuperNodeData d = null;
-// //int passage = 0;
-// String snode_IP;
-// JaceSuperNodeInterface stub = null;
-//
-// try {
-// System.out.println("\n" + spawnerIP
-// + " (spawner) requests a new node : ");
-// while (i < Register.Instance().getSize() && found == false) {
-// tmpNode = Register.Instance().getNodeAt(i);
-//
-// if (tmpNode.getAppliName() == null
-// && tmpNode.getAliveFlag() == true) {
-// tmpNode.setAppliName("notnull");
-// found = true;
-//
-// // enlever maintenant le noeud du register de
-// // SuperNode??????
-// // System.out.println("je remove le noeud car il va beater le spawner (getNewNode)");
-// // Register.Instance().removeNodeAt(i);
-// Register.Instance().removeNode(tmpNode);
-// // Register.Instance().removeNode(tmpNode.getIP());
-//
-// int index = SuperNodeListe.Instance().existSuperNode(
-// LocalHost.Instance().getIP());
-//
-// ((SuperNodeData) SuperNodeListe.Instance().getListe()
-// .elementAt(index)).setNbOfNodes(Register.Instance()
-// .getSize());
-// SuperNodeListe.Instance().forwardCountNode();
-// }
-// i++;
-// }
-// } catch (Exception e1) {
-// System.out.println("... plante en cherchant chez moi");
-// }
-//
-// // Register.Instance().viewAll();
-// SuperNodeListe.Instance().viewAll();
-//
-// try {
-// // si pas assez de noeud sur ce superNode,
-// if (found == false) {
-// System.out.println("pas de noeud dispo chez moi");
-//
-// SuperNodeListe snodeListTmp = SuperNodeListe.Instance().clone();
-// // while ( (found == false) && (passage <
-// // SuperNodeListe.Instance().getSize()) ) {
-// while ((found == false) && (snodeListTmp.getSize() > 0)) {
-// // System.out.println("passage = " + passage);
-// // d = SuperNodeListe.Instance().getBestSuperNodeData();
-// d = snodeListTmp.getBestSuperNodeData();
-// System.out.println("KKKKKKKKKKKKKKK ......... le best c "
-// + d.getIP() + " il en a " + d.getNbOfNodes());
-// if (d != null) {
-// snode_IP = d.getIP();
-// // si c moi, je passe au suivant
-// if (LocalHost.Instance().getIP().equals(snode_IP)) {
-// // passage++;
-// System.out
-// .println("OUUUUPS, c moi dc je tente un autre");
-// snodeListTmp.removeSuperNode(d);
-// continue;
-// }
-//
-// stub = d.getStub();
-//
-// if (stub != null) {
-// try {
-// Register tmpReg = stub.reserveLocalNodes(1);
-// if (tmpReg != null) {
-// // for (int j = 0; j < tmpReg.getSize();
-// // j++) {
-// System.out.println("IL EN A 1 !!!!!!!");
-// tmpNode = tmpReg.getNodeAt(0);
-// found = true;
-// System.out.println("le snode " + snode_IP
-// + " me reserve le noeud demande");
-// } else {
-// System.out
-// .println("MERDE !!! pas de noeud dispo sur "
-// + snode_IP);
-// System.out
-// .println("Je demande un noeud a un autre");
-// }
-//
-// } catch (Exception e) {
-// System.out
-// .println("le snode est mort, je demande les noeuds a un autre");
-// // remettre localement a 0 le nb de noeuds de ce
-// // superNode
-// SuperNodeListe.Instance().modifCountNode(
-// snode_IP, 0);
-// snodeListTmp = SuperNodeListe.Instance()
-// .clone();
-// }
-// }
-// } else {
-// System.out
-// .println("PUTAIN !!!! aucun noeud encore dispo sur les snode");
-// // passage = SuperNodeListe.Instance().getSize();
-// }
-// // passage++;
-// snodeListTmp.removeSuperNode(d);
-// }
-// }
-// } catch (Exception e2) {
-// System.out.println("plante en cherchant chez les autres");
-// }
-//
-// // si pas assez de noeud sur tous les superNode,
-// if (found == false) {
-// System.out.println("aucun noeud dispo dans le systeme");
-// } else {
-// System.out.println("je lui donne son noeud");
-// }
-//
-// return tmpNode;
-// }
-
-// public Register reserveLocalNodes(int nb) throws RemoteException {
-// Register reg = null;
-// System.out
-// .println("\nA superNode or a Spawner asks me for a register of "
-// + nb + " Daemons");
-//
-// int count = 0;
-// int i = 0;
-// Node tmpNode;
-//
-// if (Register.Instance().getSize() == 0) {
-// return new Register();
-// } else {
-// reg = new Register();
-//
-// while (i < Register.Instance().getSize() && count < nb) {
-// tmpNode = Register.Instance().getNodeAt(i);
-//
-// if (tmpNode.getAppliName() == null
-// && tmpNode.getAliveFlag() == true
-// /* && tmpNode.getNbOfBeats() > 10 */) {
-// // if node available, alive and not recently connected, then
-// tmpNode.setAppliName("notnull");
-// reg.addNode(tmpNode);
-//
-// // remove now the node from SuperNode or later ?
-// // System.out.println("I remove the Node from SuperNode beating it will now beat the Spawner");
-// Register.Instance().removeNode(tmpNode);
-// count++;
-// }
-// // increment counter only y Node NOT REMOVED
-// else {
-// i++;
-// }
-// }
-//
-// // Register.Instance().viewAll();
-// System.out.println("Number of Daemons reserved on me : " + count);
-// // Inform other SuperNodes that some Daemons initialy registered on
-// // me
-// // are no longer available because reserved for the spawner that
-// // invoked me
-// int index = SuperNodeListe.Instance().existSuperNode(
-// LocalHost.Instance().getIP());
-// ((SuperNodeData) SuperNodeListe.Instance().getListe().elementAt(
-// index)).setNbOfNodes(Register.Instance().getSize());
-//
-// if (count != 0) {
-// SuperNodeListe.Instance().forwardCountNode();
-// }
-//
-// System.out.println("I return " + count + " nodes");
-// // System.out.println( reg ) ;
-// // SuperNodeListe.Instance().viewAll() ;
-// return reg;
-// }
-// }