selectedNode = (String)preferredRestartLocations.remove(agent);
  public static String getRestartLocation(String agent, Set excludedNodes) {    if(selectedNodes.containsKey(agent)) {      LinkedList nodes = (LinkedList)selectedNodes.get(agent);      if(nodes.size() > 0) {        return (String) nodes.removeFirst();      } else {        selectedNodes.remove(agent);        return null;      }    }    String activeNodes[] =        model.listEntries(model.NODE, DefaultRobustnessController.ACTIVE);    Set candidateNodes = new HashSet();    for (int i = 0; i < activeNodes.length; i++) {      if (!excludedNodes.contains(activeNodes[i])) {          candidateNodes.add(activeNodes[i]);      }    }    int numAgents = 0;    String selectedNode = null;    Hashtable temp = new Hashtable();    for (Iterator it = candidateNodes.iterator(); it.hasNext();) {      String candidate = (String)it.next();      int agentsOnNode = model.entitiesAtLocation(candidate).length;      if(logger.isDebugEnabled())        logger.debug("agents on node: " + candidate + "  " + agentsOnNode);      if(restartAgents.containsKey(candidate)){        int restarts = Integer.parseInt((String)(restartAgents.get(candidate)));        agentsOnNode += restarts;      }      temp.put(candidate, Integer.toString(agentsOnNode));      if (selectedNode == null || agentsOnNode < numAgents) {        selectedNode = candidate;        numAgents = agentsOnNode;      }    }    if (preferredRestartLocations.containsKey(agent)) {      logger.info("Using preferredRestartLocation: agent=" + agent + " dest=" + selectedNode);      selectedNode = (String)preferredRestartLocations.remove(agent);    }    temp.remove(selectedNode); //this one is already used this time, don't count it.    LinkedList list = new LinkedList();    for(int i=0; i<temp.size(); i++) {      String next = getNextNode(temp);      list.addLast(next);      temp.remove(next);    }    if(logger.isDebugEnabled())      logger.debug("other available restart nodes: " + list);    selectedNodes.put(agent, list);    return selectedNode;  }