- Correct interaction with the Mapping library.
- Correction of some bugs.
- Cleaning (partially) the code.
- /!\ Some code is used for tests with fault tolerance ! This code is fully dependent on my account on Grid'5000 ! To be cleaned /!\
import java.net.ServerSocket;
import java.net.Socket;
import java.rmi.Naming;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+import and.Mapping.GNode;
import and.Mapping.Utils;
public class JaceDaemon {
// attributes
public static JaceDaemon Instance = null;
private String snode_IP = null;
- private int snode_port = 1098;
- private int daemonPort = 1098;
+ private int snode_port = 1099;
+ private int daemonPort = 1099;
private int heartTime; // HeartBeat frequency
private String protocol;
private boolean running = false;
- public JaceDaemon(String superNode, int port, String comProtocol) {
- if (!superNode.equals("-d")) {
+ public JaceDaemon( String superNode, int port, String comProtocol ) {
+ if( !superNode.equals( "-d" ) )
+ {
// snode_IP = LocalHost.Instance().resolve(superNode); // get IP of
// the super node
- snode_IP = superNode;
+ snode_IP = superNode ;
}
- daemonPort = port;
- protocol = comProtocol;
- running = true;
- Instance = this;
+ daemonPort = port ;
+ protocol = comProtocol ;
+ running = true ;
+ Instance = this ;
// initialize();
}
*
**/
public void initialize() {
- LocalHost.Instance().setPort(daemonPort);
- exportObject(); // Iinstanciate the JaceServer localy
- reconnectSuperNode(); // Connect to one of the SuperNodes
- if (protocol.equals("socket")) {
- listenForRequests();
+ LocalHost.Instance().setPort( daemonPort ) ;
+ exportObject() ; // Instanciate the JaceServer localy
+ reconnectSuperNode() ; // Connect to one of the SuperNodes
+
+ if( protocol.equals( "socket" ) )
+ {
+ listenForRequests() ;
}
-
- /*
- * System.out.println("sleep de 5 secondes avt tuer Daemon"); try {
- * Thread.sleep(5000); } catch(Exception e1) {}
- *
- *
- * sortir();
- */
}
/**
*
**/
private void exportObject() {
- // if( protocol.equals( "rmi" ) ) {
- JaceInterface ref = null;
- JaceServer myServer = null;
-
- //System.out.println("Name of local machine is : "
- // + LocalHost.Instance().getName());
- //System.out.println("IP of local machine is : "
- // + LocalHost.Instance().getIP());
+ JaceInterface ref = null ;
+ JaceServer myServer = null ;
+ Registry reg ;
+
try {
+
+ while( true )
+ {
+ reg = LocateRegistry.getRegistry( daemonPort ) ;
+
+ String tab[] = reg.list() ;
+
+ System.out.println( "There is an existing RMI Registry on port "+daemonPort+" with "+tab.length+" entries!" ) ;
+ for( int i = 0 ; i < tab.length ; i++ )
+ {
+ try {
+ if( UnicastRemoteObject.unexportObject( Naming.lookup(tab[i]), true ) )
+ {
+ System.out.println( "Register successfuly deleted!" ) ;
+ } else {
+ System.err.println( "Register undeleted !!!" ) ;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ if( UnicastRemoteObject.unexportObject( myServer, true ) )
+ {
+ System.out.println( "Register successfuly deleted!" ) ;
+ } else {
+ System.err.println( "Register undeleted !!!" ) ;
+ }
+ }
+ } catch( RemoteException e ) {
+ }
+
+
+ try {
+ if (System.getSecurityManager() == null) {
+ System.setSecurityManager(new SecurityManager());
+ }
+
// launch the JaceServer
myServer = new JaceServer( /* this */);
- java.rmi.registry.LocateRegistry.createRegistry(daemonPort);
- java.rmi.registry.LocateRegistry.getRegistry(daemonPort).rebind(
+ LocateRegistry.createRegistry(daemonPort);
+ LocateRegistry.getRegistry(daemonPort).rebind(
"JaceServer", myServer);
ref = (JaceInterface) Naming.lookup("rmi://"
+ LocalHost.Instance().getIP() + ":" + daemonPort
}
LocalHost.Instance().setStub(ref);
- // }
}
/**
}
}
-
+
+
/**
*
**/
} catch (Exception e) {
//System.out
// .println("Snode not launched, try another one (1/2s)");
- try {
- Thread.sleep(500);
- } catch (Exception e1) {
- // nothing
- }
+// try {
+// Thread.sleep(500);
+// } catch (Exception e1) {
+// // nothing
+// }
}
}
// LocalHost.Instance().getIP(),
// LocalHost.Instance().getName(),
// daemonPort ) ;
+
+ GNode me = Utils.createGNode() ;
+
+ if( me == null )
+ {
+ System.err.println( "Problem during the creation of my GNode !!" ) ;
+ System.exit( 1 ) ;
+ } else {
+ if( me.getIP().equals( "" ) || me.getIP() == null
+ || me.getIP().isEmpty()
+ || ! me.getIP().equals( LocalHost.Instance().getIP()))
+ {
+ System.err.println( "Problem with my IP address in my GNode !!" ) ;
+ System.exit( 2 ) ;
+ }
+ }
snodeStub.workerRegistering(LocalHost.Instance().getStub(),
LocalHost.Instance().getIP(), LocalHost.Instance()
- .getName(), daemonPort, Utils.createGNode());
+ .getName(), daemonPort, me ) ;
// Launching the heart beat thread
HeartBeatThread.Instance().setHeartTime(heartTime);
LocalHost.Instance().setStartedThreads(false);
System.out.println("Reinitialization of the Daemon");
- System.out.println("I kill the application if any exists");
+ System.out.println( "I kill the application if any exists" ) ;
// ScanThread.Instance().setScanning( false ) ;
// System.out.println( "Set ScanThread off" ) ;
// Sender.Instance().kill() ;
try {
- Thread.sleep(2500);
+ Thread.sleep( 2500 ) ;
} catch (Exception e) {
// nothing
}
Register.Instance().purge();
} catch (Exception e) {
- System.err.println("Crashed killing the application : " + e);
+ System.err.println( "Crashed killing the application : " + e ) ;
}
- System.out.println("Daemon reinitialized");
- // Runtime.getRuntime().gc() ;
+ System.out.println( "Daemon reinitialized" ) ;
+ System.gc() ;
reconnectSuperNode();
}
public void setSpawner(JaceSpawnerInterface spawnerStub)
throws RemoteException;
- public void updateRegister(Node oldNode, Node node) throws RemoteException;
+ public int updateRegister(Node oldNode, Node node, int rank) throws RemoteException;
public void getBackupForNewNode(int rank) throws RemoteException;
+
+ public void suicide2(String string)throws RemoteException ;
}
if (entity.equals("-Daemon")) {
System.out
.println("\n*************** LAUNCHING ---- DAEMON *****");
- JaceDaemon daemon = new JaceDaemon(superNodeName, port,
- comProtocol);
+ JaceDaemon daemon = new JaceDaemon( superNodeName, port,
+ comProtocol ) ;
daemon.initialize();
} else if (entity.equals("-Spawner")) {
if (args.length > 9) {
int nbDaemonPerThread = -1;
int nbSavingNodes = -1;
int algoMapping = -1;
+ int test = -1 ;
double paramAlgo = 0.5 ;
+ int nbFault = 0 ;
+ int faultTime = 0 ;
try {
nbDaemonPerSpawner = new Integer(args[4]).intValue();
nbDaemonPerThread = new Integer(args[5]).intValue();
nbSavingNodes = new Integer(args[6]).intValue();
- algoMapping = new Integer(args[7]).intValue();
- paramAlgo = new Double(args[8]).doubleValue();
+ test = new Integer(args[7]).intValue();
+ nbFault = new Integer(args[8]).intValue();
+ faultTime = new Integer(args[9]).intValue();
+ algoMapping = new Integer(args[10]).intValue();
+ paramAlgo = new Double(args[11]).doubleValue();
} catch (NumberFormatException e) {
System.err.println("The number of Daemons per spawner and the number of daemons per thread must be integers: "
+ e);
System.exit(0);
}
//System.out.println("=====> " + algoMapping);
- param = new String[args.length - 9];
- for (int i = 9; i < args.length; i++) {
- param[i - 9] = args[i];
+ param = new String[args.length - 12];
+ for (int i = 12; i < args.length; i++) {
+ param[i - 12] = args[i];
System.out.println("=> " + args[i]);
}
JaceSpawner spawner = new JaceSpawner(superNodeName, port,
comProtocol, param, nbDaemonPerSpawner,
- nbDaemonPerThread, nbSavingNodes, algoMapping, paramAlgo);
+ nbDaemonPerThread, nbSavingNodes, algoMapping, paramAlgo, test, nbFault, faultTime);
spawner.initialize();
}
System.out
.println("-Daemon : <option> = [superNodeName] [daemonPort] [protocol]");
System.out
- .println("ex : java jaceP2P.JaceP2P -Daemon cluster1 1098 rmi");
+ .println("ex : java jaceP2P.JaceP2P -Daemon cluster1 1099 rmi");
System.out.println("");
System.out
.println("-SNode : <option> = [superNodeName] [superNodePort] [protocol] [timeHeartBeat]");
System.out
- .println("ex : java jaceP2P.JaceP2P -SNode cluster1 1098 rmi 500");
+ .println("ex : java jaceP2P.JaceP2P -SNode cluster1 1099 rmi 500");
System.out.println("");
System.out
.println("-Spawner : <option> = [superNodeName] [SpawnerPort] [protocol] nbDaemonPerSpawner nbDaemonPerThread nbresave nbTask URLToTaskName <TaskParam>");
System.out
- .println("ex : java jaceP2P.JaceP2P -Spawner cluster1 1098 rmi 8 4 3 16 http://bilbo/staff/vuillemi/java/LinSolv2 1000 0 20000 5");
+ .println("ex : java jaceP2P.JaceP2P -Spawner cluster1 1099 rmi 8 4 3 16 http://bilbo/staff/vuillemi/java/LinSolv2 1000 0 20000 5");
System.out
- .println("ex : java jaceP2P.JaceP2P -Spawner cluster1 1098 rmi 8 4 3 16 file:/home/vuillemi/java/LinSolv2 1000 0 20000 5");
+ .println("ex : java jaceP2P.JaceP2P -Spawner cluster1 1099 rmi 8 4 3 16 file:/home/vuillemi/java/LinSolv2 1000 0 20000 5");
System.exit(0);
}
}
return 0;
}
- public void updateRegister(Node oldNode, Node node) throws RemoteException {
+ public int updateRegister( Node oldNode, Node node, int rank ) throws RemoteException {
// if(tag==1)
// HeartBeatThread.Instance().setServer((Object)node.getStub());
Calendar cal = new GregorianCalendar();
System.out.println("at time=" + cal.get(Calendar.MINUTE) + ":"
+ cal.get(Calendar.SECOND));
- System.out.println("Modify REGISTER");
+ System.out.println("Modify REGISTER");
try {
- // System.out.println("blablablablabalablablabalbalab");
- System.out.println("oldName=" + oldNode.getName());
- boolean b = Register.Instance().removeNodeOfName(oldNode.getName());
- if (b)
- System.out.println("removed old Node!!!!!");
- else
- System.out.println("didn't find old Node!!!!");
-
- Register.Instance().addNode(node);
- Register.Instance().viewAll();
+ boolean b = false ;
+ if( oldNode != null )
+ {
+ System.out.println("Old node name=" + oldNode.getName());
+ b = Register.Instance().removeNodeOfName(oldNode.getName());
+ }
+ if( b )
+ {
+ System.out.println("Old node removed !");
+ } else {
+ System.out.println("Did not find the old Node !");
+ }
+
+ if( node != null )
+ {
+ Register.Instance().addNode(node);
+ } else {
+ System.err.println( "The new node is NULL !" ) ;
+ return 1 ;
+ }
+// Register.Instance().viewAll();
TaskId myTaskId = null;
+// myTaskId = Register.Instance().getListeOfTasks()
+// .getTaskIdOfHostStub(oldNode.getStub());
myTaskId = Register.Instance().getListeOfTasks()
- .getTaskIdOfHostStub(oldNode.getStub());
+ .getTaskIdOfRank( rank ) ;
myTaskId.setHostIP(node.getIP());
myTaskId.setHostName(node.getName());
// Register.Instance().setVersion(version);
myTaskId.setHostStub(node.getStub());
+
+ return 0 ;
} catch (Exception e) {
System.err.println("Error in updateregister :" + e);
+ return 1 ;
// e.printStackTrace();
}
}
}
public void run() {
- BackupsManager.Instance().initialize(req);
+ BackupsManager.Instance().initialize( req ) ;
}
}
class ReinitDaemon extends Thread {
- public ReinitDaemon() {
- }
+ public ReinitDaemon() {}
public void run() {
- JaceDaemon.Instance().reinitDaemon();
+ JaceDaemon.Instance().reinitDaemon() ;
}
}
+
+ @Override
+ public void suicide2( String mes ) throws RemoteException
+ {
+ System.out.println( "Killed because: " + mes ) ;
+
+ try{
+ UnicastRemoteObject.unexportObject( this, true ) ;
+ }
+ catch( Exception e ) {
+ System.err.println( "Unable to unexport myself: " + e ) ;
+ }
+
+ System.exit( 0 ) ;
+ }
}
package jaceP2P;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
import java.rmi.Naming;
+import java.rmi.RemoteException;
+import java.rmi.UnmarshalException;
import java.util.Calendar;
import java.util.GregorianCalendar;
+import java.util.Random;
import java.util.Vector;
+import and.Mapping.Algo;
+import and.Mapping.Utils;
+
public class JaceSpawner {
private Class<?> c;
private Loader load;
private Task tache = null;
public static JaceSpawner Instance;
private static String superNode_IP = null;
- private int superNode_port = 1098;
+ private int superNode_port = 1099;
private static int spawnerPort = 1099;
- private static JaceSuperNodeInterface centralServer = null;
+ protected static JaceSuperNodeInterface centralServer = null;
private JaceSpawnerInterface spawnerRef = null;
private int nbTasks;
private String appliName;
private int algo;
private double paramAlgo ;
private String idAlgo ;
+
+ // ** Test ** //
+ private int test;
+ private double dh ;
+ protected int nbFault ;
+ protected int faultTime ;
public JaceSpawner(String superNode, int port, String comProtocol,
String[] args, int nbDaemonPerSpawner, int nbDaemonPerThread,
- int nbSavingNodes, int _algo, double _paramAlgo) {
+ int nbSavingNodes, int _algo, double _paramAlgo, int _test, int _nbF, int _fT) {
// superNode_IP = LocalHost.Instance().resolve(superNode);
algo = _algo;
paramAlgo = _paramAlgo ;
+
+ test = _test ;
+ nbFault = _nbF ;
+ faultTime = _fT ;
+
+
superNode_IP = superNode;
spawnerPort = port;
protocol = comProtocol;
}
idAlgo = _idAlgo ;
- // System.out.println("xxxxxxxxxxxxxxx reg size="+reg.getSize()+" xxxxxxxxxxxxxx");
+
this.appliName = appliName;
this.nbTasks = nbTasks;
RunningApplication.Instance().setRunning(true);
RunningApplication.Instance().setNumberOfDisconnections(nbdc);
RunningApplication.Instance().setNumberOfSpawnerDisconnections(nbsdc);
- // System.out.println("+++++++++++++++++++++++++");
+
Instance = this;
// if(tag==0)
broadcastRegister(1);
ScanThreadSpawner.Instance().start();
broadcastScanning();
-// System.out.println("apres broadcastScanning");
+
new StartScanning().start();
} else {
System.err.println("Cannot find myself in the spawnersList !");
public void initialize() {
// if(protocol.equals("rmi")){
// launch the JaceSpawnerServer
+ if (System.getSecurityManager() == null) {
+ System.setSecurityManager(new SecurityManager());
+ }
+
+// signal = false ;
+
exportObject();
connectSuperNode();
createAppli();
createSpawnerNetwork();
+ // ** Tests ** //
+ new FaultMake().run() ;
// }
}
}
public synchronized void signalDeadNode(JaceInterface host, int rankOfDead) {
- try {
+
+
TaskId myTaskId = null;
int nb = 0;
int nbC = 0;
nbC = RunningApplication.Instance().getNumberOfCouilles();
System.out.println("At time = " + time + "s, NbDisconnection = "
+ nb + ", NbProblem = " + nbC);
+
+ if( host == null )
+ System.err.println( "SIGNAL DE NODE NULL" ) ;
// !!!!!!!!!!!!!!actualiser le ListeTask ds le Register
- myTaskId = Register.Instance().getListeOfTasks()
+ try {
+ myTaskId = Register.Instance().getListeOfTasks()
.getTaskIdOfHostStub(host);
+ } catch( Exception e ) {}
+
if (myTaskId == null) {
- Register.Instance.getListeOfTasks().viewAll();
myTaskId = Register.Instance().getListeOfTasks()
.getTaskIdOfRank(rankOfDead);
+ if( myTaskId == null )
+ {
+ System.err.println("Houston we have a serious problem!!");
+ return ;
+ }
+
JaceInterface deadStub = myTaskId.getHostStub();
- deadStub.suicide("Not doing a good work");
+
+ if( deadStub != null )
+ {
+ try{
+ deadStub.suicide2("Not doing a good work");
+ }catch(Exception e){}
+ } else {
+ System.err.println( "Dead node stub unavailable!" );
+ }
}
- myTaskId.setHostIP(null);
- myTaskId.setHostName(null);
- Node noeud = Register.Instance().getNodeOfStub(
- myTaskId.getHostStub());
- myTaskId.setHostStub(null);
+
+ Node noeud = Register.Instance().getNodeOfName( myTaskId.getHostName() ) ;
+
int rankDeaD = myTaskId.getRank();
- String nomNoeud = noeud.getName();
- // Register.Instance().removeNodeAt(i);
- // Register.Instance().removeNode(host.getIP());
- // System.out.println("fait le remove : taille = " +
- // Register.Instance().getSize());
+ String nomNoeud = "" ;
+
+ if( noeud != null )
+ {
+ nomNoeud = noeud.getName();
+ }
- boolean b = Register.Instance().removeNodeOfName(noeud.getName());
+ boolean b = false ;
+
+ if( ! nomNoeud.equals( "" ) )
+ {
+ b = Register.Instance().removeNodeOfName( nomNoeud ) ;
+ } else {
+ System.err.println( "Dead node name unknown!!" ) ;
+ }
+
+ if( ! b )
+ {
+ b = Register.Instance().removeNode( noeud ) ;
+ }
- if (b == true) {
+ if( b == true )
+ {
System.out.println("Removing Node of rank "
+ rankDeaD + " : size = "
+ Register.Instance().getSize());
System.out.println("At time=" + cal.get(Calendar.MINUTE) + ":"
+ cal.get(Calendar.SECOND));
- // retrouver SI POSSIBLE un autre libre pr remplacer celui la pr
- // cette tache
-
/**** Sébastien Miquée **/
- //Node tmpNode = foundToReplaceThisNode(rankDeaD, nomNoeud);
- Node tmpNode = foundToReplaceThisNode(rankDeaD, nomNoeud, noeud);
+ Node tmpNode = null ;
+ int retry = 0, retryMax = 4 ;
+
+ while( tmpNode == null )
+ {
+ tmpNode = foundToReplaceThisNode(rankDeaD, nomNoeud, noeud);
+
+ if( tmpNode == null )
+ {
+ try{
+ Thread.sleep( 1000 ) ;
+ } catch( Exception e ) {}
+
+ retry++ ;
+
+ if( retry > retryMax )
+ {
+ System.err.println( "Unable to replace the dead node "+nomNoeud ) ;
+ return ;
+ }
+ }
+ }
+
try {
- // broadcastRegister(0);
updateConcernedNodes(rankDeaD, noeud, tmpNode);
Thread.sleep(500);
- System.out.println("Set scanning on %%%%%%");
- tmpNode.getStub().setScanning(true);
+ System.out.println("Set scanning on "+tmpNode.getName());
+ tmpNode.getStub().setScanning( true ) ;
} catch (Exception e) {
- System.err.println("Unable to setScannig on for the new node: "
- + e);
+ try {
+ Thread.sleep( 2000 ) ;
+
+ tmpNode.getStub().setScanning( true ) ;
+ } catch (InterruptedException e1) {
+ } catch (RemoteException e2) {
+ System.err.println( "Unable to setScanning on for the new node: " + e2 ) ;
+ }
+ System.err.println("Unable to setScanning on for the new node: "
+ + e) ;
}
- // Register.Instance().getListeOfTasks().viewAll();
for (int z = 0; z < spawnersList.size(); z++)
+ {
if (!((JaceSpawnerInterface) spawnersList.get(z))
.equals(Register.Instance().getSpawnerStub()))
+ {
try {
((JaceSpawnerInterface) spawnersList.get(z))
.replaceDeamonBy(noeud, tmpNode, rankDeaD);
.println("Unable to broadcast the modifications to all the spawners: "
+ e);
}
- } catch (Exception ee) {
- System.err.println("Error in signalDeadNode() :" + ee);
- }
+ }
+ }
}
// verifie si les noeud notes vivant ds le Register.Instance() du SuperNode
// pr les requisitionner
/*** Sébastien Miquée ***/
-
- //private synchronized Node foundToReplaceThisNode(int theRank, String nom) {
- private synchronized Node foundToReplaceThisNode(int theRank, String nom, Node _n) {
- // int i = 0;
+ private synchronized Node foundToReplaceThisNode(int theRank, String nom, Node _n)
+ {
boolean found = false ;
Node node = null ;
+ int nbNull = 0 ;
while( found == false ) {
try {
-
- //node = centralServer.getNewNode(LocalHost.Instance().getIP());
- node = centralServer.getNewNode( idAlgo, _n);
+ node = null ;
- if( node != null )
+ node = centralServer.getNewNode( idAlgo, theRank ) ;
+
+ if( node != null && ! node.getIP().isEmpty() && node.getIP() != null
+ && ! node.getIP().equals( "" ) )
{
found = true ;
} else {
- Thread.sleep( 1000 ) ;
- System.out.println("Pas de bon retour !");
+ System.err.println("Returned node is null!");
+ nbNull++ ;
+ try {
+ Thread.sleep( 2000 ) ;
+ } catch( Exception e ) {}
}
} catch (Exception e) {
// trouver un autre superNode et lui demander le noeud a lui
connectSuperNode();
}
+
+ if( Register.Instance().existNode( node ) != -1 )
+ {
+ found = false ;
+ }
}
- if (node != null) {
- System.out.println("Using Node " + node.getName() + " ("
- + node.getIP() + ") in order to replace " + nom
- + " size before add: " + Register.Instance().getSize()
- + "\n\n");
+ if( node != null )
+ {
+ System.out.println( "Using Node " + node.getName() + " in order to replace " + nom + "\n" ) ;
+
node.setAliveFlag(true);
node.setAliveTime();
// TODO verif pourkoi superNode me le redonne
// alors qu'il fait deja du calcul
// int is = Register.Instance().existNode(node.getIP());
- int is = Register.Instance().existNode(node);
- if (is != -1) {
+ int is = Register.Instance().existNode( node ) ;
+
+ if( is != -1 )
+ {
System.out.println("The Node is already in the register ! I don't add it.");
System.out.println("Node " + node.getName() + " not added !") ;
node = null;
myTaskId.setHostName(node.getName());
myTaskId.setHostStub(node.getStub());
- // Register.Instance().getListeOfTasks().viewAll();
int neighborRank;
if (theRank == 0)
+ {
neighborRank = Register.Instance().getSize() - 1;
- else
+ } else {
neighborRank = theRank - 1;
+ }
+
TaskId neighborTask2 = Register.Instance().getListeOfTasks()
- .getTaskIdOfRank(neighborRank);
- try {
- JaceInterface jaceStub = neighborTask2.getHostStub();
- jaceStub.updateHeart(node.getStub());
- } catch (Exception e) {
- System.err.println("Next node unreachable ! " + e);
- // node = null;
+ .getTaskIdOfRank( neighborRank ) ;
+
+ int loop = 0, MAX_LOOP = 1 ;
+ boolean ok = false ;
+ JaceInterface jaceStub = null ;
+
+ while( !ok && loop < MAX_LOOP )
+ {
+ try {
+ jaceStub = neighborTask2.getHostStub();
+ jaceStub.updateHeart(node.getStub());
+
+ ok = true ;
+ } catch( Exception e ) {
+ loop++ ;
+
+ if( loop < MAX_LOOP )
+ {
+ try {
+ Thread.sleep( loop * 2000 ) ;
+ } catch (InterruptedException e1) {}
+ }
+
+ if( loop == MAX_LOOP )
+ {
+ System.err.println( "Next node unreachable! " + e ) ;
+ }
+ }
+ }
+
+ if( loop == MAX_LOOP )
+ {
+
+ try {
+ node.getStub().suicide2( "Not reachable!" ) ;
+ } catch (RemoteException e1) {
+ System.err.println( "Unable to suicide the node!\n"+e1 );
+ signalDeadNode( null, neighborTask2.getRank() ) ;
+ }
}
}
if (centralServer == null) {
System.err.println("Central Server not localized !");
}
- node = centralServer.getNewNode( idAlgo, null ) ;
+ node = centralServer.getNewNode( idAlgo, -2 ) ;
RunningApplication.Instance()
.incrementNumberOfSpawnerDisconnections();
//found = true;
} catch (Exception e) {
// trouver un autre superNode et lui demander le noeud a lui
System.err.println("Super Node not localized !\n " + e);
-// System.out.println("pas localise le super node " + e);
-// System.out.println("pas localise le super node " + e);
-// System.out.println("pas localise le super node " + e);
-// System.out.println("pas localise le super node " + e);
-// System.out.println("pas localise le super node " + e);
-// System.out.println("pas localise le super node " + e);
-// System.out.println("pas localise le super node " + e);
System.err.println("My IP : " + LocalHost.Instance().getIP());
if (centralServer == null) {
System.err.println("CentralServer is NULL !");
+ LocalHost.Instance().resolve(node.getName())
+ ") to replace a dead spawner\n\n");
try {
- // Register.Instance().viewAll();
- // Register.Instance().getListeOfTasks().viewAll();
spawnerStub = node.getStub().transformIntoSpawner(
params,
appliName,
, idAlgo);
spawnersList.setElementAt(spawnerStub, index);
-// spawnerStub.setIdAlgo( idAlgo ) ;
-
new StartProcessThread(index).start();
- // spawnerStub.startProcess( spawnersList);
+
} catch (Exception e) {
System.err.println("Unable to reach the new spawner: " + e);
}
.getNumberOfSpawnerDisconnections();
System.out.println("Application finished successfully !");
-// System.out.println("Application finished successfully !!!!!!");
-// System.out.println("Application finished successfully !!!!!!");
-// System.out.println("Application finished successfully !!!!!!");
-// System.out.println("Application finished successfully !!!!!!");
-// System.out.println("Application finished successfully !!!!!!");
-// System.out
-// .println("Application finished successfully !!!!!!\n");
+
System.out.println("TOTAL TIME in s : " + (finalTime / 1000));
System.out.println("nb of desconnections: " + nbe);
System.out.println("nb of spawners desconnections: " + nbsdc);
+
+ // ** Tests ** //
+ String path = "/home/lyon/smiquee/resultats/execTime_CG_"+algo+"_"+test ;
+ PrintWriter ecrivain = null ;
+ ecrivain = new PrintWriter( new OutputStreamWriter( new FileOutputStream( path ), "UTF8" ) ) ;
+
+ ecrivain.println( "TOTAL TIME in s : " + (finalTime / 1000));
+ ecrivain.println( "nb of desconnections: " + nbe);
+ ecrivain.println( "nb of spawners desconnections: " + nbsdc);
+ ecrivain.println( "DH = "+dh ) ;
+
+ ecrivain.flush() ;
+ ecrivain.close() ;
+
+
if (JaceDaemon.Instance().isRunning()) {
JaceDaemon.Instance().reconnectSuperNode();
// purger l'appli
RunningApplication.Instance().purge();
- // System.exit(1);
}
/** Suprresion of the mapping algorithm on the SuperNode **/
boolean connected = false;
if (!(superNode_IP == null)) {
try {
+ centralServer = null ;
+ System.gc() ;
+
System.out.println("Trying to invoke super node "
+ superNode_IP);
centralServer = (JaceSuperNodeInterface) Naming.lookup("rmi://"
Node noeud = null;
boolean recieved = false;
+ idAlgo = LocalHost.Instance().getIP() + ":" + LocalHost.Instance().getPort() ;
+
System.out.println("Trying to get a Register on the SuperNode");
int nbExtraSpawners = 0;
if (nbTasks > nbOfDaemonsPerSpawner) {
}
while (!recieved) {
try {
- registerSpawner = centralServer.getRegisterSpawner(LocalHost
- .Instance().getIP(), nbTasks, (Task) tache, nbTasks
+ registerSpawner = centralServer.getRegisterSpawner(idAlgo,
+ nbTasks, (Task) tache, nbTasks
+ nbExtraSpawners, algo, paramAlgo);
recieved = true;
} catch (Exception e) {
}
}
- idAlgo = LocalHost.Instance().getIP() + ":" + LocalHost.Instance().getPort() ;
+ // ** Tests ** //
+ try {
+ Algo al = centralServer.getAlgo( idAlgo ) ;
+
+ dh = al.getGrid().getHeterogenityDegre() ;
+ System.out.println( "### DH = " + dh ) ;
+
+ Utils.writeGraph( al.getGraph(), "/home/lyon/smiquee/resultats/",
+ "graph_CG_"+algo+"_"+test+".xml" ) ;
+ Utils.writeGrid( al.getGrid(), "/home/lyon/smiquee/resultats/",
+ "grid_CG_"+algo+"_"+test+".xml") ;
+ Utils.writeMapping( al.getMapping(), "/home/lyon/smiquee/resultats/",
+ "mapping_CG_"+algo+"_"+test+".xml" ) ;
+ } catch (RemoteException e1) {
+ System.err.println( "Problème avec Algo dans Spawner !" ) ;
+ e1.printStackTrace();
+ }
if (registerSpawner.getSize() != (nbTasks + nbExtraSpawners)) {
System.err.println("I did not recieve enough nodes from superNode!!!! \n killing application !!!!");
for (int i = 0; i < registerSpawner.getSize(); i++) {
try {
- registerSpawner.getNodeAt(i).getStub().reconnectSuperNode();
+ registerSpawner.getNodeAt(i).getStub().suicide( "Not enough nodes for the application" ) ;
+
} catch (Exception e) {
System.err.println("The reserved node was unable to reconnect to the super node");
}
spawnersList = new Vector<Object>();
for (int i = 0; i < nbExtraSpawners && i < registerSpawner.getSize(); i++) {
spawnersList.add(registerSpawner.getNodeAt(0));
-// * nbOfDaemonsPerSpawner));
+
registerSpawner.removeNodeOfName(registerSpawner.getNodeAt(0).getName());
-// * nbOfDaemonsPerSpawner));
+
}
registerSpawner.setNbOfTasks(nbTasks);
}
-// /**
-// * Set the identifier of the mapping algorithm used.
-// * @param _s The mapping identifier
-// *
-// * @author Sébastien Miquée
-// */
-// public void setIdAlgo( String _s ) throws RemoteException
-// {
-// System.err.println("############# SET ID ALGO ################# "+_s);
-// idAlgo = _s ;
-// }
-
public class TransformThread extends Thread {
int i;
Node n;
System.err.println("The Super Node is maybe dead: " + e1) ;
for (int z = 0; z < Register.Instance().getSize(); z++) {
try {
- Register.Instance().getNodeAt(z).getStub()
- .reconnectSuperNode();
+ Register.Instance().getNodeAt(z).getStub().suicide2("Problem") ;
+
} catch (Exception ez) {
System.err.println("The reserved node was unable to reconnect to the super node: \n"
+ ez);
}
}
}
+
+
+ public class FaultMake extends Thread {
+
+ public FaultMake(){}
+
+ public void run()
+ {
+ ListeTask t = null ;
+ Random r = null ;
+ int next, old = -1 ;
+
+ System.out.println( "Starting fault tolerance !" ) ;
+
+ while( ! RunningApplication.Instance().isRunning() )
+ {
+ /** Waiting some time the beginning of the computation **/
+ try {
+ sleep( 1000 ) ;
+ } catch (InterruptedException e) {
+ }
+ }
+
+ while( RunningApplication.Instance().isRunning() )
+ {
+ /** Waiting some time ... **/
+ try {
+ sleep( faultTime * 1000 ) ;
+ } catch (InterruptedException e) {
+ }
+
+ /** ... and kill some daemons ! **/
+ t = Register.Instance().getListeOfTasks();
+ r = new Random() ;
+
+ for( int i = 0 ; i < nbFault ; i++ )
+ {
+ next = r.nextInt( t.getSize() ) ;
+
+ while( next == old )
+ {
+ next = r.nextInt( t.getSize() ) ;
+ }
+ old = next ;
+
+ Node noeud = null;
+ try {
+ TaskId recev = null;
+ System.out.println("Making fault on Task" + next);
+
+ recev = t.getTaskIdOfRank( next );
+
+ JaceInterface stub = recev.getHostStub();
+ System.out.println("name = " + recev.getHostName());
+ noeud = Register.Instance().getNodeOfStub( stub ) ;
+
+ stub.suicide2( "Test fault tolerance" ) ;
+
+ } catch (UnmarshalException ue ){
+ } catch (Exception e) {
+ try {
+ System.err.println("Error in FaultMake on node: "
+ + noeud.getName() + ". " + e);
+ } catch (Exception e2) {
+ System.err.println("(Fault)Error in error:" + e2);
+ }
+ }
+
+ try {
+ sleep( 500 ) ;
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ }
+ }
+
+
public class StartProcessThread extends Thread {
int i;
// Register.Instance().getNode(workerIP).getWorkerStub().reconnectSuperNode();
// stub.reconnectSuperNode();
- stub.suicide("fin d'appli");
+ stub.suicide("End of application");
} catch (Exception e) {
- System.err.println("can't kill node " + name);
+ System.err.println("Cannot kill node " + name);
}
yield();
}
}
- public Register getRegister(int rank) {
+ @SuppressWarnings("unchecked")
+ public synchronized Register getRegister( int rank ) {
ListeTask listOfTasks = Register.Instance().getListeOfTasks();
- Vector<Integer> dependencies = getDependencies(rank, listOfTasks.getSize());
+ Vector dependencies = getDependencies(rank, listOfTasks.getSize());
Register g = new Register();
ListeTask newListOfTasks = new ListeTask();
+
g.setAppliName(Register.Instance().getAppliName());
g.setParams(Register.Instance().getParams());
g.setSpawnerStub(Register.Instance().getSpawnerStub());
g.setNbOfTasks(Register.Instance().getNbOfTasks());
// g.setVersion(reg.getVersion());
+
for (int j = 0; j < dependencies.size(); j++) {
TaskId id = listOfTasks.getTaskIdOfRank(((Integer) dependencies
.elementAt(j)).intValue());
newListOfTasks.addTask(id);
if (id.getHostStub() != null) {
Node noeud = Register.Instance()
- .getNodeOfStub(id.getHostStub());
- g.addNode(noeud);
+ .getNodeOfName( id.getHostName() ) ;// (id.getHostStub());
+ if( noeud != null )
+ g.addNode( noeud ) ;
+ else
+ System.err.println( "PAS BON DU TOUT" ) ;
}
}
g.setListeOfTasks(newListOfTasks);
return g;
}
+ @SuppressWarnings("unchecked")
private void updateConcernedNodes(int rank, Node oldNode, Node node) {
ListeTask listOfTasks = Register.Instance().getListeOfTasks();
- Vector<?> dependencies = getDependencies(rank, listOfTasks.getSize());
- System.out.println("la liste des voisins concernes de : " + rank);
+ Vector dependencies = getDependencies(rank, listOfTasks.getSize());
+ System.out.println("List of concerned neighbors of task " + rank+": ");
for (int z = 0; z < dependencies.size(); z++)
System.out.print(((Integer) dependencies.elementAt(z)).intValue()
+ " ");
System.out.println();
// Register.Instance().setVersion(registerVersion);
// registerVersion++;
- Register.Instance()
- .setSpawnerStub(Register.Instance().getSpawnerStub());
+// Register.Instance()
+// .setSpawnerStub(Register.Instance().getSpawnerStub());
int s;
if ((dependencies.size() % nbOfDeamonsPerThread) == 0)
s = dependencies.size() / nbOfDeamonsPerThread;
else
System.out.println("Node " + oldNode.getName() + " of rank " + rank
+ " hasn't been removed");
- Register.Instance().addNode(node);
+
+ if( node != null )
+ {
+ Register.Instance().addNode(node);
- TaskId myTaskId = Register.Instance().getListeOfTasks()
+ TaskId myTaskId = Register.Instance().getListeOfTasks()
.getTaskIdOfHostStub(oldNode.getStub());
- myTaskId.setHostIP(node.getIP());
+ myTaskId.setHostIP(node.getIP());
- myTaskId.setHostName(node.getName());
- myTaskId.setHostStub(node.getStub());
- // Register.Instance().setVersion(Register.Instance().getVersion()+1);
- RunningApplication.Instance().incrementNumberOfDisconnections();
- System.out.println("Replacing node: " + oldNode.getName() + " with: "
+ myTaskId.setHostName(node.getName());
+ myTaskId.setHostStub(node.getStub());
+ // Register.Instance().setVersion(Register.Instance().getVersion()+1);
+ RunningApplication.Instance().incrementNumberOfDisconnections();
+ System.out.println("Replacing node: " + oldNode.getName() + " with: "
+ node.getName());
- // Register.Instance().getListeOfTasks().viewAll();
+ // Register.Instance().getListeOfTasks().viewAll();
+ } else {
+ System.err.println( "ReplaceDaemon: The new node is null!" ) ;
+ }
}
// @Override
final int NB_HEART_DECONNECT = 3;
// attribute
private int heartTime; // frequency of heartBeat
- private int port = 1098; // par la suite, donner par fichier de conf
+ private int port = 1099; // par la suite, donner par fichier de conf
private int timeBeforeKill; // wait for 3 non response of heartBeat to kill
// the Daemon
String protocol;
// create his list of SuperNode
// containing the IPs and ports
// but not already the stubs
+ if (System.getSecurityManager() == null) {
+ System.setSecurityManager(new SecurityManager());
+ }
+
+
SuperNodeListe.Instance().staticInitialization();
HeartBeatSNode.Instance().setHeartTime(heartTime);
// public Node getNewNode(String spawnerIP) throws RemoteException;
- public Node getNewNode(String spawnerIP, Node _deadNode) throws RemoteException;
+ public Node getNewNode( String _spawnerIP, int _rank ) throws RemoteException ;
+
+ public Node getNewNode( String spawnerIP, GNode _deadNode ) throws RemoteException;
public Vector<?> sendStub(String IP, int port, JaceSuperNodeInterface stub)
throws RemoteException;
public ArrayList<GNode> getGNodes() throws RemoteException ;
public void removeAlgo( String _id, int _mode ) throws RemoteException ;
+
+ public void setMapped( GNode _g, int _mode ) throws RemoteException ;
+
+ public void removeMappedGNode( GNode _g, int _mode ) throws RemoteException ;
+
+ // ** Tests ** //
+ public Algo getAlgo( String _spID ) throws RemoteException ;
}
/** ! **/
import and.Mapping.Algo;
import and.Mapping.DefaultMapping;
+import and.Mapping.FT_AIAC_QM;
+import and.Mapping.FT_FEC;
import and.Mapping.GNode;
import and.Mapping.GTask;
import and.Mapping.Graph;
import and.Mapping.Grid;
-import and.Mapping.LSM;
-import and.Mapping.QM;
+import and.Mapping.Maheve;
import and.Mapping.Simple;
-import and.Mapping.Utils;
public class JaceSuperNodeServer extends UnicastRemoteObject implements
private int beat;
private ArrayList<GNode> gnodes = null;
private ArrayList<Algo> algos = null ;
- private int count = 0 ;
private boolean inDemand = false, operating = false, authorized = false ;
-// private boolean daemonListChange ;
// Constructors
beat = timeBeat ;
gnodes = new ArrayList<GNode>() ;
algos = new ArrayList<Algo>() ;
-// daemonListChange = true ;
}
public int getSuperNodeBeat() throws RemoteException {
// Create the node
Node noeud = new Node(workerStub);
noeud.setName(workerName);
- noeud.setIP(workerIP);
+ noeud.setIP(g.getIP());
noeud.setAliveFlag(true);
noeud.setAliveTime();
noeud.setPort(port);
noeud.setAppliName(null);
noeud.setNbOfBeats(0);
- noeud.setId( count ) ;
- noeud.setId( Long.parseLong( workerIP.replace( ".", "" ) ) ) ;
+
+ String sid = workerIP.replace( ".", "" ) + port ;
+ Long id = Long.parseLong( sid ) ;
+ noeud.setId( id ) ;
g.setNode( noeud ) ;
- g.setId( noeud.getId() ) ;
+ g.setId( id ) ;
g.setMapped( false ) ;
workingOnGnodes() ;
gnodes.add( g ) ;
+ updateGrids( g ) ;
-// daemonListChange = true ;
// Insert the node in the Register.Instance() of the Super Node
Register.Instance().addNode(noeud);
operating = false ;
}
+
+ /**
+ * Update all mapping algorithms with a new node.
+ * @param _g The new node
+ *
+ * @author Sébastien Miquée
+ */
+ private synchronized void updateGrids( GNode _g )
+ {
+ if( _g != null )
+ {
+ for( int i = 0 ; i < algos.size() ; i++ )
+ {
+ algos.get( i ).getGrid().addGNode( _g ) ;
+ }
+ }
+
+ }
+
/****************************************************/
/****************************************************/
* @author Sébastien Miquée
*/
@Override
- public Register getRegisterSpawner(String spawnerIP, int nbTasks, Task t,
+ public synchronized Register getRegisterSpawner(String spawnerIP, int nbTasks, Task t,
int nbNoeuds, int algo, double paramAlgo) throws RemoteException {
// Have we the correct application ?
workingOnGnodes() ;
/** Initialization of Grid architecture (G5K for now) **/
- Grid grid = Utils.createGridG5k(gnodes);
-// grid.initClusters();
+ Grid grid = new Grid() ;
+
+ for( int i = 0 ; i < gnodes.size() ; i++ )
+ {
+ grid.addGNode( gnodes.get( i ) ) ;
+ }
/** Informing about the grid heterogeneity **/
graph.addGTask(ts.get(i));
}
- // -- debug !
- // graph.print() ;
-
- // try {
- // Thread.sleep(10000) ;
- // } catch( Exception e ) {}
-
- // grid.print() ;
- //
- // try {
- // Thread.sleep( 10000 ) ;
- // } catch( Exception e ) {}
-
+ /** TODO Loading algorithm class with parameters in a configuration file **/
/** Selection of the mapping algorithm **/
Algo al = null ;
al = new Simple(graph, grid);
break;
case 1:
- al = new QM(graph, grid, paramAlgo);
+ al = new FT_AIAC_QM(graph, grid, paramAlgo);
break;
case 2:
- al = new LSM(graph, grid, paramAlgo);
+ al = new FT_FEC(graph, grid, paramAlgo);
break;
+ case 3:
+ al = new Maheve( graph, grid ) ;
+ break ;
default:
al = new DefaultMapping( graph, grid, gnodes ) ;
}
/** Creating the register **/
ArrayList<GNode> ag = al.getMapping().getMappedGNodes();
+
+ System.out.println("NB returned nodes : "+ag.size());
+
+ /** Setting the algorithm's identifier **/
+ al.setIdS( spawnerIP ) ;
+
+ /** Adding the algorithm in the list **/
+ algos.add( al ) ;
+
+ int idAlgo = searchAlgo( spawnerIP ) ;
+
+ /** Mapping distribution over other SuperNodes */
+ SuperNodeListe.Instance().setMapping( al ) ;
+
+
+
authorized = true ;
for( int i = 0; i < ag.size(); i++ ) {
reg.addNode((Node) ag.get(i).getNode());
- delGNodeFromList( (Node) ag.get(i).getNode(), 2, spawnerIP ) ;
-// gnodes.remove(ag.get(i));
-// Register.Instance().removeNode((Node) ag.get(i).getNode());
+
+ ag.get(i).setMapped( true ) ;
+ setMapped( ag.get(i), 1 ) ;
+ Register.Instance().removeNode((Node) ag.get(i).getNode());
}
for( int i = 0 ; i < nb ; i ++ )
{
- sup = al.getOtherGNode( gnodes ) ;
+ sup = algos.get(idAlgo).getOtherGNode( gnodes ) ;
+ algos.get(idAlgo).getMapping().addOtherNode( sup ) ;
reg.addNodeBeg( (Node) sup.getNode() ) ;
- delGNodeFromList( (Node) sup.getNode(), 2, spawnerIP ) ;
+ setMapped( sup, 1 ) ;
+ Register.Instance().removeNode((Node) sup.getNode());
}
}
if (ag.size() != 0) {
SuperNodeListe.Instance().forwardCountNode();
}
-
- /** Setting the algorithm's identifier **/
- al.setIdS( spawnerIP ) ;
-
- /** Adding the algorithm in the list **/
- algos.add( al ) ;
}
-// System.out.println( "Spawner returned reg: " + reg ) ;
-
- /** Mapping distribution over other SuperNodes */
- SuperNodeListe.Instance().setMapping( al ) ;
-
operating = false ;
/** Returning result **/
}
+ public synchronized void setMapped( GNode _g, int _mode ) throws RemoteException
+ {
+ if( _g != null )
+ {
+ _g.setMapped( true ) ;
+
+ for( int i = 0 ; i < gnodes.size() ; i++ )
+ {
+ if( _g.getId() == gnodes.get( i ).getId() )
+ {
+ gnodes.remove( i ) ;
+ break ;
+ }
+ }
+
+ for( int i = 0 ; i < algos.size() ; i++ )
+ {
+ algos.get( i ).getGrid().setMappedStatus( _g, true ) ;
+ }
+
+ if( _mode == 1 )
+ {
+ authorized = true ;
+
+ SuperNodeListe.Instance().setMappedGNode( _g, 0 ) ;
+
+ authorized = false ;
+ }
+ } else {
+ System.err.println( "GNode is null is setMapped!" ) ;
+ }
+ }
+
/**
* Suppress a node from the gnodes list if this node is free, or remove
* it from the Mapping class of the mapping algorithm if this node is
* @author Sébastien Miquée
*/
@Override
- public GNode delGNodeFromList( Node _n, int _mode, String _spawnerIp ) throws RemoteException
+ public synchronized GNode delGNodeFromList( Node _n, int _mode, String _spawnerIp ) throws RemoteException
{
GNode removedGNode = null ;
workingOnGnodes() ;
free = true ;
}
-
- /** The dead node is not in the mapping **/
- if( _mode == 0 || _mode == 2)
+
+ if( _mode == 0 )
{
+ GNode dead = null ;
+
for( int i = 0 ; i < gnodes.size() ; i++ )
{
- if( ((Node)gnodes.get(i).getNode()).getId() == _n.getId() )
+ if( _n.getId() == ((Node) gnodes.get(i).getNode()).getId() )
{
- removedGNode = gnodes.remove( i ) ;
- Register.Instance().removeNodeOfName( removedGNode.getName() ) ;
+ dead = gnodes.remove( i ) ;
break ;
}
}
- }
-
- /** The dead node is in the mapping **/
- if( _mode == 1 )
- {
- /** Searching the algorithm **/
- int idAlgo = searchAlgo( _spawnerIp ) ;
- if( idAlgo == -1 )
+ if( dead != null )
{
- System.err.println( "No algorithm found for this Spawner!" ) ;
- return null ;
- }
-
- ArrayList<GNode> temp = algos.get( idAlgo ).getMapping().getMappedGNodes() ;
-
- for( int i = 0 ; i < temp.size() ; i++ )
- {
- if( ((Node)temp.get(i).getNode()).getId() == _n.getId() )
+ for( int i = 0 ; i < algos.size() ; i++ )
{
- removedGNode = temp.get( i ) ;
- Register.Instance().removeNodeOfName( removedGNode.getName() ) ;
- break ;
+ algos.get( i ).getGrid().removeGNode( dead ) ;
+ Register.Instance().removeNodeOfName( dead.getName() ) ;
+ SuperNodeListe.Instance().removeGNode( dead, _mode, _spawnerIp ) ;
}
- }
- }
-
- /** Removing the dead node from the Grid **/
- if( _mode == 0 || _mode == 1 ) {
- int idAlgo = searchAlgo( _spawnerIp ) ;
-
- if( idAlgo != -1 && _mode == 1 )
- {
- algos.get( idAlgo ).getGrid().removeGNode( removedGNode ) ;
+ } else {
+ System.err.println( "The dead node signaled does not exist!" ) ;
}
}
- /** Propagation of the deletion **/
- SuperNodeListe.Instance().removeGNode( removedGNode, _mode, _spawnerIp ) ;
-
if( free )
{
operating = false ;
*
* @author Sébastien Miquée
*/
- private void workingOnGnodes()
+ private synchronized void workingOnGnodes()
{
boolean tmp = true ;
inDemand = false ;
}
+
+ /**
+ * Search and return a new node when one failed or when JaceP2P needs another
+ * one. For the first case, the given failed node should not be null, and
+ * null in the other case.
+ * @param _spawnerIP IP of the requester
+ * @param _rank The task number number of the dead node
+ *
+ * @author Sébastien Miquée
+ */
+ @Override
+ public synchronized Node getNewNode( String _spawnerIP, int _rank ) throws RemoteException
+ {
+ int idNode = -1 ;
+ int idAlgo = searchAlgo( _spawnerIP ) ;
+
+ if( idAlgo == -1 )
+ {
+ System.err.println( "No algorithm found for this Spawner!" ) ;
+ return null ;
+ }
+
+ /** We have to replace a Spawner **/
+ if( _rank == -2 )
+ {
+ idNode = -2 ;
+ } else {
+ /** We have to replace a computing node **/
+ idNode = algos.get( idAlgo ).getMapping().getIdOfAssociation( _rank ) ;
+ }
+
+ if( idNode == -1 )
+ {
+ System.err.println( "No tasks corresponds to rank "+_rank+"!" ) ;
+ return null ;
+ }
+
+ GNode dead = null ;
+
+ if( idNode >= 0 )
+ {
+ dead = algos.get( idAlgo ).getMapping().getAssociation( idNode ).getGNode() ;
+ }
+
+ if( dead == null && idNode >= 0 )
+ {
+ System.err.println( "The GNode corresponding to the task "+_rank+" is null!" ) ;
+ System.err.println( "Trying to find a new node for this task (not optimal)..." ) ;
+ }
+
+ return getNewNode( _spawnerIP, dead ) ;
+ }
/**
* Search and return a new node when one failed or when JaceP2P needs another
* @author Sébastien Miquée
*/
@Override
- public Node getNewNode( String _spawnerIP, Node _deadNode ) throws RemoteException
+ public synchronized Node getNewNode( String _spawnerIP, GNode _deadNode ) throws RemoteException
{
Node node = null ;
- GNode remp = null, gnode = null ;
+ GNode remp = null ;
int idAlgo = searchAlgo( _spawnerIP ) ;
return null ;
}
+
/** Can we use gnodes ?**/
workingOnGnodes() ;
- if( _deadNode != null )
+ if( _deadNode != null )
{
authorized = true ;
- gnode = delGNodeFromList( _deadNode, 1, _spawnerIP ) ;
+ removeMappedGNode( _deadNode, 1 ) ;
+
+ authorized = false ;
- remp = algos.get( idAlgo ).replaceNode( gnode, gnodes ) ;
+ remp = algos.get( idAlgo ).replaceNode( _deadNode, gnodes ) ;
if( remp != null )
{
System.out.println( "Replacing node found." ) ;
+ authorized = true ;
+
remp.setMapped( true ) ;
- delGNodeFromList( (Node) remp.getNode(), 2, _spawnerIP ) ;
+ setMapped( remp, 1 ) ;
+ Register.Instance().removeNodeOfName( remp.getName() ) ;
+
+
+ /** Updating all mapping **/
+ updateMappedNode( _deadNode, remp, _spawnerIP ) ;
+ propagateReplaceNode( _deadNode, remp, _spawnerIP ) ;
authorized = false ;
authorized = true ;
- delGNodeFromList( (Node) remp.getNode(), 2, _spawnerIP ) ;
+ setMapped( remp, 1 ) ;
+ Register.Instance().removeNodeOfName( remp.getName() ) ;
authorized = false ;
if( remp != null )
{
node = (Node) remp.getNode() ;
+ } else {
+ System.err.println( "SuperNode: No new node found!" ) ;
}
- /** Updating all mapping **/
- updateMappedNode( gnode, remp, _spawnerIP ) ;
- propagateReplaceNode( gnode, remp, _spawnerIP ) ;
-
-
/** Free the gnodes use **/
operating = false ;
}
+ public synchronized void removeMappedGNode( GNode _g, int _mode ) throws RemoteException
+ {
+ if( _g != null )
+ {
+ for( int i = 0 ; i < algos.size() ; i++ )
+ {
+ algos.get( i ).getGrid().removeGNode( _g ) ;
+ }
+
+ if( _mode == 1 )
+ {
+ SuperNodeListe.Instance().removeGNode( _g, 0 ) ;
+ }
+ } else {
+ System.err.println( "GNode to be deleted is null!" ) ;
+ }
+ }
+
/**
* Replace a failed GNode in the mapping by another one.
* This method is called by the SuperNodeList, to broadcast the modification.
* @author Sébastien Miquée
*/
@Override
- public void updateMappedNode( GNode _dead, GNode _remp, String _spawnerIP )
+ public synchronized void updateMappedNode( GNode _dead, GNode _remp, String _spawnerIP )
{
if( _remp != null )
{
if( pos != -1 )
{
/** Changing the node in the mapping **/
- algos.get( idAlgo ).getMapping().getMapping().get( pos ).setGNode( _remp ) ;
-
- System.out.println( "Succesfully replacing the fallen node in the mapping." ) ;
- }
+ if( algos.get( idAlgo ).getMapping().getMapping().get( pos ).setGNode( _remp ) )
+ {
+ System.out.println( "Succesfully replacing the fallen node in the mapping." ) ;
+ } else {
+ System.err.println( "Failed in replacing the fallen node in the mapping!" ) ;
+ }
+ } else {
+ System.err.println( "The dead node was not found in the mapping!" ) ;
+ }
- /** Changing the status in the grid **/
- algos.get( idAlgo ).getGrid().setMappedStatus( _remp, true ) ;
-
- algos.get( idAlgo ).updateGrid() ;
} else {
System.err.println( "The new GNode is null!" ) ;
- }
+ }
}
*
* @author Sébastien Miquée
*/
- private void propagateReplaceNode( GNode _dead, GNode _remp, String _spawnerIP ) throws RemoteException
+ private synchronized void propagateReplaceNode( GNode _dead, GNode _remp, String _spawnerIP ) throws RemoteException
{
if( _remp != null )
{
SuperNodeListe.Instance().propagateReplaceNode( _dead, _remp, _spawnerIP ) ;
+ } else {
+ System.err.println( "The replacement node is null!" ) ;
}
}
gnodes.add( _g ) ;
+ updateGrids( _g ) ;
+
if( free )
operating = false ;
}
}
-// @Override
-// public void removeGNode( GNode _g ) throws RemoteException
-// {
-// if( _g != null )
-// {
-// boolean free = false ;
-//
-// if( ! operating )
-// {
-// workingOnGnodes() ;
-// free = true ;
-// }
-//
-// for( int i = 0 ; i < gnodes.size() ; i++ )
-// {
-// if( ((Node)gnodes.get(i).getNode()).getId() == ((Node)_g.getNode()).getId() )
-// {
-// gnodes.remove( i ) ;
-// Register.Instance().removeNodeOfName( _g.getName() ) ;
-// break ;
-// }
-// }
-//
-// if( free )
-// operating = false ;
-// }
-//
-// }
-
-
/**
* Set the local mapping with another done on an other SuperNode.
* @param _al The new mapping
* @author Sébastien Miquée
*/
@Override
- public void setMapping( Algo _al ) throws RemoteException
+ public synchronized void setMapping( Algo _al ) throws RemoteException
{
if( searchAlgo( _al.getIdS() ) == -1 )
- algos.add( _al ) ;
+ {
+ algos.add( _al ) ;
+ } else {
+ System.err.println( "I already have this mapping algorithm!" ) ;
+ }
}
*/
public void removeAlgo( String _id, int _mode ) throws RemoteException
{
- int i ;
+ int pos ;
- i = searchAlgo( _id ) ;
+ pos = searchAlgo( _id ) ;
- if( i != -1 )
+ if( pos != -1 )
{
- algos.remove( i ) ;
+ algos.remove( pos ) ;
if( _mode == 0 )
{
SuperNodeListe.Instance().removeAlgo( _id ) ;
}
+ } else {
+ System.err.println( "The mapping algorithm requested for deletion does not exist!" ) ;
}
}
+
+ // ** Tests ** //
+ public Algo getAlgo( String _spID ) throws RemoteException
+ {
+ int pos ;
+ Algo ret = null ;
+
+ pos = searchAlgo( _spID ) ;
+
+ if( pos != -1 )
+ {
+ ret = algos.get( pos ) ;
+ }
+
+ return ret ;
+ }
+
+
}
/** ! **/
import java.util.Vector;
-public class ListeTask implements java.io.Serializable, java.lang.Cloneable {
-
- private static final long serialVersionUID = 1L;
+public class ListeTask implements java.io.Serializable, java.lang.Cloneable
+{
+ private static final long serialVersionUID = 1L ;
// attributes
- protected Vector<TaskId> liste = new Vector<TaskId>();
- protected TaskId task;
+ protected Vector<TaskId> liste = new Vector<TaskId>() ;
+ protected TaskId task ;
// constructor
- public ListeTask() {
- };
+ public ListeTask() {}
@SuppressWarnings("unchecked")
public synchronized ListeTask clone() {
}
public synchronized void setStub(JaceInterface stub) {
+ ref = null ;
ref = stub;
}
public synchronized void setSuperNodeStub(JaceSuperNodeInterface stub) {
+ refSuperNode = null ;
refSuperNode = stub;
}
}
public synchronized void setSuperNodeIP(String IP) {
+ superNodeIP = null ;
superNodeIP = IP;
}
* public void setVersion(int version){ this.version=version; }
*/
- public synchronized void addNode(Node host) {
- int is = -1;
- if (host == null) {
- System.err
- .println("In Register.addNode : host.getIP() == null !");
+ public synchronized int addNode( Node host )
+ {
+ int is = -1 ;
+ if( host == null )
+ {
+ System.err.println( "In Register.addNode : host == null !" ) ;
+ return 1 ;
}
- is = existNodeOfStub(host.getStub());
+
+ is = existNodeOfStub( host.getStub() ) ;
+
if (is != -1) {
System.out.println("This node exists yet, I replace it");
- // System.out.println("MERDE !!");
- // System.out.println("MERDE !!");
- // System.out.println("MERDE !!");
- // System.out.println("MERDE !!");
- // System.out.println("MERDE !!");
- // System.out.println("MERDE !!");
- // System.out.println("MERDE !!");
+
liste.setElementAt(host, is);
} else {
liste.add(host);
}
+
+ return 0 ;
}
/**
}
public synchronized boolean removeNode(Node n) {
- return (liste.remove(n));
+ return ( liste.remove( n ) ) ;
}
- public synchronized boolean removeNodeOfName(String s) {
- boolean removed = false;
- int i = 0;
+ public synchronized boolean removeNodeOfName( String s )
+ {
+ boolean removed = false ;
+ int i = 0 ;
// System.out.println("begin remove");
// viewAll();
- while (i < liste.size() && !removed) {
+ while( i < liste.size() && ! removed )
+ {
// System.out.println("i="+i+" s="+s);
- if (((Node) liste.get(i)).getName().equals(s)) {
- liste.remove(i);
- removed = true;
- } else
- i++;
+ if( ((Node) liste.get(i)).getName().equals(s) )
+ {
+ liste.remove( i ) ;
+ removed = true ;
+ } else {
+ i++ ;
+ }
}
// System.out.println("end remove");
- return removed;
+ return removed ;
}
public synchronized int getSize() {
}
}
- @SuppressWarnings("static-access")
+// @SuppressWarnings("static-access")
public void testNeighbor() {
Node host;
//Node tmpNode;
} else {
dead = true;
//changed = true;
- host.getStub().suicide("Not responding");
+ host.getStub().suicide2("Not responding");
System.out.println("\n\nNot responding node "
+ host.getName() + " (" + host.getIP()
+ ") size : "
try {
spawnerStub.signalDeadNode(jaceStub, neighborRank);
- this.sleep(10 * beat);
+ Thread.sleep(10 * beat);
} catch (RemoteException e1) {
System.err.println("Couldn't reach the spawner: "
BufferedReader br = new BufferedReader(ipsr);
while ((adr = br.readLine()) != null) {
- liste.add(new SuperNodeData(adr, 1098));
+ liste.add(new SuperNodeData(adr, 1099));
}
br.close();
// String adr3="193.52.61.140";
// System.out.println("adr3 = " + adr3);
- // liste.add(new SuperNodeData(adr1, 1098));
- // liste.add(new SuperNodeData(adr2, 1098));
- // liste.add(new SuperNodeData(adr3, 1098));
+ // liste.add(new SuperNodeData(adr1, 1099));
+ // liste.add(new SuperNodeData(adr2, 1099));
+ // liste.add(new SuperNodeData(adr3, 1099));
}
public void fileInitialization(String fileName) {
/*********** Sébastien Miquée ***********/
/****************************************/
- public void addGNode( GNode _g )
+ public synchronized void addGNode( GNode _g )
{
if( _g != null )
{
}
}
- public void removeGNode( GNode _g, int _mode, String _spawnerIP )
+ public synchronized void removeGNode( GNode _g, int _mode, String _spawnerIP )
{
if( _g != null )
{
}
}
+ public synchronized void removeGNode( GNode _g, int _mode )
+ {
+ if( _g != null )
+ {
+
+ SuperNodeData d = null ;
+ JaceSuperNodeInterface remoteStub = null ;
+
+ for( int i = 0 ; i < liste.size() ; i++ )
+ {
+ d = (SuperNodeData) liste.elementAt( i ) ;
+ if( ! d.getIP().equals(LocalHost.Instance().getIP() ) )
+ {
+ // if not me, I inform the other super nodes
+ remoteStub = d.getStub() ;
+ try {
+ remoteStub.removeMappedGNode( _g, _mode ) ;
+ } catch( Exception e ) {
+ System.err.println( "Unable to remove GNode on SuperNode " + d.getIP() ) ;
+ }
+ }
+ }
+ }
+ }
+
+ public synchronized void setMappedGNode( GNode _g, int _mode )
+ {
+ if( _g != null )
+ {
+
+ SuperNodeData d = null ;
+ JaceSuperNodeInterface remoteStub = null ;
+
+ for( int i = 0 ; i < liste.size() ; i++ )
+ {
+ d = (SuperNodeData) liste.elementAt( i ) ;
+ if( ! d.getIP().equals(LocalHost.Instance().getIP() ) )
+ {
+ // if not me, I inform the other super nodes
+ remoteStub = d.getStub() ;
+ try {
+ remoteStub.setMapped( _g, _mode ) ;
+ } catch( Exception e ) {
+ System.err.println( "Unable to set mapped GNode on SuperNode " + d.getIP() ) ;
+ }
+ }
+ }
+ }
+ }
+
protected boolean workingOnGnodes()
{
}
}
- public void propagateReplaceNode( GNode _dead, GNode _remp, String _spawnerIP )
+ public synchronized void propagateReplaceNode( GNode _dead, GNode _remp, String _spawnerIP )
{
if( _dead != null && _remp != null )
{
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.rmi.ConnectException;
import java.rmi.RemoteException;
import java.util.Vector;
public Task sauv;
public BackupConvg sauvConvg = new BackupConvg();
public boolean postReloading = false;
- public Vector<?> reduceAll;
+ @SuppressWarnings("unchecked")
+ public Vector reduceAll;
int cpt = 0;
int count = 0;
// else
// SenderSocket.Instance().getBuffer().add(msg);
}
+
+ } catch( ConnectException ce ) {
+ recev.getHostStub().suicide2( "Not responding!" ) ;
} catch (Exception e) {
System.err.println("Unable to send data message to " + dest
+ ": " + e);
+// recev.getHostStub().suicide2( "Not responding!" ) ;
}
// System.out.println("TASK : g mis un msg qui doit etre envoye");
// envoie toujours asynchrone !!!!!!!! : le Message partira
// + ") taille MsgQueue : " + MsgQueue.Instance().getSize());
} catch (Exception e) {
if (Register.Instance().getListeOfTasks() == null)
- System.err.println("Tasks list is null: " + e);
+ System.err.println("Tasks list is null2: " + e);
}
try {
JaceSession.Instance().getTaskThread().sleep(10);
this.hostStub = s;
}
- public void setAppliName(String nom) {
+ public synchronized void setAppliName(String nom) {
this.appliName = nom;
}
// TODO a virer et laisser que le hostStub
- public void setHostIP(String nom) {
+ public synchronized void setHostIP(String nom) {
this.hostIP = nom;
}
// TODO a virer et laisser que le hostStub
- public void setHostName(String nom) {
+ public synchronized void setHostName(String nom) {
this.hostName = nom;
}
- public void setRank(int val) {
+ public synchronized void setRank(int val) {
this.rank = val;
}
- public void setHostStub(JaceInterface s) {
+ public synchronized void setHostStub(JaceInterface s) {
this.hostStub = s;
}
int requete;
int i, rank;
Task tache = null;
- Vector<?> neighbors;
+ @SuppressWarnings("unchecked")
+ Vector neighbors;
int nbOfDeamonsPerThread;
Node oldNode, node;
- public UpdateRegisterConcernedThread(Vector<?> neighbors, Register r, int i,
+ @SuppressWarnings("unchecked")
+ public UpdateRegisterConcernedThread(Vector neighbors, Register r, int i,
int rank, Node noeud, Node tmpNode) {
this.reg = r;
public void run() {
ListeTask listOfTasks = Register.Instance().getListeOfTasks().clone();
+// boolean retry = false ;
+// int nbRetry = 0 ;
+// int nbRetryMax = 2 ;
+
+ String name = "" ;
+
// listOfTasks.viewAll();
for (int index = i * nbOfDeamonsPerThread; index < i
- * nbOfDeamonsPerThread + nbOfDeamonsPerThread
- && index < neighbors.size(); index++) {
+ * nbOfDeamonsPerThread + nbOfDeamonsPerThread
+ && index < neighbors.size(); index++)
+ {
- try {
- if (((Integer) neighbors.elementAt(index)).intValue() == rank) {
- Register g = new Register();
- ListeTask newListOfTasks = new ListeTask();
- g.setAppliName(reg.getAppliName());
- g.setParams(reg.getParams());
+// retry = true ;
+// nbRetry = 0 ;
- g.setSpawnerStub(JaceSpawner.Instance()
- .getSpawnerResponsibleOn(rank));
- g.setNbOfTasks(reg.getNbOfTasks());
+// while( retry )
+// {
+ try {
+ if (((Integer) neighbors.elementAt(index)).intValue() == rank) {
+ Register g = new Register();
+ ListeTask newListOfTasks = new ListeTask();
+ g.setAppliName(reg.getAppliName());
+ g.setParams(reg.getParams());
- for (int j = 0; j < neighbors.size(); j++) {
- TaskId id = listOfTasks
- .getTaskIdOfRank(((Integer) neighbors
- .elementAt(j)).intValue());
- newListOfTasks.addTask(id);
- if (id.getHostStub() != null) {
- Node noeud = reg.getNodeOfStub(id.getHostStub());
- Node n2 = noeud;
-
- g.addNode(n2);
- }
- }
- g.setListeOfTasks(newListOfTasks);
-
- TaskId neighborTask = listOfTasks
- .getTaskIdOfRank((((Integer) neighbors
- .elementAt(index)).intValue() + 1)
- % listOfTasks.getSize());
- JaceInterface stubVoisin = neighborTask.getHostStub();
- JaceInterface stub = listOfTasks.getTaskIdOfRank(
- ((Integer) neighbors.elementAt(index)).intValue())
- .getHostStub();
- if (stub == null || stubVoisin == null) {
- System.out.println("stub NULL");
- } else {
-
- String name = listOfTasks.getTaskIdOfRank(
- ((Integer) neighbors.elementAt(index))
- .intValue()).getHostName();
+ g.setSpawnerStub(JaceSpawner.Instance()
+ .getSpawnerResponsibleOn(rank));
+ g.setNbOfTasks(reg.getNbOfTasks());
- try {
- // whatever the case, update the Register on each Node
+ for (int j = 0; j < neighbors.size(); j++) {
+ TaskId id = listOfTasks
+ .getTaskIdOfRank(((Integer) neighbors
+ .elementAt(j)).intValue()) ;
+ newListOfTasks.addTask( id ) ;
+ if( id.getHostStub() != null ) {
+ Node noeud = reg.getNodeOfStub( id.getHostStub() ) ;
+// Node n2 = noeud ;
+ if( noeud != null )
+ {
+ g.addNode( noeud ) ;
+ } else {
+ noeud = reg.getNodeOfName( id.getHostName() ) ;
+
+ if( noeud != null )
+ {
+ g.addNode( noeud ) ;
+ } else {
+ System.err.println( "UpdateRegisterConcernedThread: cannot found the corresponding node !" ) ;
+ }
+ }
+ }
+ }
+
+ g.setListeOfTasks(newListOfTasks);
- // JaceSpawnerInterface
- // ja=Register.Instance().getSpawnerStub();
- // System.out.println("avant update register");
+ TaskId neighborTask = listOfTasks
+ .getTaskIdOfRank((((Integer) neighbors
+ .elementAt(index)).intValue() + 1)
+ % listOfTasks.getSize());
+ JaceInterface stubVoisin = neighborTask.getHostStub();
+ JaceInterface stub = listOfTasks.getTaskIdOfRank(
+ ((Integer) neighbors.elementAt(index)).intValue())
+ .getHostStub();
+ if( stub == null || stubVoisin == null )
+ {
+ System.out.println("stub NULL");
+ } else {
+ name = listOfTasks.getTaskIdOfRank(
+ ((Integer) neighbors.elementAt(index))
+ .intValue()).getHostName();
- stub.updateRegister(g, stubVoisin, 0);
+ Node noeud = null ;
+
+ try {
+ // whatever the case, update the Register on each Node
- // System.out.println(" after update register");
- // if updateRegister worked, that means Node is
- // Alive
- Node noeud = Register.Instance()
- .getNodeOfStub(stub);
- if (noeud != null) {
- noeud.setAliveFlag(true);
- noeud.setAliveTime();
+ // JaceSpawnerInterface
+ // ja=Register.Instance().getSpawnerStub();
+ // System.out.println("avant update register");
- }
- } catch (Exception e) {
- System.err
- .println(name
- + " ("
- + LocalHost.Instance()
- .resolve(name)
- + " rank="
- + index
- + ") cannot be reached by UpdateRegisterConcernedThread for new node "
- + " size : "
- + Register.Instance().getSize()
- + " :" + e);
+ stub.updateRegister( g, stubVoisin, 0 ) ;
- }
- }
- } else {
- //int tag;
- TaskId id = listOfTasks
- .getTaskIdOfRank(((Integer) neighbors
- .elementAt(index)).intValue());
- String name = id.getHostName();
+ // System.out.println(" after update register");
+ // if updateRegister worked, that means Node is
+ // Alive
+ noeud = Register.Instance()
+ .getNodeOfStub(stub);
+ if (noeud != null) {
+ noeud.setAliveFlag(true);
+ noeud.setAliveTime();
- try {
-
- JaceInterface stub = id.getHostStub();
- stub.updateRegister(oldNode, node);
- } catch (Exception e) {
- System.err
+ }
+// retry = false ;
+ } catch( Exception e ) {
+ System.err
.println(name
+ " ("
- + LocalHost.Instance().resolve(name)
+ + LocalHost.Instance()
+ .resolve(name)
+ " rank="
+ index
- + ") cannot be reached by UpdateRegisterConcernedThread "
+ + ") cannot be reached by UpdateRegisterConcernedThread for new node "
+ " size : "
- + Register.Instance().getSize() + " :"
- + e);
+ + Register.Instance().getSize()
+ + " :" + e);
+// try{
+// Thread.sleep( (nbRetry + 1) * 2000 ) ;
+// }catch(Exception sl){}
+// nbRetry++ ;
+
+// if( nbRetry > nbRetryMax )
+// {
+// retry = false ;
+// System.err.println( "Cannot retry anymore!" ) ;
+// if( noeud != null )
+// {
+// try {
+// JaceSpawner.Instance().signalDeadNode( noeud.getStub(), index ) ;
+// } catch( Exception ex ) {
+// JaceSpawner.Instance().signalDeadNode( null, index ) ;
+// }
+// } else {
+// JaceSpawner.Instance().signalDeadNode( null, index ) ;
+// }
+// }
+ }
+ }
+ } else {
+ //int tag;
+ TaskId id = listOfTasks
+ .getTaskIdOfRank(((Integer) neighbors
+ .elementAt(index)).intValue());
+ name = id.getHostName();
+
+ try {
+
+ JaceInterface stub = id.getHostStub() ;
+ stub.updateRegister( oldNode, node, rank ) ;
+// retry = false ;
+ } catch (Exception e) {
+ System.err
+ .println(name
+ + " ("
+ + LocalHost.Instance().resolve(name)
+ + " rank="
+ + index
+ + ") cannot be reached by UpdateRegisterConcernedThread size : "
+ + Register.Instance().getSize() + " :"
+ + e);
+
+// try{
+// Thread.sleep( (nbRetry + 1) * 2000 ) ;
+// }catch(Exception sl){}
+// nbRetry++ ;
+
+// if( nbRetry > nbRetryMax )
+// {
+// retry = false ;
+// System.err.println( "Cannot retry anymore!" ) ;
+// }
+ }
}
+ } catch( Exception e2 ) {
+ System.err.println("Error in updateRegisterConcernedThread :"
+ + e2);
}
- } catch (Exception e2) {
- System.err.println("Error in updateRegisterConcernedThread :"
- + e2);
- }
+// }
+
+// if( nbRetry > nbRetryMax )
+// {
+//
+// }
}
// System.out.println("at the end of an updateRegisterCon. j="+i);
// Register.Instance().getListeOfTasks().viewAll();
// System.out.println("avant update register");
// 1 l'appli vient de commencer
- stub.updateRegister(g, stubVoisin, requete);
+ int ret = 1 ;
+ int loop = 0 ;
+ int LOOP_MAX = 3 ;
+
+ while( ret == 1 && loop < LOOP_MAX )
+ {
+ ret = stub.updateRegister(g, stubVoisin, requete);
+ loop++ ;
+ }
+
+ if( loop == LOOP_MAX )
+ {
+ System.err.println( "Problem during register update!" ) ;
+ } else {
// System.out.println("Envoi du registre a :"+index);
// g.viewAll();
// System.out.println("ancien registre");
// Register.Instance().viewAll();
// System.out.println(" after update register");
// if updateRegister worked, that means Node is Alive
- Node noeud = Register.Instance().getNodeOfStub(stub);
- if (noeud != null) {
- noeud.setAliveFlag(true);
- noeud.setAliveTime();
-
+ Node noeud = Register.Instance().getNodeOfStub(stub);
+ if (noeud != null) {
+ noeud.setAliveFlag(true);
+ noeud.setAliveTime();
+ }
}
} catch (Exception e) {
System.err.println(name + " ("