setCurrentState(se.name, INITIAL);
  public void applyUpdates(String nodeName, int nodeStatus, AgentStatus[] as, String leader) {    synchronized (statusMap) {      logger.debug("ApplyUpdates:" +                   " node=" + nodeName +                   " nodeStatus=" + controller.stateName(nodeStatus) +                   " numAgents=" + as.length);      //boolean leaderVoteChange = false;      StatusEntry se = (StatusEntry)statusMap.get(nodeName);      // Apply node status changes      if (se == null) {        se = new StatusEntry();        se.name = nodeName;        se.type = NODE;        se.timestamp = new Date();        se.ttl = DEFAULT_TTL;        se.currentLocation = nodeName;        se.priorLocation = null;        se.currentState = nodeStatus;        se.leaderVote = leader;        statusMap.put(se.name, se);        //leaderVoteChange = true;        queueChangeEvent(            new CommunityStatusChangeEvent(CommunityStatusChangeEvent.                                           MEMBERS_ADDED,                                           se.name,                                           se.type,                                           se.currentState,                                           -1,                                           null,                                           null,                                           null,                                           null));      } else {        if (se.currentState != nodeStatus) {          int priorState = se.currentState;          se.currentState = nodeStatus;          se.timestamp = new Date();          queueChangeEvent(              new CommunityStatusChangeEvent(CommunityStatusChangeEvent.                                             STATE_CHANGE,                                             se.name,                                             se.type,                                             se.currentState,                                             priorState,                                             null,                                             null,                                             null,                                             null));        }        if (se.leaderVote == null || !se.leaderVote.equals(leader)) {          se.leaderVote = leader;          //leaderVoteChange = true;        }      }      se.timestamp = new Date();      // Apply agent status changes      for (int i = 0; i < as.length; i++) {        se = (StatusEntry)statusMap.get(as[i].getName());        if (prior.contains(as[i].getName())) {          logger.info("Removing " + as[i].getName() + " from Prior list, update received from " + nodeName);          prior.remove(as[i].getName());        }        if (se != null) {          setCurrentState(as[i].getName(), as[i].getStatus());          if (se.currentLocation == null || !se.currentLocation.equals(as[i].getLocation())) {            se.priorLocation = se.currentLocation;            //logger.info(priorLocation + "->" + as[i].getLocation());            se.currentLocation = as[i].getLocation();            queueChangeEvent(                new CommunityStatusChangeEvent(CommunityStatusChangeEvent.                                               LOCATION_CHANGE,                                               se.name,                                               se.type,                                               se.currentState,                                               -1,                                               se.currentLocation,                                               se.priorLocation,                                               null,                                               null));          }          se.timestamp = new Date();        }      }      //if (leaderVoteChange)        electLeader();    }  }