iter = requestToDisconnectNodeDiagnosisIndex.values().iterator(); while (iter.hasNext()) { RequestToDisconnectNodeDiagnosis d = (RequestToDisconnectNodeDiagnosis)iter.next(); if (logger.isDebugEnabled()) logger.debug("Restoring: " + d.dump()); blackboard.publishChange(d);
}   if (somethingRequestedExpired) { iter = expiredRequestedAlarms.iterator(); while(iter.hasNext()) { RequestedAlarm thisAlarm = (RequestedAlarm)iter.next(); if (thisAlarm.hasExpired()) { thisAlarm.handleExpiration(); }
    public void execute() {            if (logger.isDebugEnabled()) logger.debug("Entering ** execute() **");        if (logger.isDebugEnabled()) logger.debug("RTC's: " + reconnectTimeConditionSubscription.toString());        if (logger.isDebugEnabled()) logger.debug("Added RTC's: " + reconnectTimeConditionSubscription.getAddedCollection().toString());        if (logger.isDebugEnabled()) logger.debug("Changed RTC's: " + reconnectTimeConditionSubscription.getChangedCollection().toString());        if (logger.isDebugEnabled()) logger.debug("OpModes's: " + blackboard.query(DisconnectDefenseAgentEnabler.pred).toString());               Iterator iter;        // if restoring, publish all the existing Diagnosis & Action objects        if (restoring) {            iter = requestToDisconnectAgentDiagnosisIndex.values().iterator();            while (iter.hasNext()) {                RequestToDisconnectAgentDiagnosis d = (RequestToDisconnectAgentDiagnosis)iter.next();                if (logger.isDebugEnabled()) logger.debug("Restoring: " + d.dump());                blackboard.publishChange(d);            }            iter = requestToDisconnectNodeDiagnosisIndex.values().iterator();            while (iter.hasNext()) {                RequestToDisconnectNodeDiagnosis d = (RequestToDisconnectNodeDiagnosis)iter.next();                if (logger.isDebugEnabled()) logger.debug("Restoring: " + d.dump());                blackboard.publishChange(d);            }             iter = disconnectActionIndex.values().iterator();            while (iter.hasNext()) {                DisconnectAction a = (DisconnectAction)iter.next();                if (logger.isDebugEnabled()) logger.debug("Restoring: " + a.dump());                blackboard.publishChange(a);            }            restoring = false;        }                          // Handle expired Alarms for overdue nodes        if (somethingExpired) {            iter = expiredAlarms.iterator();            while(iter.hasNext()) {                OverdueAlarm thisAlarm = (OverdueAlarm)iter.next();                if (thisAlarm.hasExpired()) {                    thisAlarm.handleExpiration();                }            }        expiredAlarms.clear();        somethingExpired = false;        }                if (managerAddress != null) {// already know the ManagerAgent, so create Diagnoes & Actions for newly announced Nodes & Agents            if (logger.isDebugEnabled()) logger.debug("Know MA, so create Diagnosis & Action for newly announce Nodes & Agents");            iter = reconnectTimeConditionSubscription.getAddedCollection().iterator();            while (iter.hasNext()) {                ReconnectTimeCondition rtc = (ReconnectTimeCondition)iter.next();                createDiagnosisAndAction(new AssetID(rtc.getAsset(), AssetType.findAssetType(rtc.getAssetType())));            }        }                Iterator i = managerAddressSubscription.getAddedCollection().iterator();        if (i.hasNext()) { // just found the ManagerAgentAddress            managerAddress = ((RobustnessManagerID)i.next()).getMessageAddress();            if (logger.isDebugEnabled()) logger.debug("ManagerAddress: "+managerAddress.toString());            // so create conditions & opmodes for everything we've seen so far but not created            iter = reconnectTimeConditionSubscription.iterator();            while (iter.hasNext()) {                ReconnectTimeCondition rtc = (ReconnectTimeCondition)iter.next();                createDiagnosisAndAction(new AssetID(rtc.getAsset(), AssetType.findAssetType(rtc.getAssetType())));            }                    }                iter = reconnectTimeConditionSubscription.getChangedCollection().iterator();        while (iter.hasNext()) {            ReconnectTimeCondition rtc = (ReconnectTimeCondition)iter.next();            if (rtc != null) {                double encodedTime = ((Double)rtc.getValue()).doubleValue();                if (logger.isDebugEnabled()) logger.debug("Changed "+rtc.toString());                if (encodedTime >= 0.0) { // it's a request to do something                    handleNodeRequest(rtc);                }                else { // it's an acknowledgement that the Action happened                    handleNodeAcknowledgment(rtc);                }            }        }        iter = ActionSubscription.getChangedCollection().iterator();        while (iter.hasNext()) {            DisconnectAction action = (DisconnectAction)iter.next();            if (logger.isDebugEnabled()) logger.debug("Saw Changed: " + action.dump());            Set newPV = action.getNewPermittedValues();            if (newPV != null) {                if (logger.isDebugEnabled()) logger.debug("NPV: " + newPV.toString());                if (logger.isDebugEnabled()) logger.debug("Permitted change to: " + action.dump());                try {                    action.setPermittedValues(newPV);                    action.clearNewPermittedValues();                    RequestRecord rr = (RequestRecord)pendingRequests.get(action);                        if (rr != null) { // processing a request                            if (logger.isDebugEnabled()) logger.debug("Requested Action is: " + rr.getRequest().toString());                            if (action.getPermittedValues().contains(rr.getRequest())) {                                boolean deleted = rr.getRemainingActions().remove(action);                                if (logger.isDebugEnabled()) logger.debug("Removal of Action: " + action.dump() + " is " + deleted);                                pendingRequests.remove(action);                                if (rr.getRemainingActions().isEmpty()) {                                       propagateChange(rr, true);                                }                            }                            else {                                if (logger.isInfoEnabled()) logger.info("Permission NOT granted for: " + action.dump());                               // Iterator iter2 = (rr.getOriginalActions()).removeAll(rr.getRemainingActions()).iterator();                               // while (iter2.hasNext()) {                                //    DisconnectAction thisAction = (DisconnectAction)iter.next();                                //    thisAction.setPermittedValues(new HashSet());                                //    blackboard.publishChange(thisAction);                                //    pendingRequests.remove(thisAction);                               // }                                propagateChange(rr, false);                            }                            if (logger.isDebugEnabled()) logger.debug("RequestRecord after getting permission for: " + action.dump() + " is " + rr.dump());                        }                    } catch (IllegalValueException e)  {                    logger.error("Attempt to set: "+action.dump()+" with illegal value "+e.toString());                    return;                    }             }             else { // do not want to do anything            }        }    }