Program: 32103
Project: 32103
Buggy source:
protected void runDistributedTrain() throws IOException, InterruptedException, ClassNotFoundException {
  LOG.info("String_Node_Str",isDryTrain ? "String_Node_Str" : "String_Node_Str");
  Configuration conf=new Configuration();
  SourceType sourceType=super.getModelConfig().getDataSet().getSource();
  final List<String> args=new ArrayList<String>();
  prepareCommonParams(args,sourceType);
  FileSystem fileSystem=ShifuFileUtils.getFileSystemBySourceType(sourceType);
  Path tmpModelsPath=fileSystem.makeQualified(new Path(super.getPathFinder().getPathBySourceType(new Path(Constants.TMP,Constants.DEFAULT_MODELS_TMP_FOLDER),sourceType)));
  args.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,NNConstants.NN_TMP_MODELS_FOLDER,tmpModelsPath.toString()));
  int baggingNum=isForVarSelect ? 1 : super.getModelConfig().getBaggingNum();
  long start=System.currentTimeMillis();
  LOG.info("String_Node_Str",baggingNum);
  boolean isParallel=Boolean.valueOf(Environment.getProperty(SHIFU_DTRAIN_PARALLEL,SHIFU_DEFAULT_DTRAIN_PARALLEL)).booleanValue();
  GuaguaMapReduceClient guaguaClient;
  if (modelConfig.getNormalize().getIsParquet()) {
    guaguaClient=new GuaguaParquetMapReduceClient();
    RequiredFieldList requiredFieldList=new RequiredFieldList();
    int[] inputOutputIndex=NNUtils.getInputOutputCandidateCounts(this.columnConfigList);
    int inputNodeCount=inputOutputIndex[0] == 0 ? inputOutputIndex[2] : inputOutputIndex[0];
    int candidateCount=inputOutputIndex[2];
    for (    ColumnConfig columnConfig : super.columnConfigList) {
      if (inputNodeCount == candidateCount) {
        if (CommonUtils.isGoodCandidate(columnConfig)) {
          requiredFieldList.add(new RequiredField(columnConfig.getColumnName(),columnConfig.getColumnNum(),null,DataType.DOUBLE));
        }
 else         if (columnConfig.isTarget()) {
          requiredFieldList.add(new RequiredField(columnConfig.getColumnName(),columnConfig.getColumnNum(),null,DataType.INTEGER));
        }
      }
 else {
        if (columnConfig.isFinalSelect()) {
          requiredFieldList.add(new RequiredField(columnConfig.getColumnName(),columnConfig.getColumnNum(),null,DataType.DOUBLE));
        }
 else         if (columnConfig.isTarget()) {
          requiredFieldList.add(new RequiredField(columnConfig.getColumnName(),columnConfig.getColumnNum(),null,DataType.INTEGER));
        }
      }
    }
    requiredFieldList.add(new RequiredField("String_Node_Str",columnConfigList.size(),null,DataType.DOUBLE));
    args.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,"String_Node_Str",serializeRequiredFieldList(requiredFieldList)));
    args.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,"String_Node_Str","String_Node_Str"));
  }
 else {
    guaguaClient=new GuaguaMapReduceClient();
  }
  List<String> progressLogList=new ArrayList<String>(baggingNum);
  for (int i=0; i < baggingNum; i++) {
    List<String> localArgs=new ArrayList<String>(args);
    localArgs.add("String_Node_Str");
    localArgs.add(String.format("String_Node_Str",super.getModelConfig().getModelSetName(),i + 1));
    LOG.info("String_Node_Str",(i + 1));
    String modelName=getModelName(i);
    Path modelPath=fileSystem.makeQualified(new Path(super.getPathFinder().getModelsPath(sourceType),modelName));
    checkContinuousTraining(fileSystem,localArgs,modelPath);
    localArgs.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,NNConstants.GUAGUA_NN_OUTPUT,modelPath.toString()));
    localArgs.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,NNConstants.NN_TRAINER_ID,String.valueOf(i + 1)));
    final String progressLogFile=getProgressLogFile(i + 1);
    progressLogList.add(progressLogFile);
    localArgs.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,NNConstants.NN_PROGRESS_FILE,progressLogFile));
    String hdpVersion=HDPUtils.getHdpVersionForHDP224();
    if (StringUtils.isNotBlank(hdpVersion)) {
      localArgs.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,"String_Node_Str",hdpVersion));
      HDPUtils.addFileToClassPath(HDPUtils.findContainingFile("String_Node_Str"),conf);
      HDPUtils.addFileToClassPath(HDPUtils.findContainingFile("String_Node_Str"),conf);
      HDPUtils.addFileToClassPath(HDPUtils.findContainingFile("String_Node_Str"),conf);
      HDPUtils.addFileToClassPath(HDPUtils.findContainingFile("String_Node_Str"),conf);
    }
    if (isParallel) {
      guaguaClient.addJob(localArgs.toArray(new String[0]));
    }
 else {
      TailThread tailThread=startTailThread(new String[]{progressLogFile});
      guaguaClient.createJob(localArgs.toArray(new String[0])).waitForCompletion(true);
      stopTailThread(tailThread);
    }
  }
  if (isParallel) {
    TailThread tailThread=startTailThread(progressLogList.toArray(new String[0]));
    guaguaClient.run();
    stopTailThread(tailThread);
  }
  for (int i=0; i < baggingNum; i++) {
    String modelName=getModelName(i);
    Path modelPath=fileSystem.makeQualified(new Path(super.getPathFinder().getModelsPath(sourceType),modelName));
    copyModelToLocal(modelName,modelPath,sourceType);
  }
  copyTmpModelsToLocal(tmpModelsPath,sourceType);
  LOG.info("String_Node_Str",System.currentTimeMillis() - start);
}

