<commit_before>package org.apache.hadoop.yarn.dmtk.am;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

import org.apache.hadoop.yarn.dmtk.DSConstants;

public class CommandFileGenerator {
  CommandFileGenerator(boolean isVerboseOn, int workerServerPort,
      int workerNum, int serverNum, String workerArgs, String serverArgs) {
    isVerboseOn_ = isVerboseOn;
    workerServerPort_ = workerServerPort;
    workerNum_ = workerNum;
    serverNum_ = serverNum;
    workerArgs_ = workerArgs;
    serverArgs_ = serverArgs;
  }

  public void GenerateCommandFile(String type, int id, String fileName, String ip) throws Exception {
    if (type == DSConstants.WORKER)
      GenerateWorkerCommandFile(id, fileName);
    else
      GenerateServerCommandFile(id, ip, fileName);
  }

  /**
  * start.bat endpointlist machinelist workerId workerNum serverNum workerServerPort workerArgs
  */
  private void GenerateWorkerCommandFile(int workerId, String fileName) throws IOException {
    BufferedWriter out = new BufferedWriter(new FileWriter(
        fileName));
    out.write("cd " + DSConstants.WORKERDIR + " \n");
    if (DSConstants.isWindow) {
	    if (isVerboseOn_) {
	      out.write("echo 'files:'\ndir /s \n");
	      out.write("echo 'user:'\nwhoami\n");
	      out.write("echo 'content of cmd:'\ntype " + DSConstants.STARTFILE + " " + "\n");
	      out.write("echo 'content of endpointlist:'\ntype " + DSConstants.ENDPOINTLIST + "\n");
	      out.write("echo 'content of machinelist:'\ntype " + DSConstants.MACHINELISTFILE + "\n");
	    }
	
	    out.write("call " + DSConstants.STARTFILE + " "
	        + DSConstants.ENDPOINTLIST + " " 
	    	+ DSConstants.MACHINELISTFILE + " " + workerId + " "
	    	+ workerNum_ + " " + serverNum_ + " "
	        + workerServerPort_ + " " + workerArgs_ + " 2>&1 \n");
	    out.write("echo worker " + workerId + " exit with code %errorlevel%\n");
	    out.write("exit /b %errorlevel%\n");
	    out.close();
    } else {
	    if (isVerboseOn_) {
		      out.write("echo 'files:'\nls \n");
		      out.write("echo 'user:'\nwhoami\n");
		      out.write("echo 'content of cmd:'\ncat " + DSConstants.STARTFILE + " " + "\n");
		      out.write("echo 'content of endpointlist:'\ncat " + DSConstants.ENDPOINTLIST + "\n");
		      out.write("echo 'content of machinelist:'\ncat " + DSConstants.MACHINELISTFILE + "\n");
		    }
		
		    out.write("./" + DSConstants.STARTFILE + " "
		        + DSConstants.ENDPOINTLIST + " " + workerId + " " 
		        + workerServerPort_ + " " + workerArgs_ + " 2>&1 \n");
		    out.close();
    }
  }

  /**
  * start.bat serverId workerNum serverNum ip workerServerPort serverArgs
  */
  private void GenerateServerCommandFile(int serverId, String ip, String fileName) throws IOException {
    BufferedWriter out = new BufferedWriter(
        new FileWriter(fileName));
    out.write("cd " + DSConstants.SERVERDIR + " \n");
    if (DSConstants.isWindow) {
	    if (isVerboseOn_) {
	      out.write("echo 'fileslist:'\ndir /s \n");
	      out.write("echo 'user:'\nwhoami\n");
	      out.write("echo 'content of cmd:'\ntype " + " " + DSConstants.STARTFILE + " \n");
	    }
	
	    out.write("call " + DSConstants.STARTFILE + " "
	        + serverId + " " + workerNum_ + " " + serverNum_ + " " + ip + " "
	        + workerServerPort_ + " " + serverArgs_ + " 2>&1 \n");
	    out.write("echo server " + serverId +" exit with code %errorlevel%\n");
	    out.write("exit /b %errorlevel%\n");
	    out.close();
    } else {
	    if (isVerboseOn_) {
		      out.write("echo 'fileslist:'\nls \n");
		      out.write("echo 'user:'\nwhoami\n");
		      out.write("echo 'content of cmd:'\ncat " + " " + DSConstants.STARTFILE + " \n");
		    }
		
		    out.write("./" + DSConstants.STARTFILE + " "
		        + serverId + " " + workerNum_ + " "+ ip + ":"
		        + workerServerPort_ + " " + serverArgs_ + " 2>&1 \n");
		    out.close();
    }
  }

  private boolean isVerboseOn_;
  private int workerServerPort_;
  private int workerNum_, serverNum_;
  private String workerArgs_;
  private String serverArgs_;
}
<commit_msg>fix a bug generate command file in linux<commit_after>package org.apache.hadoop.yarn.dmtk.am;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

import org.apache.hadoop.yarn.dmtk.DSConstants;

