MessageHistory.AgentEntry ae = aeA[i];
MessageHistory.AgentEntry ae = (MessageHistory.AgentEntry)aeA[i];
    public synchronized void execute() {	if (community == null) return;        // handle new agents	int tsLookupCnt = 0;	Iterator iter = newAgentQueue.iterator();	while (iter.hasNext()) {	    AgentDiagnoses ad = (AgentDiagnoses)iter.next();	    Diagnosis rmiDiag, sfDiag, altDiag, allDiag;	    String agentName = ad.agentName;	    try {		rmiDiag = new RMILinksStatusDiagnosis(agentName,sb);		sfDiag  = new StoreAndForwardLinksStatusDiagnosis(agentName,sb);		altDiag = new AlternateDirectLinksStatusDiagnosis(agentName,sb);		allDiag = new AllLinksStatusDiagnosis(agentName,sb);	    } catch  (TechSpecNotFoundException e) {		if (tsLookupCnt > 10) {		    log.warn("TechSpec not found for LinksStatusDiagnosis.  Will retry.", e);		    tsLookupCnt = 0;		}		bb.signalClientActivity();		break;	    }	    ad.rmiDiag = rmiDiag;	    ad.sfDiag  = sfDiag;	    ad.altDiag = altDiag;	    ad.allDiag = allDiag;	    bb.publishAdd(rmiDiag);	    bb.publishAdd(sfDiag);	    bb.publishAdd(altDiag);	    bb.publishAdd(allDiag);	    iter.remove();	     	    if (statsAlarm == null) {		statsAlarm = new ProcessStatsAlarm(period);		alarmService.addRealTimeAlarm(statsAlarm);	    }	}	//process stats	if (statsAlarm != null && statsAlarm.hasExpired()) {	    Vector q;	    long notTooOld = System.currentTimeMillis()-period-latency;	    synchronized (statsQueue) {		q = statsQueue;		statsQueue = new Vector();	    }	    if (log.isDebugEnabled()) 		log.debug("execute: old statsQueue="+q);	    if (log.isDebugEnabled()) 		log.debug("execute: new statsQueue="+statsQueue);            // create a vector of MessageHistory.AgentEntries extracted             // from all the stats vectors in the statsQueue	    Vector aeV = new Vector(); 	    iter = q.iterator();	    while (iter.hasNext()) {		Vector stats = (Vector)iter.next(); 		if (stats != null) {		    Hashtable aeht = (Hashtable)stats.elementAt(1);		    if (aeht != null) {			Enumeration enum = aeht.elements();			while (enum.hasMoreElements()) {			    MessageHistory.AgentEntry ae = 				(MessageHistory.AgentEntry)enum.nextElement();			    if (ae.timestamp >= notTooOld) {				aeV.add(ae);			    }			}		    }		}	    }	    MessageHistory.AgentEntry[] aeA = 		(MessageHistory.AgentEntry[])aeV.toArray();	    Arrays.sort(aeA,comparator);	    String agent = null;	    int rmiSends=0; 	    int sfSends=0; 	    int altSends=0; 	    int allSends=0;	    int rmiSuccesses=0;            int sfSuccesses=0;            int altSuccesses=0;            int allSuccesses=0;	    AgentDiagnoses diags = null;	    for (int i=0 ; i<aeA.length ; i++) {		MessageHistory.AgentEntry ae = aeA[i];		if (ae.agent != agent) { // next agent		    //update last one		    if (diags != null) {			updateDiag(diags.rmiDiag, rmiSends, rmiSuccesses);			updateDiag(diags.sfDiag, sfSends, sfSuccesses);			updateDiag(diags.altDiag, altSends, altSuccesses);			updateDiag(diags.allDiag, allSends, allSuccesses);		    }		    agent = ae.agent;		    diags = (AgentDiagnoses)agents.get(agent);		    rmiSends=0; sfSends=0; altSends=0; allSends=0;		    rmiSuccesses=0; sfSuccesses=0; altSuccesses=0; allSuccesses=0;		}		Enumeration enum = ae.protocolTbl.elements();		while (enum.hasMoreElements()) {		    MessageHistory.ProtocolEntry pe = 			(MessageHistory.ProtocolEntry)enum.nextElement();		    char prot = pe.linkLetter;		    allSends = allSends + pe.successes;		    allSuccesses = allSuccesses + pe.successes;		    switch (prot)			{			case 'R': // RMI 			case 'S': // SSLRMI			    rmiSends = rmiSends + pe.successes;			    rmiSuccesses = rmiSuccesses + pe.successes;			    break;			case 'E': // Email                         case 'N': // NNTP			    sfSends = sfSends + pe.successes;			    sfSuccesses = sfSuccesses + pe.successes;			    break;			case 'T': // TCP                        case 'U': // UDP			    altSends = altSends + pe.successes;			    altSuccesses = altSuccesses + pe.successes;			    break;			default:			    if (log.isWarnEnabled()) 				log.warn("execute: stats for unexpected protocol seen, linkLetters="+prot);			}		}	    }