if (logger.isDebugEnabled()) logger.debug("starting to process a changed LocalReconnectTimeCondition"); if (iter.hasNext()) { LocalReconnectTimeCondition lrtc = (LocalReconnectTimeCondition)iter.next(); if (logger.isDebugEnabled()) logger.debug("Found lrtc "+lrtc.getAsset()); if (lrtc != null) { reconnectInterval = (long) Double.parseDouble(lrtc.getValue().toString()) / 1000L;
if (iter.hasNext()) { if (getNodeAddress().equals(managerAddress)) { if (eventService.isEventEnabled()) { eventService.event("Not allowed to Disconnect ManagementAgent on "+getNodeAddress().toString()); }
  public void execute() {      Iterator iter;            // if already know the ManagerAgent Address, then process newly announced Agents as they arrive            if (managerAddress != null) {          //********** Check for new agents on the node **********          // create conditions for all the agents that report now          Iterator iter2 = localAgentsSubscription.getAddedCollection().iterator();          while (iter2.hasNext()) {             AgentExistsCondition aec = (AgentExistsCondition) iter2.next();             createConditionsAndOpModes("Agent", aec.getAsset(), getNodeAddress(), managerAddress);          }      }      iter = managerAddressSubscription.getAddedCollection().iterator();      if (iter.hasNext()) {          // find & set the ManagerAgent address           managerAddress = ((RobustnessManagerID)iter.next()).getMessageAddress();           if (logger.isDebugEnabled()) logger.debug("ManagerAddress: "+managerAddress.toString());          // create conditions & opmodes for the NodeAgent          createLocalCondition("Node", getNodeID(), getNodeAddress(), managerAddress);          createConditionsAndOpModes("Node", getNodeID(), getNodeAddress(), managerAddress);               //********** Check for new agents on the node **********          // create conditions for all the agents that reported BEFORE we found the ManagerAgent Address          Iterator iter2 = localAgentsSubscription.iterator();          while (iter2.hasNext()) {             AgentExistsCondition aec = (AgentExistsCondition) iter2.next();             createConditionsAndOpModes("Agent", aec.getAsset(), getNodeAddress(), managerAddress);          }      }                  //********** Check for departing agents on the node & remove there conditions & opmodes **********      iter = localAgentsSubscription.getRemovedCollection().iterator();      while (iter.hasNext()) {         AgentExistsCondition aec = (AgentExistsCondition) iter.next();         if (logger.isDebugEnabled()) logger.debug("Removing "+aec.getAsset());         removeConditionsAndOpModes(aec.getAssetType(), aec.getAsset());      }            //********* Check for changes in our modes ************            //We have defense modes for all agents      iter = defenseModeSubscription.getChangedCollection().iterator();      while (iter.hasNext()) {          DisconnectDefenseAgentEnabler dmode = (DisconnectDefenseAgentEnabler)iter.next();          if (dmode != null) {              String defenseMode = dmode.getValue().toString();              if (logger.isDebugEnabled()) logger.debug("Saw: "+                 dmode.getClass()+":"+                 dmode.getName() + " set to " + dmode.getValue());          }      };      //We have defense modes for all agents      iter = monitoringModeSubscription.getChangedCollection().iterator();      while (iter.hasNext()) {                DisconnectMonitoringAgentEnabler mmode = (DisconnectMonitoringAgentEnabler)iter.next();          if (mmode != null) {              String monitoringMode = mmode.getValue().toString();              if (logger.isDebugEnabled()) logger.debug("Saw: "+                mmode.getClass()+":"+                mmode.getName() + " set to " + mmode.getValue());          }      }            //We have one local time condition, so we only get the one from iter.next();      // This was set by the DisconnectServlet for the Node      iter = localReconnectTimeSubscription.getChangedCollection().iterator();      if (logger.isDebugEnabled()) logger.debug("starting to process a changed LocalReconnectTimeCondition");      if (iter.hasNext()) {                LocalReconnectTimeCondition lrtc = (LocalReconnectTimeCondition)iter.next();          if (logger.isDebugEnabled()) logger.debug("Found lrtc "+lrtc.getAsset());          if (lrtc != null) {                reconnectInterval = (long) Double.parseDouble(lrtc.getValue().toString()) / 1000L;          }          // set the ReconnectTimeCondition for each agent on the node          Iterator iter2 = reconnectTimeSubscription.iterator();          while (iter2.hasNext()) {              ReconnectTimeCondition rtc = (ReconnectTimeCondition)iter2.next();              rtc.setTime(new Double(Double.parseDouble(lrtc.getValue().toString())));              getBlackboardService().publishAdd(rtc);              if (logger.isDebugEnabled()) logger.debug("Set the Condition for "+getNodeID()+":"+rtc.getAsset());             }      }            // announce changes to the defenseEnabler as Cougaar Events to allow actual disconnection from ACME      // need to iterate thru the modes to find the one for the Node Agent      iter = defenseModeSubscription.getChangedCollection().iterator();      while (iter.hasNext()) {          DisconnectDefenseAgentEnabler dmode = (DisconnectDefenseAgentEnabler)iter.next();          if (dmode != null) {              if (dmode.getAssetType().equals("Node")) {                  String defenseMode = dmode.getValue().toString();                  if (eventService.isEventEnabled()) {                      if (defenseMode.equals("ENABLED")) {                          eventService.event(getNodeID()+" plans to Disconnect for "+reconnectInterval+" sec");                      }                      else {                          eventService.event(getNodeID()+" has Reconnected");                      }                  }              }          }      };  }