public int[] getDataMessageRoute(int dest) { boolean find = false; int[] route = null; int repr = group(dest); if (repr == MWACNetworkPartialKnowledgeManager.UNDEFINED_ID) return null; System.out.println(repr + " est le représentant du message a envoyer"); ListIterator<int[]> iter = this.routes.listIterator(); while (!find && iter.hasNext()) { route = iter.next(); find = MWACRouteAssistant.contains(route, repr); } if (find) { System.out.println("!J'ai trouvé une route " + MWACRouteAssistant.routeToString(route)); find = false; int i = 0; // System.out.println("Je vais rentré dans la boucle"); while (!find && i < route.length) find = (route[i++] == repr); // System.out.println("Je sors de la boucle"); route = MWACRouteAssistant.subRoute(route, i); // System.out.println("Je fais la nouvelle route"); // System.out.println("La route est devenue "+MWACRouteAssistant.routeToString(route)); System.out.flush(); return route; } else { System.out.println("Je N'ai PAS trouvé une route"); return null; } }
public String toHTML() { String res = ""; res = "<B>Group association</B> (" + this.idGroupAssociation.size() + ")<BR>"; res += "<TABLE border=1>"; res += "<TR><TD>Group</TD><TD>Members</TD></TR>"; for (int i = 0; i < this.idGroupAssociation.size(); i++) res += this.idGroupAssociation.get(i).toHTML(); res += "</TABLE>"; res += "<BR>"; res += "<B>Route fragment</B> (" + this.routes.size() + ")<BR>"; res += "<TABLE border=1>"; for (int i = 0; i < this.routes.size(); i++) res += "<TR><TD>" + MWACRouteAssistant.routeToString(this.routes.get(i)) + "</TD></TR>"; res += "</TABLE>"; res += "<BR>"; res += "<B>Association(Route request/sender)</B> (" + this.routes.size() + ")<BR>"; res += "<TABLE border=1>"; res += "<TR><TD>Route request</TD><TD>Sender</TD></TR>"; for (int i = 0; i < this.routeRequestAndReceiverAssociation.size(); i++) res += this.routeRequestAndReceiverAssociation.get(i).toHTML(); res += "</TABLE>"; return res; }
/** * returns the list of identifiers of neighbors groups which let's think that there is an * organizational incoherence * * @param group group of the agent which is the owner of this neighboor list * @returns a list of suspicious groups */ public Vector<Integer> suspiciousNeighboorsGroups(int[] ownerGroupIdentifier) { // String TEMPTEMPTEMPTEMP=""; Vector<Integer> lst = new Vector<Integer>(); Vector<Integer> ok = new Vector<Integer>(); TrustedTripletIdRoleGroup triplet; ListIterator<TrustedTripletIdRoleGroup> iter; int i = 0; ; int t[]; // construct the list of identifier of neighboor group iter = neighboorList.listIterator(); while (iter.hasNext()) { triplet = iter.next(); t = triplet.groups; for (i = 0; i < t.length; i++) if (!MWACRouteAssistant.contains(ownerGroupIdentifier, t[i]) && (!lst.contains(t[i]))) lst.add(t[i]); } // TEMPTEMPTEMPTEMP="EXISTING GROUPS: "; // for(i=0;i<lst.size();i++) TEMPTEMPTEMPTEMP+=(lst.get(i)+" "); // TEMPTEMPTEMPTEMP+="\nTRIPLETS:\n"; // remove identifier of well known group // * group identifier which are contained by a link agent which allow to contact the owner group // * group identifier of a neighboor representative agent LinkedList<TrustedTripletIdRoleGroup> copyNeighboorList = (LinkedList<TrustedTripletIdRoleGroup>) this.neighboorList.clone(); iter = copyNeighboorList.listIterator(); while (iter.hasNext()) { triplet = iter.next(); if (triplet.role == TrustedMWACAgent.roleREPRESENTATIVE) { lst.removeElement(triplet.id); iter.remove(); } else if (triplet.role == TrustedMWACAgent.roleLINK) { t = triplet.groups; i = 0; while (i < t.length && (!MWACRouteAssistant.contains(ownerGroupIdentifier, t[i]))) i++; if (i < t.length) { for (i = 0; i < t.length; i++) { lst.removeElement(t[i]); if (!ok.contains(t[i]) && (!MWACRouteAssistant.contains(ownerGroupIdentifier, t[i]))) ok.add(t[i]); } // TEMPTEMPTEMPTEMP+="(1)"+triplet+"\n"; iter.remove(); } } } // remove identifier of well known group by an other agent if (!ok.isEmpty()) { iter = copyNeighboorList.listIterator(); while (iter.hasNext()) { triplet = iter.next(); if (triplet.role == TrustedMWACAgent.roleLINK) { t = triplet.groups; i = 0; while (i < t.length && (!ok.contains(t[i]))) i++; if (i < t.length) { for (i = 0; i < t.length; i++) { lst.removeElement(t[i]); } // TEMPTEMPTEMPTEMP+="(2)"+triplet+"\n"; iter.remove(); } // else // TEMPTEMPTEMPTEMP+="(-)"+triplet+"\n"; } } } // if (lst.size()>0) // { // TEMPTEMPTEMPTEMP+="\n\nRESULTAT DES SUSPECTS="; // for(i=0;i<lst.size();i++) TEMPTEMPTEMPTEMP+=(lst.get(i)+" "); // System.out.println(TEMPTEMPTEMPTEMP); // } return lst; }