for (int j = 0; j < nodes.length; j++) { AgentComponent[] agents = nodes[j].getAgents();  if (agents == null || agents.length == 0) continue; String thisHost = hosts[i].getShortName(); if (thisHost.equals(nameServerHost)) { newNameServer = oldNameServer; break hostLoop; } if (dfltNameServer == null) { dfltNameServer = thisHost + ":" + NAME_SERVER_PORTS; if (oldNameServer == null) { break hostLoop; }
if (nodes.length == 0) continue; String thisHost = hosts[i].getShortName(); if (thisHost.equals(nameServerHost)) { newNameServer = oldNameServer; break hostLoop; } if (dfltNameServer == null) { dfltNameServer = thisHost + ":" + NAME_SERVER_PORTS; if (oldNameServer == null) { break hostLoop;
  public void updateNameServerHostName() {    Properties defaultNodeArgs = getDefaultNodeArguments();    String oldNameServer = defaultNodeArgs.getProperty("org.cougaar.name.server");    String newNameServer = null;    String dfltNameServer = null;    String nameServerHost = null;    if (oldNameServer != null) {      int colon = oldNameServer.indexOf(':');      if (colon >= 0) {        nameServerHost = oldNameServer.substring(0, colon);      } else {        nameServerHost = oldNameServer;      }    }    HostComponent[] hosts = getHostComponents();  hostLoop:    for (int i = 0; i < hosts.length; i++) {      NodeComponent[] nodes = hosts[i].getNodes();      for (int j = 0; j < nodes.length; j++) {	AgentComponent[] agents = nodes[j].getAgents();	// skip nodes that have no agents	if (agents == null || agents.length == 0)	  continue;        String thisHost = hosts[i].getShortName();        if (thisHost.equals(nameServerHost)) {          newNameServer = oldNameServer;          break hostLoop;       // Use existing nameserver definition        }        if (dfltNameServer == null) { // First host is default          dfltNameServer = thisHost + ":" + NAME_SERVER_PORTS;          if (oldNameServer == null) {            break hostLoop;     // Use dfltNameServer          }        }      }    }    if (newNameServer == null) newNameServer = dfltNameServer;    // set new server in all nodes    NodeComponent[] nodes = getNodesInner();    for (int i = 0; i < nodes.length; i++) {      NodeComponent node = nodes[i];      Properties arguments = node.getArguments();      // Insure no per-node override exists      arguments.remove("org.cougaar.name.server");    }    // Now install experiment-wide setting.    if (newNameServer != null) {      defaultNodeArgs.setProperty("org.cougaar.name.server", newNameServer);    }  }