if (properties.getProperty(Experiment.PERSIST_CLEAR) == null) { properties.setProperty(Experiment.PERSIST_CLEAR, "true"); }
  private void prepareToCreateNodes() {    HostComponent[] hostsToRunOn = experiment.getHostComponents();    for (int i = 0; i < hostsToRunOn.length; i++) {      String hostName = hostsToRunOn[i].getShortName();      NodeComponent[] nodesToRun = hostsToRunOn[i].getNodes();      for (int j = 0; j < nodesToRun.length; j++) {        NodeComponent nodeComponent = nodesToRun[j];        final String nodeName = nodeComponent.getShortName();        // create an unique node name to circumvent server problems        String uniqueNodeName = nodeName;        // get arguments from NodeComponent and pass them to ApplicationServer        // note that these properties augment any properties that        // are passed to the server in a properties file on startup        Properties properties = getNodeMinusD(nodeComponent, hostName);        java.util.List args = getNodeArguments(nodeComponent);        // TODO: experiment.getTrialID can return null        // if not connected to database        // and properties.setProperty generates a null pointer exception        // when passed a null value	if (experiment.getTrialID() != null)	  properties.setProperty(Experiment.EXPERIMENT_ID,                                experiment.getTrialID());	else {	  log.error("Null trial ID for experiment!");	}        //Don't override if it's already set        if (properties.getProperty(Experiment.PERSIST_CLEAR)             == null) {          properties.setProperty(Experiment.PERSIST_CLEAR,                                 "true");        }        // create a status button        NodeStatusButton statusButton = createStatusButton(nodeName, hostName);        ConsoleStyledDocument doc = new ConsoleStyledDocument();        ConsoleTextPane textPane = new ConsoleTextPane(doc, statusButton);        JScrollPane scrollPane = new JScrollPane(textPane);        // create a node event listener to get events from the node        OutputListener listener;        String logFileName = getLogFileName(nodeName);        try {          listener = new ConsoleNodeListener(this,                                             nodeComponent,                                             logFileName,                                             statusButton,                                             doc);        } catch (Exception e) {          if(log.isErrorEnabled()) {            log.error("Unable to create output for: " + nodeName, e);          }          continue;        }        if (notifyCondition != null)          textPane.setNotifyCondition(notifyCondition);        ((ConsoleStyledDocument)textPane.getStyledDocument()).setBufferSize(viewSize);        if (notifyOnStandardError)          statusButton.setNotifyOnStandardError(true);        if (displayFilter != null)          ((ConsoleNodeListener)listener).setFilter(displayFilter);        nodeListeners.put(nodeName, listener);        nodePanes.put(nodeName, textPane);        OutputPolicy outputPolicy = new OutputPolicy(10);        Iterator fileIter = experiment.getConfigFiles(nodesToRun);        int remotePort = getAppServerPort(properties);        RemoteHost remoteAppServer;        try {          remoteAppServer =             remoteHostRegistry.lookupRemoteHost(hostName, remotePort, true);        } catch (Exception e) {          if(log.isErrorEnabled()) {            log.error("CSMARTConsole: unable to contact app-server on " +                       hostName + " : " + remotePort, e);          }          JOptionPane.showMessageDialog(this,                                        "Unable to contact app-server on " +                                        hostName + " : " + remotePort +                                        "; check that server is running");          continue;        }        RemoteFileSystem remoteFS;        try {          remoteFS = remoteAppServer.getRemoteFileSystem();        } catch (Exception e) {          if(log.isErrorEnabled()) {            log.error("CSMARTConsole: unable to access app-server file system on " +                       hostName + " : " + remotePort, e);          }          JOptionPane.showMessageDialog(this,                                        "Unable to access app-server file system on " +                                         hostName + " : " + remotePort +                                        "; check that server is running");          continue;        }        while(fileIter.hasNext()) {          String filename = (String)fileIter.next();          OutputStream out = null;          try {            out = remoteFS.write(filename);            experiment.writeContents(filename, out);          } catch(Exception e) {            if(log.isErrorEnabled()) {              log.error("Caught an Exception writing leaf on " +                        hostName + " : " + remotePort, e);            }          } finally {            try {              out.close();            } catch(Exception e) {              if(log.isErrorEnabled()) {                log.error("Caught exception closing stream", e);              }            }          }        }        NodeCreationInfo nci =          new NodeCreationInfo(remoteAppServer, uniqueNodeName,                                properties, args,                               listener, outputPolicy,                                nodeName, hostName,                               nodeComponent, scrollPane, statusButton,                               logFileName);        nodeCreationInfoList.add(nci);      }    }  }