Fixed version (ground truth):
protected void runDistributedTrain() throws IOException, InterruptedException, ClassNotFoundException {
  LOG.info("String_Node_Str",isDryTrain ? "String_Node_Str" : "String_Node_Str");
  Configuration conf=new Configuration();
  SourceType sourceType=super.getModelConfig().getDataSet().getSource();
  final List<String> args=new ArrayList<String>();
  prepareCommonParams(args,sourceType);
  FileSystem fileSystem=ShifuFileUtils.getFileSystemBySourceType(sourceType);
  Path tmpModelsPath=fileSystem.makeQualified(new Path(super.getPathFinder().getPathBySourceType(new Path(Constants.TMP,Constants.DEFAULT_MODELS_TMP_FOLDER),sourceType)));
  args.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,NNConstants.NN_TMP_MODELS_FOLDER,tmpModelsPath.toString()));
  int baggingNum=isForVarSelect ? 1 : super.getModelConfig().getBaggingNum();
  long start=System.currentTimeMillis();
  LOG.info("String_Node_Str",baggingNum);
  boolean isParallel=Boolean.valueOf(Environment.getProperty(SHIFU_DTRAIN_PARALLEL,SHIFU_DEFAULT_DTRAIN_PARALLEL)).booleanValue();
  GuaguaMapReduceClient guaguaClient;
  if (modelConfig.getNormalize().getIsParquet()) {
    guaguaClient=new GuaguaParquetMapReduceClient();
    RequiredFieldList requiredFieldList=new RequiredFieldList();
    int[] inputOutputIndex=NNUtils.getInputOutputCandidateCounts(this.columnConfigList);
    int inputNodeCount=inputOutputIndex[0] == 0 ? inputOutputIndex[2] : inputOutputIndex[0];
    int candidateCount=inputOutputIndex[2];
    for (    ColumnConfig columnConfig : super.columnConfigList) {
      if (columnConfig.isTarget()) {
        requiredFieldList.add(new RequiredField(columnConfig.getColumnName(),columnConfig.getColumnNum(),null,DataType.FLOAT));
      }
 else {
        if (inputNodeCount == candidateCount) {
          if (!columnConfig.isMeta() && !columnConfig.isTarget() && CommonUtils.isGoodCandidate(columnConfig)) {
            requiredFieldList.add(new RequiredField(columnConfig.getColumnName(),columnConfig.getColumnNum(),null,DataType.FLOAT));
          }
        }
 else {
          if (!columnConfig.isMeta() && !columnConfig.isTarget() && columnConfig.isFinalSelect()) {
            requiredFieldList.add(new RequiredField(columnConfig.getColumnName(),columnConfig.getColumnNum(),null,DataType.FLOAT));
          }
        }
      }
    }
    requiredFieldList.add(new RequiredField("String_Node_Str",columnConfigList.size(),null,DataType.DOUBLE));
    args.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,"String_Node_Str",serializeRequiredFieldList(requiredFieldList)));
    args.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,"String_Node_Str","String_Node_Str"));
  }
 else {
    guaguaClient=new GuaguaMapReduceClient();
  }
  List<String> progressLogList=new ArrayList<String>(baggingNum);
  for (int i=0; i < baggingNum; i++) {
    List<String> localArgs=new ArrayList<String>(args);
    localArgs.add("String_Node_Str");
    localArgs.add(String.format("String_Node_Str",super.getModelConfig().getModelSetName(),i + 1));
    LOG.info("String_Node_Str",(i + 1));
    String modelName=getModelName(i);
    Path modelPath=fileSystem.makeQualified(new Path(super.getPathFinder().getModelsPath(sourceType),modelName));
    checkContinuousTraining(fileSystem,localArgs,modelPath);
    localArgs.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,NNConstants.GUAGUA_NN_OUTPUT,modelPath.toString()));
    localArgs.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,NNConstants.NN_TRAINER_ID,String.valueOf(i + 1)));
    final String progressLogFile=getProgressLogFile(i + 1);
    progressLogList.add(progressLogFile);
    localArgs.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,NNConstants.NN_PROGRESS_FILE,progressLogFile));
    String hdpVersion=HDPUtils.getHdpVersionForHDP224();
    if (StringUtils.isNotBlank(hdpVersion)) {
      localArgs.add(String.format(NNConstants.MAPREDUCE_PARAM_FORMAT,"String_Node_Str",hdpVersion));
      HDPUtils.addFileToClassPath(HDPUtils.findContainingFile("String_Node_Str"),conf);
      HDPUtils.addFileToClassPath(HDPUtils.findContainingFile("String_Node_Str"),conf);
      HDPUtils.addFileToClassPath(HDPUtils.findContainingFile("String_Node_Str"),conf);
      HDPUtils.addFileToClassPath(HDPUtils.findContainingFile("String_Node_Str"),conf);
    }
    if (isParallel) {
      guaguaClient.addJob(localArgs.toArray(new String[0]));
    }
 else {
      TailThread tailThread=startTailThread(new String[]{progressLogFile});
      guaguaClient.createJob(localArgs.toArray(new String[0])).waitForCompletion(true);
      stopTailThread(tailThread);
    }
  }
  if (isParallel) {
    TailThread tailThread=startTailThread(progressLogList.toArray(new String[0]));
    guaguaClient.run();
    stopTailThread(tailThread);
  }
  for (int i=0; i < baggingNum; i++) {
    String modelName=getModelName(i);
    Path modelPath=fileSystem.makeQualified(new Path(super.getPathFinder().getModelsPath(sourceType),modelName));
    copyModelToLocal(modelName,modelPath,sourceType);
  }
  copyTmpModelsToLocal(tmpModelsPath,sourceType);
  LOG.info("String_Node_Str",System.currentTimeMillis() - start);
}