3 import java.util.Vector;
5 class UpdateRegisterConcernedThread extends Thread {
11 int nbOfDeamonsPerThread;
14 public UpdateRegisterConcernedThread(Vector<?> neighbors, Register r, int i,
15 int rank, Node noeud, Node tmpNode) {
21 this.neighbors = neighbors;
24 nbOfDeamonsPerThread = JaceSpawner.Instance().getNbOfDeamonsPerThread();
28 ListeTask listOfTasks = Register.Instance().getListeOfTasks().clone();
29 // listOfTasks.viewAll();
30 for (int index = i * nbOfDeamonsPerThread; index < i
31 * nbOfDeamonsPerThread + nbOfDeamonsPerThread
32 && index < neighbors.size(); index++) {
35 if (((Integer) neighbors.elementAt(index)).intValue() == rank) {
36 Register g = new Register();
37 ListeTask newListOfTasks = new ListeTask();
38 g.setAppliName(reg.getAppliName());
39 g.setParams(reg.getParams());
41 g.setSpawnerStub(JaceSpawner.Instance()
42 .getSpawnerResponsibleOn(rank));
43 g.setNbOfTasks(reg.getNbOfTasks());
45 for (int j = 0; j < neighbors.size(); j++) {
46 TaskId id = listOfTasks
47 .getTaskIdOfRank(((Integer) neighbors
48 .elementAt(j)).intValue());
49 newListOfTasks.addTask(id);
50 if (id.getHostStub() != null) {
51 Node noeud = reg.getNodeOfStub(id.getHostStub());
57 g.setListeOfTasks(newListOfTasks);
59 TaskId neighborTask = listOfTasks
60 .getTaskIdOfRank((((Integer) neighbors
61 .elementAt(index)).intValue() + 1)
62 % listOfTasks.getSize());
63 JaceInterface stubVoisin = neighborTask.getHostStub();
64 JaceInterface stub = listOfTasks.getTaskIdOfRank(
65 ((Integer) neighbors.elementAt(index)).intValue())
67 if (stub == null || stubVoisin == null) {
68 System.out.println("stub NULL");
71 String name = listOfTasks.getTaskIdOfRank(
72 ((Integer) neighbors.elementAt(index))
73 .intValue()).getHostName();
76 // whatever the case, uate the Register on each Node
78 // JaceSpawnerInterface
79 // ja=Register.Instance().getSpawnerStub();
80 // System.out.println("avant update register");
82 // 0 l'applejaacoja commence
83 stub.updateRegister(g, stubVoisin, 0);
85 // System.out.println(" after update register");
86 // if updateRegister worked, that means Node is
88 Node noeud = Register.Instance()
91 noeud.setAliveFlag(true);
95 } catch (Exception e) {
99 + LocalHost.Instance()
103 + ") cannot be reached by UpdateRegisterConcernedThread for new node "
105 + Register.Instance().getSize()
112 TaskId id = listOfTasks
113 .getTaskIdOfRank(((Integer) neighbors
114 .elementAt(index)).intValue());
115 String name = id.getHostName();
119 JaceInterface stub = id.getHostStub();
120 stub.updateRegister(oldNode, node);
121 } catch (Exception e) {
125 + LocalHost.Instance().resolve(name)
128 + ") cannot be reached by UpdateRegisterConcernedThread "
130 + Register.Instance().getSize() + " :"
134 } catch (Exception e2) {
135 System.out.println("error in updateRegisterConcernedThread :"
139 // System.out.println("at the end of an updateRegisterCon. j="+i);
140 // Register.Instance().getListeOfTasks().viewAll();
143 @SuppressWarnings("unused")
144 private Vector<Integer> getDependencies(int id, int jaceSize) {
145 // get computing dependencies
146 Vector<Integer> neighbors = new Vector<Integer>();
147 int[] dep = tache.getDependencies(id);
148 for (int z = 0; z < taille(dep); z++)
149 neighbors.add(dep[z]);
150 // System.out.println("la liste des voisins de calcul de: "+id);
151 // for(int z=0;z<neighbors.size();z++)
152 // System.out.print(((Integer)neighbors.elementAt(z)).intValue()+" ");
153 // System.out.println();
154 // get convergence neighbors
156 while (Math.pow(2, d) < jaceSize) {
157 if (id < Math.pow(2, d) && ((id + Math.pow(2, d)) < jaceSize))
158 if (!neighbors.contains((Object) ((int) (id + Math.pow(2, d)))))
159 neighbors.add((int) (id + Math.pow(2, d)));
160 if (id < Math.pow(2, d + 1) && id >= Math.pow(2, d))
161 if (!neighbors.contains((Object) ((int) (id - Math.pow(2, d)))))
162 neighbors.add((int) (id - Math.pow(2, d)));
166 // get backup neighbors
167 int nb = reg.getNumBackupNeighbors();
170 for (int j = 1; j <= nb; j++) {
171 // ------------ 1 - for backups "j + n" (to the right of j)
172 rankOfBackTask = (id + j) % jaceSize;
173 if (!neighbors.contains((Object) rankOfBackTask))
174 neighbors.add(rankOfBackTask);
176 // ------------ 2 - for backups "j - n" (to the left of j)
179 rankOfBackTask = tmp % jaceSize;
181 rankOfBackTask = jaceSize - (Math.abs(tmp) % jaceSize);
183 if (!neighbors.contains((Object) rankOfBackTask))
184 neighbors.add(rankOfBackTask);
192 public static int taille(int[] vect) {
195 while (x < vect.length && vect[x] >= 0) {