X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/jaceP2P.git/blobdiff_plain/0f24648ed27a5e3bd060e04afac15b2821dd693a..b5a7cb08ee803935699d211fd2abb0afddcbc98a:/src/jaceP2P/JaceSpawner.java?ds=sidebyside diff --git a/src/jaceP2P/JaceSpawner.java b/src/jaceP2P/JaceSpawner.java index e2f68d5..85014e0 100644 --- a/src/jaceP2P/JaceSpawner.java +++ b/src/jaceP2P/JaceSpawner.java @@ -1,6 +1,7 @@ package jaceP2P; import java.rmi.Naming; +import java.rmi.RemoteException; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Vector; @@ -38,6 +39,7 @@ public class JaceSpawner { // Variables for Mapping private int algo; private double paramAlgo ; + private String idAlgo ; public JaceSpawner(String superNode, int port, String comProtocol, String[] args, int nbDaemonPerSpawner, int nbDaemonPerThread, @@ -181,8 +183,10 @@ public class JaceSpawner { public void startProcess(Vector spawnersList) { this.spawnersList = spawnersList; + int is = spawnersList.indexOf((Object) Register.Instance() .getSpawnerStub()); + if (is != -1) { int nextNeighbour; if (is == spawnersList.size() - 1) @@ -260,7 +264,7 @@ public class JaceSpawner { } // /System.out.println("is running = false"); if (!JaceDaemon.Instance().isRunning()) - System.exit(0); + System.exit( 1 ) ; } public synchronized void signalDeadNode(JaceInterface host, int rankOfDead) { @@ -404,6 +408,9 @@ public class JaceSpawner { if( node != null ) { found = true ; + } else { + Thread.sleep( 1000 ) ; + System.out.println("Pas de bon retour !"); } } catch (Exception e) { // trouver un autre superNode et lui demander le noeud a lui @@ -584,7 +591,7 @@ public class JaceSpawner { .updateHeart(spawnerStub); } catch (Exception e) { System.err - .println("unable to change the server of the heartbeatThread for the previous node of rank " + .println("Unable to change the server of the heartbeatThread for the previous node of rank " + previous + ". error:" + e); } } @@ -636,6 +643,7 @@ public class JaceSpawner { ListeTask t = Register.Instance().getListeOfTasks(); ScanThreadSpawner.Instance().kill(); HeartBeatSpawner.Instance().kill(); + for (int i = 0; i < s + 1; i++) { new KillThread(i, debut, nbOfDaemonsPerSpawner, @@ -652,6 +660,7 @@ public class JaceSpawner { int nbsdc = RunningApplication.Instance() .getNumberOfSpawnerDisconnections(); + System.out.println("Application finished successfully !"); // System.out.println("Application finished successfully !!!!!!"); // System.out.println("Application finished successfully !!!!!!"); @@ -674,10 +683,12 @@ public class JaceSpawner { RunningApplication.Instance().purge(); // System.exit(1); } + + /** Suprresion of the mapping algorithm on the SuperNode **/ + centralServer.removeAlgo( idAlgo, 0 ) ; } - } catch (Exception e) { - System.out - .println("w aiiiiiiiiiiiiiirrrr" + e + " index=" + index); + } catch( Exception e ) { + System.err.println( "Error the application nodes scan!\n " + e ) ; z = index; } /* @@ -826,7 +837,7 @@ public class JaceSpawner { .println("JaceP2P_Error in JaceSpawner.exportObject() when creating the local JaceSpawnerServer " + e); // System.err.println("exit ds JaceSpawner.exportObject"); - System.exit(0); + System.exit( 1 ) ; } } @@ -933,6 +944,9 @@ public class JaceSpawner { connectSuperNode(); } } + + idAlgo = LocalHost.Instance().getIP() ; + 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++) { @@ -942,15 +956,15 @@ public class JaceSpawner { System.err.println("The reserved node was unable to reconnect to the super node"); } } - System.exit(0); + System.exit( 1 ) ; } spawnersList = new Vector(); for (int i = 0; i < nbExtraSpawners && i < registerSpawner.getSize(); i++) { - spawnersList.add(registerSpawner.getNodeAt(i - * nbOfDaemonsPerSpawner)); - registerSpawner.removeNode(registerSpawner.getNodeAt(i - * nbOfDaemonsPerSpawner)); + spawnersList.add(registerSpawner.getNodeAt(0)); +// * nbOfDaemonsPerSpawner)); + registerSpawner.removeNodeOfName(registerSpawner.getNodeAt(0).getName()); +// * nbOfDaemonsPerSpawner)); } registerSpawner.setNbOfTasks(nbTasks); @@ -983,6 +997,18 @@ public class JaceSpawner { System.exit(0); } } + + + /** + * 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 + { + idAlgo = _s ; + } public class TransformThread extends Thread { int i; @@ -1020,7 +1046,7 @@ public class JaceSpawner { + ez); } } - System.exit(0); + System.exit(1); } } } @@ -1041,10 +1067,8 @@ public class JaceSpawner { * System.out.println("waiting till transform of spawner "+i+ * " is finished"); Thread.sleep(20); }catch(Exception e1){} */ - // System.out.println("start process on spawner of rank "+i); - JaceSpawnerInterface spawnerStub = (JaceSpawnerInterface) spawnersList - .elementAt(i); + JaceSpawnerInterface spawnerStub = (JaceSpawnerInterface) spawnersList.get(i); spawnerStub.startProcess(spawnersList); } catch (Exception e) { e.printStackTrace(System.out); @@ -1071,21 +1095,34 @@ public class JaceSpawner { // in order to start each task on the Daemons spawnersList.add(Register.Instance().getSpawnerStub()); - System.out.println(" rank=spawnersList.size()=" + spawnersList.size()); + System.out.println(" rank="+rank+" spawnersList.size()=" + spawnersList.size()); rank = spawnersList.size() - 1; + broadcastRegister(1); + for (int j = 0; j < spawnersList.size(); j++) { System.out.println("waiting till transform of spawner " + j + " is finished"); while ((spawnersList.elementAt(j) instanceof Node)) + { try { Thread.sleep(20); } catch (Exception e) { } - System.out - .println("End Transformation of all spawners. Beginning the computing processes"); + } + + try { + ((JaceSpawnerInterface)spawnersList.elementAt( i )).setIdAlgo( idAlgo ) ; + } catch (RemoteException e) { + System.err.println( "Unable to set Mapping Algorithm identifier" ) ; + e.printStackTrace(); + } + } + + System.out.println("End Transformation of all spawners. Beginning the computing processes"); + for (i = 0; i < spawnersList.size(); i++) { // while(!(spawnersList.elementAt(i) instanceof @@ -1112,7 +1149,7 @@ public class JaceSpawner { JaceInterface nodeStub = null; TaskId myTask = null; - System.out.println("appli launched, starting the chrono"); + System.out.println("Application launched, starting the chronometer"); RunningApplication.Instance().getChrono().start(); RunningApplication.Instance().setName(appliName); @@ -1277,8 +1314,8 @@ public class JaceSpawner { while (broadcasting == true) Thread.sleep(5); broadcasting = true; - Register.Instance().setSpawnerStub( - Register.Instance().getSpawnerStub()); +// Register.Instance().setSpawnerStub( +// Register.Instance().getSpawnerStub()); int x = reg.getListeOfTasks().getSize() / nbOfDaemonsPerSpawner; int s; if (rank == x)