log.debug("Ping succeeded, agent=" + node);
  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 RestartLocationRequests    for (Iterator it = restartRequests.getAddedCollection().iterator();         it.hasNext();) {      RestartLocationRequest req = (RestartLocationRequest)it.next();      //log.info("Got RestartLocationRequest: agent(s)=" + req.getAgents());      getCommunityTopology();      Collection destinations = null;      //if (req.getRequestType() == RestartLocationRequest.LOCATE_NODE) {        destinations = selectDestinationNodes(req.getAgents(), req.getExcludedNodes(),          req.getExcludedHosts());        if (destinations != null && destinations.size() > 0) {          // get first candidate destination          log.debug("RestartLocationRequest: " + destinationsToString(destinations));          restartRequestMap.put(req, destinations);          Destination dest = (Destination)destinations.iterator().next();          doPing(new ClusterIdentifier(dest.node));        } else {          req.setStatus(RestartLocationRequest.FAIL);          bbs.publishChange(req);          StringBuffer msg =            new StringBuffer("No node available for restart: agent(s)=[");          for (Iterator it1 = req.getAgents().iterator(); it1.hasNext();) {            msg.append(((MessageAddress)it1.next()).toString());            if (it1.hasNext()) msg.append(" ");          }          msg.append("]");          log.warn(msg.toString());        }        /*      } else if (req.getRequestType() == RestartLocationRequest.LOCATE_HOST) {        destinations = selectDestinationHosts(req.getExcludedHosts());        if (destinations != null && destinations.size() > 0) {          // get first candidate destination          log.debug("RestartLocationRequest: " + destinationsToString(destinations));          Destination dest = (Destination)destinations.iterator().next();          req.setStatus(RestartLocationRequest.SUCCESS);          req.setHost(dest.host);          bbs.publishChange(req);        } else {          req.setStatus(RestartLocationRequest.FAIL);          bbs.publishChange(req);          log.warn("No host available for restart");        }      }      */    }    // Get PingRequests    for (Iterator it = pingRequests.getChangedCollection().iterator();         it.hasNext();) {      PingRequest req = (PingRequest)it.next();      int status = req.getStatus();      String node = req.getTarget().toString();      if (log.isDebugEnabled()) {        log.debug("PingRequest changed, agent=" + node + " request" + req);      }      switch (status) {        case PingRequest.SENT:          break;        case PingRequest.RECEIVED:          for (Iterator it1 = restartRequestMap.entrySet().iterator(); it1.hasNext();) {            Map.Entry me = (Map.Entry)it1.next();            RestartLocationRequest rlr = (RestartLocationRequest)me.getKey();            Collection destinations = (Collection)me.getValue();            for (Iterator it2 = destinations.iterator(); it2.hasNext();) {              Destination dest = (Destination)it2.next();              if (dest.node.equals(node) && dest.pingStatus == PingRequest.NEW) {                dest.pingStatus = PingRequest.RECEIVED;                log.debug("Ping succeeded, agent=" + node);                // Remove PingRequest from BB and our internal list                if (pingUIDs.contains(req.getUID())) pingUIDs.remove(req.getUID());                bbs.publishRemove(req);                rlr.setHost(dest.host);                rlr.setNode(dest.node);                rlr.setStatus(RestartLocationRequest.SUCCESS);                bbs.publishChange(rlr);                it1.remove();                if (log.isInfoEnabled()) {                  StringBuffer msg =                    new StringBuffer("Completed RestartLocation request: agent(s)=[");                  for (Iterator it3 = rlr.getAgents().iterator(); it3.hasNext();) {                    msg.append(((MessageAddress)it3.next()).toString());                    if (it3.hasNext()) msg.append(" ");                  }                  msg.append("], selectedNode=" + rlr.getNode() + ", selectedHost=" + rlr.getHost());                  log.debug(msg.toString());                  break;                }              }            }          }          break;        case PingRequest.FAILED:          for (Iterator it1 = restartRequestMap.entrySet().iterator(); it1.hasNext();) {            Map.Entry me = (Map.Entry)it1.next();            RestartLocationRequest rlr = (RestartLocationRequest)me.getKey();            Collection destinations = (Collection)me.getValue();            for (Iterator it2 = destinations.iterator(); it2.hasNext();) {              Destination dest = (Destination)it2.next();              if (dest.node.equals(node) && dest.pingStatus == PingRequest.NEW) {                dest.pingStatus = PingRequest.FAILED;                log.debug("Ping failed, agent=" + node);                if (it2.hasNext()) {                  dest = (Destination)it2.next();                  doPing(new ClusterIdentifier(dest.node));                } else {                  rlr.setStatus(RestartLocationRequest.FAIL);                  StringBuffer msg =                    new StringBuffer("No nodes/hosts available for restart: agent(s)=[");                  for (Iterator it3 = rlr.getAgents().iterator(); it3.hasNext();) {                    msg.append(((MessageAddress)it3.next()).toString());                    if (it3.hasNext()) msg.append(" ");                  }                  msg.append("]");                  it1.remove();                  log.debug(msg.toString());                  bbs.publishChange(rlr);                }              }            }          }          if (pingUIDs.contains(req.getUID())) pingUIDs.remove(req.getUID());          bbs.publishRemove(req);          break;        default:      }    }  }