log.warn("Restart of active agent, action=ADD status=" +
log.warn("Restart of (possibly) active agent attempted, action=ADD status=" +
  public void execute() {    // Get Parameter changes    for (Iterator it = mgmtAgentProps.getChangedCollection().iterator();         it.hasNext();) {      //ManagementAgentProperties props = (ManagementAgentProperties)it.next();      //updateParams(props);      log.info("Parameters modified: " + paramsToString());    }     // Get HealthStatus objects    for (Iterator it = healthStatus.getChangedCollection().iterator();    //for (Iterator it = healthStatus.getCollection().iterator();         it.hasNext();) {      HealthStatus hs = (HealthStatus)it.next();      if (hs.getState().equals(HealthStatus.HEALTH_CHECK)) {        log.debug("Received HEALTH_CHECK for agent " + hs.getAgentId());        evaluate(hs);      }    }    // Get AgentControl objects    if (agentControlStatus.hasChanged()) {      for (Enumeration en = agentControlStatus.getChangedList(); en.hasMoreElements(); ) {	      AgentControl ac = (AgentControl) en.nextElement();        AbstractTicket ticket = ac.getAbstractTicket();        if (ticket instanceof AddTicket) {          AddTicket addTicket = (AddTicket)ticket;          HealthStatus hs = getHealthStatus(addTicket.getMobileAgent());          if (hs != null) {            hs.setHeartbeatRequestStatus(HealthStatus.UNDEFINED);            //log.debug("Changed mobility status: agent-" + hs.getAgentId() +            //  " statusCode=" + ac.getStatusCodeAsString());            if (ac.getStatusCode() == ac.CREATED) {              hs.setState(HealthStatus.RESTART_COMPLETE);              hs.setStatus(HealthStatus.RESTARTED);              publishChange(hs);              bbs.publishRemove(ac);            } else if (ac.getStatusCode() == ac.ALREADY_EXISTS) {              // Mobility thinks the agent is alive              // We think its dead because its not responding to HeartbeatRequests or Pings              log.warn("Restart of active agent, action=ADD status=" +                ac.getStatusCodeAsString() + " agent=" + addTicket.getMobileAgent() +                " destNode=" + addTicket.getDestinationNode());              // Try an in-place restart              hs.setLastRestartAttempt(new Date());              moveAgent(addTicket.getMobileAgent(), addTicket.getDestinationNode());            } else {              hs.setState(HealthStatus.FAILED_RESTART);              publishChange(hs);              bbs.publishRemove(ac);              log.error("Unexpected status code from mobility, action=ADD status=" +                ac.getStatusCodeAsString() + " agent=" + addTicket.getMobileAgent() +                " destNode=" + addTicket.getDestinationNode());            }          }        }      }    }    // Get RestartLocationRequests    for (Iterator it = restartRequests.getChangedCollection().iterator();         it.hasNext();) {      RestartLocationRequest req = (RestartLocationRequest)it.next();      int status = req.getStatus();      switch (status) {        case RestartLocationRequest.SUCCESS:          restartAgents(req.getAgents(), req.getNode());          bbs.publishRemove(req);          break;        case RestartLocationRequest.FAIL:          for (Iterator it1 = req.getAgents().iterator(); it1.hasNext();) {            HealthStatus hs = getHealthStatus((MessageAddress)it1.next());            if (hs != null) {              hs.setLastRestartAttempt(new Date());              hs.setState(HealthStatus.FAILED_RESTART);              publishChange(hs);            }          }          /*          log.error("Unable to restart agent(s), no destination node available:" +            " agents=" + req.getAgents());          bbs.publishRemove(req);          */          // RestartLocator did not return a destination, try to restart agent at          // its prior location          HealthStatus hs =            getHealthStatus((MessageAddress)req.getAgents().iterator().next());          restartAgents(req.getAgents(), hs.getNode());          bbs.publishRemove(req);          break;        default:      }    }  }