Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fixing some bugs.
[jaceP2P.git] / src / jaceP2P / JaceSpawner.java
index e2f68d5..66be55a 100644 (file)
@@ -181,8 +181,10 @@ public class JaceSpawner {
 
        public void startProcess(Vector<Object> spawnersList) {
                this.spawnersList = spawnersList;
+
                int is = spawnersList.indexOf((Object) Register.Instance()
                                .getSpawnerStub());
+
                if (is != -1) {
                        int nextNeighbour;
                        if (is == spawnersList.size() - 1)
@@ -584,7 +586,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);
                                }
                        }
@@ -947,10 +949,10 @@ public class JaceSpawner {
 
                spawnersList = new Vector<Object>();
                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);
@@ -1020,7 +1022,7 @@ public class JaceSpawner {
                                                                                        + ez);
                                                }
                                        }
-                                       System.exit(0);
+                                       System.exit(1);
                                }
                        }
                }
@@ -1041,10 +1043,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,9 +1071,11 @@ 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");
@@ -1083,9 +1085,10 @@ public class JaceSpawner {
                                        Thread.sleep(20);
                                } catch (Exception e) {
                                }
-                       System.out
-                                       .println("End Transformation of all spawners. Beginning the computing processes");
                }
+
+               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 +1115,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 +1280,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)