public class CommandFileGenerator {
  CommandFileGenerator(boolean isVerboseOn, int workerServerPort,
      int workerNum, int serverNum, String workerArgs, String serverArgs) {
    isVerboseOn_ = isVerboseOn;
    workerServerPort_ = workerServerPort;
    workerNum_ = workerNum;
    serverNum_ = serverNum;
    workerArgs_ = workerArgs;
    serverArgs_ = serverArgs;
  }

  public void GenerateCommandFile(String type, int id, String fileName, String ip) throws Exception {
    if (type == DSConstants.WORKER)
      GenerateWorkerCommandFile(id, fileName);
    else
      GenerateServerCommandFile(id, ip, fileName);
  }

  /**
  * start.bat endpointlist machinelist workerId workerNum serverNum workerServerPort workerArgs
  */
  private void GenerateWorkerCommandFile(int workerId, String fileName) throws IOException {
    BufferedWriter out = new BufferedWriter(new FileWriter(
        fileName));
    out.write("cd " + DSConstants.WORKERDIR + " \n");
    if (DSConstants.isWindow) {
	    if (isVerboseOn_) {
	      out.write("echo 'files:'\ndir /s \n");
	      out.write("echo 'user:'\nwhoami\n");
	      out.write("echo 'content of cmd:'\ntype " + DSConstants.STARTFILE + " " + "\n");
	      out.write("echo 'content of endpointlist:'\ntype " + DSConstants.ENDPOINTLIST + "\n");
	      out.write("echo 'content of machinelist:'\ntype " + DSConstants.MACHINELISTFILE + "\n");
	    }
	
	    out.write("call " + DSConstants.STARTFILE + " "
	        + DSConstants.ENDPOINTLIST + " " 
	    	+ DSConstants.MACHINELISTFILE + " " + workerId + " "
	    	+ workerNum_ + " " + serverNum_ + " "
	        + workerServerPort_ + " " + workerArgs_ + " 2>&1 \n");
	    out.write("echo worker " + workerId + " exit with code %errorlevel%\n");
	    out.write("exit /b %errorlevel%\n");
	    out.close();
    } else {
	    if (isVerboseOn_) {
		      out.write("echo 'files:'\nls \n");
		      out.write("echo 'user:'\nwhoami\n");
		      out.write("echo 'content of cmd:'\ncat " + DSConstants.STARTFILE + " " + "\n");
		      out.write("echo 'content of endpointlist:'\ncat " + DSConstants.ENDPOINTLIST + "\n");
		      out.write("echo 'content of machinelist:'\ncat " + DSConstants.MACHINELISTFILE + "\n");
		    }
		
		    out.write("./" + DSConstants.STARTFILE + " "
		        + DSConstants.ENDPOINTLIST + " "
                + DSConstants.MACHINELISTFILE + " " + workerId + " " 
                + workerNum_ + " " + serverNum_ + " "
		        + workerServerPort_ + " " + workerArgs_ + " 2>&1 \n");
		    out.close();
    }
  }

  /**
  * start.bat serverId workerNum serverNum ip workerServerPort serverArgs
  */
  private void GenerateServerCommandFile(int serverId, String ip, String fileName) throws IOException {
    BufferedWriter out = new BufferedWriter(
        new FileWriter(fileName));
    out.write("cd " + DSConstants.SERVERDIR + " \n");
    if (DSConstants.isWindow) {
	    if (isVerboseOn_) {
	      out.write("echo 'fileslist:'\ndir /s \n");
	      out.write("echo 'user:'\nwhoami\n");
	      out.write("echo 'content of cmd:'\ntype " + " " + DSConstants.STARTFILE + " \n");
	    }
	
	    out.write("call " + DSConstants.STARTFILE + " "
	        + serverId + " " + workerNum_ + " " + serverNum_ + " " + ip + " "
	        + workerServerPort_ + " " + serverArgs_ + " 2>&1 \n");
	    out.write("echo server " + serverId +" exit with code %errorlevel%\n");
	    out.write("exit /b %errorlevel%\n");
	    out.close();
    } else {
	    if (isVerboseOn_) {
		      out.write("echo 'fileslist:'\nls \n");
		      out.write("echo 'user:'\nwhoami\n");
		      out.write("echo 'content of cmd:'\ncat " + " " + DSConstants.STARTFILE + " \n");
		    }
		
		    out.write("./" + DSConstants.STARTFILE + " "
		        + serverId + " " + workerNum_ + " " + serverNum_ + " " + ip + ":"
		        + workerServerPort_ + " " + serverArgs_ + " 2>&1 \n");
		    out.close();
    }
  }

  private boolean isVerboseOn_;
  private int workerServerPort_;
  private int workerNum_, serverNum_;
  private String workerArgs_;
  private String serverArgs_;
}

{'fraction_non_alphanumeric': 0.14728682170542637, 'fraction_numerical': 0.0019081693500298152, 'mean_word_length': 2.8292237442922374, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3232530', 'n_tokens_mistral': 2852, 'n_tokens_neox': 2689, 'n_words': 553}