Program: 47732
Project: 47732
Buggy source:
public Result execute(Result result,int arg1) throws KettleException {
  result.setNrErrors(0);
  Log4jFileAppender appender=null;
  String logFileName="String_Node_Str" + this.getName();
  try {
    appender=LogWriter.createFileAppender(logFileName,true,false);
    LogWriter.getInstance().addAppender(appender);
    log.setLogLevel(parentJob.getLogLevel());
  }
 catch (  Exception e) {
    logError(BaseMessages.getString(PKG,"String_Node_Str",logFileName,e.toString()));
    logError(Const.getStackTracker(e));
  }
  try {
    HadoopConfiguration hadoopConfig=getHadoopConfiguration();
    HadoopShim shim=hadoopConfig.getHadoopShim();
    ClassLoader loader=shim.getClass().getClassLoader();
    Configuration conf=shim.createConfiguration();
    String hadoopJobNameS=environmentSubstitute(hadoopJobName);
    conf.setJobName(hadoopJobNameS);
    TransExecutionConfiguration transExecConfig=new TransExecutionConfiguration();
    TransMeta transMeta=loadTransMeta(this,rep,mapTrans,mapRepositoryReference,mapRepositoryDir,mapRepositoryFile);
    TransConfiguration transConfig=new TransConfiguration(transMeta,transExecConfig);
    String mapInputStepNameS=environmentSubstitute(mapInputStepName);
    String mapOutputStepNameS=environmentSubstitute(mapOutputStepName);
    try {
      verifyTransMeta(transMeta,mapInputStepNameS,mapOutputStepNameS);
    }
 catch (    Exception ex) {
      throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"),ex);
    }
    conf.set("String_Node_Str",transConfig.getXML());
    conf.set("String_Node_Str",mapInputStepNameS);
    conf.set("String_Node_Str",mapOutputStepNameS);
    conf.set(Configuration.STRING_COMBINE_SINGLE_THREADED,combiningSingleThreaded ? "String_Node_Str" : "String_Node_Str");
    conf.set(Configuration.STRING_REDUCE_SINGLE_THREADED,reducingSingleThreaded ? "String_Node_Str" : "String_Node_Str");
    if (getSuppressOutputOfMapKey()) {
      conf.setMapOutputKeyClass(shim.getHadoopWritableCompatibleClass(null));
    }
    if (getSuppressOutputOfMapValue()) {
      conf.setMapOutputValueClass(shim.getHadoopWritableCompatibleClass(null));
    }
    if (!getSuppressOutputOfMapKey() || !getSuppressOutputOfMapValue() && transMeta != null) {
      StepMeta mapOut=transMeta.findStep(mapOutputStepNameS);
      RowMetaInterface prevStepFields=transMeta.getPrevStepFields(mapOut);
      if (mapOut.getStepMetaInterface() instanceof HadoopExitMeta) {
        String keyName=((HadoopExitMeta)mapOut.getStepMetaInterface()).getOutKeyFieldname();
        String valName=((HadoopExitMeta)mapOut.getStepMetaInterface()).getOutValueFieldname();
        int keyI=prevStepFields.indexOfValue(keyName);
        ValueMetaInterface keyVM=(keyI >= 0) ? prevStepFields.getValueMeta(keyI) : null;
        int valI=prevStepFields.indexOfValue(valName);
        ValueMetaInterface valueVM=(valI >= 0) ? prevStepFields.getValueMeta(valI) : null;
        if (!getSuppressOutputOfMapKey()) {
          if (keyVM == null) {
            throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
          }
          Class<?> hadoopWritableKey=shim.getHadoopWritableCompatibleClass(keyVM);
          conf.setMapOutputKeyClass(hadoopWritableKey);
          logDebug(BaseMessages.getString(PKG,"String_Node_Str",hadoopWritableKey.getName()));
        }
        if (!getSuppressOutputOfMapValue()) {
          if (valueVM == null) {
            throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
          }
          Class<?> hadoopWritableValue=shim.getHadoopWritableCompatibleClass(valueVM);
          conf.setMapOutputValueClass(hadoopWritableValue);
          logDebug(BaseMessages.getString(PKG,"String_Node_Str",hadoopWritableValue.getName()));
        }
      }
    }
    transMeta=loadTransMeta(this,rep,combinerTrans,combinerRepositoryReference,combinerRepositoryDir,combinerRepositoryFile);
    if (transMeta != null) {
      if (combiningSingleThreaded) {
        verifySingleThreadingValidity(transMeta);
      }
      transConfig=new TransConfiguration(transMeta,transExecConfig);
      conf.set("String_Node_Str",transConfig.getXML());
      String combinerInputStepNameS=environmentSubstitute(combinerInputStepName);
      String combinerOutputStepNameS=environmentSubstitute(combinerOutputStepName);
      conf.set("String_Node_Str",combinerInputStepNameS);
      conf.set("String_Node_Str",combinerOutputStepNameS);
      conf.setCombinerClass(shim.getPentahoMapReduceCombinerClass());
      try {
        verifyTransMeta(transMeta,combinerInputStepNameS,combinerOutputStepNameS);
      }
 catch (      Exception ex) {
        throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"),ex);
      }
    }
    transMeta=loadTransMeta(this,rep,reduceTrans,reduceRepositoryReference,reduceRepositoryDir,reduceRepositoryFile);
    if (transMeta != null) {
      if (reducingSingleThreaded) {
        verifySingleThreadingValidity(transMeta);
      }
      transConfig=new TransConfiguration(transMeta,transExecConfig);
      conf.set("String_Node_Str",transConfig.getXML());
      String reduceInputStepNameS=environmentSubstitute(reduceInputStepName);
      String reduceOutputStepNameS=environmentSubstitute(reduceOutputStepName);
      conf.set("String_Node_Str",reduceInputStepNameS);
      conf.set("String_Node_Str",reduceOutputStepNameS);
      conf.setReducerClass(shim.getPentahoMapReduceReducerClass());
      try {
        verifyTransMeta(transMeta,reduceInputStepNameS,reduceOutputStepNameS);
      }
 catch (      Exception ex) {
        throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"),ex);
      }
      if (getSuppressOutputOfKey()) {
        conf.setOutputKeyClass(shim.getHadoopWritableCompatibleClass(null));
      }
      if (getSuppressOutputOfValue()) {
        conf.setOutputValueClass(shim.getHadoopWritableCompatibleClass(null));
      }
      if (!getSuppressOutputOfKey() || !getSuppressOutputOfValue()) {
        StepMeta reduceOut=transMeta.findStep(reduceOutputStepNameS);
        RowMetaInterface prevStepFields=transMeta.getPrevStepFields(reduceOut);
        if (reduceOut.getStepMetaInterface() instanceof HadoopExitMeta) {
          String keyName=((HadoopExitMeta)reduceOut.getStepMetaInterface()).getOutKeyFieldname();
          String valName=((HadoopExitMeta)reduceOut.getStepMetaInterface()).getOutValueFieldname();
          int keyI=prevStepFields.indexOfValue(keyName);
          ValueMetaInterface keyVM=(keyI >= 0) ? prevStepFields.getValueMeta(keyI) : null;
          int valI=prevStepFields.indexOfValue(valName);
          ValueMetaInterface valueVM=(valI >= 0) ? prevStepFields.getValueMeta(valI) : null;
          if (!getSuppressOutputOfKey()) {
            if (keyVM == null) {
              throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
            }
            Class<?> hadoopWritableKey=shim.getHadoopWritableCompatibleClass(keyVM);
            conf.setOutputKeyClass(hadoopWritableKey);
            logDebug(BaseMessages.getString(PKG,"String_Node_Str",hadoopWritableKey.getName()));
          }
          if (!getSuppressOutputOfValue()) {
            if (valueVM == null) {
              throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
            }
            Class<?> hadoopWritableValue=shim.getHadoopWritableCompatibleClass(valueVM);
            conf.setOutputValueClass(hadoopWritableValue);
            logDebug(BaseMessages.getString(PKG,"String_Node_Str",hadoopWritableValue.getName()));
          }
        }
      }
    }
    conf.setMapRunnerClass(shim.getPentahoMapReduceMapRunnerClass());
    if (inputFormatClass != null) {
      String inputFormatClassS=environmentSubstitute(inputFormatClass).trim();
      Class<?> inputFormat=loader.loadClass(inputFormatClassS);
      conf.setInputFormat(inputFormat);
    }
    if (outputFormatClass != null) {
      String outputFormatClassS=environmentSubstitute(outputFormatClass).trim();
      Class<?> outputFormat=loader.loadClass(outputFormatClassS);
      conf.setOutputFormat(outputFormat);
    }
    String hdfsHostnameS=environmentSubstitute(hdfsHostname);
    String hdfsPortS=environmentSubstitute(hdfsPort);
    String jobTrackerHostnameS=environmentSubstitute(jobTrackerHostname);
    String jobTrackerPortS=environmentSubstitute(jobTrackerPort);
    List<String> configMessages=new ArrayList<String>();
    shim.configureConnectionInformation(hdfsHostnameS,hdfsPortS,jobTrackerHostnameS,jobTrackerPortS,conf,configMessages);
    for (    String m : configMessages) {
      logBasic(m);
    }
    FileSystem fs=shim.getFileSystem(conf);
    String inputPathS=environmentSubstitute(inputPath);
    Matcher m=Pattern.compile("String_Node_Str").matcher(inputPathS);
    StringBuffer sb=new StringBuffer();
    while (m.find()) {
      m.appendReplacement(sb,m.group().replace("String_Node_Str","String_Node_Str"));
    }
    m.appendTail(sb);
    String[] inputPathParts=sb.toString().split("String_Node_Str");
    List<Path> paths=new ArrayList<Path>();
    for (    String path : inputPathParts) {
      paths.add(fs.asPath(conf.getDefaultFileSystemURL(),path.replaceAll("String_Node_Str","String_Node_Str")));
    }
    Path[] finalPaths=paths.toArray(new Path[paths.size()]);
    final Path outputPathPath=fs.asPath(conf.getDefaultFileSystemURL(),environmentSubstitute(outputPath));
    conf.setInputPaths(finalPaths);
    conf.setOutputPath(outputPathPath);
    for (    UserDefinedItem item : userDefined) {
      if (item.getName() != null && !"String_Node_Str".equals(item.getName()) && item.getValue() != null && !"String_Node_Str".equals(item.getValue())) {
        String nameS=environmentSubstitute(item.getName());
        String valueS=environmentSubstitute(item.getValue());
        conf.set(nameS,valueS);
      }
    }
    conf.setJarByClass(shim.getPentahoMapReduceMapRunnerClass());
    String numMapTasksS=environmentSubstitute(numMapTasks);
    try {
      if (Integer.parseInt(numMapTasksS) < 0) {
        throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
      }
    }
 catch (    NumberFormatException e) {
      if (log.isDebug()) {
        logError(Const.getStackTracker(e));
      }
    }
    String numReduceTasksS=environmentSubstitute(numReduceTasks);
    try {
      if (Integer.parseInt(numReduceTasksS) < 0) {
        throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
      }
    }
 catch (    NumberFormatException e) {
      if (log.isDebug()) {
        logError(Const.getStackTracker(e));
      }
    }
    conf.setNumMapTasks(Const.toInt(numMapTasksS,1));
    conf.setNumReduceTasks(Const.toInt(numReduceTasksS,1));
    VariableSpace variableSpace=this.getVariables();
    XStream xStream=new XStream();
    xStream.alias("String_Node_Str",VariableSpace.class);
    String xmlVariableSpace=xStream.toXML(variableSpace);
    conf.setStrings("String_Node_Str",xmlVariableSpace);
    conf.setStrings("String_Node_Str",this.getLogLevel().toString());
    if (isCleanOutputPath()) {
      if (log.isBasic()) {
        logBasic(BaseMessages.getString(PKG,"String_Node_Str",outputPathPath.toUri().toString()));
      }
      try {
        if (!cleanOutputPath(fs,outputPathPath)) {
          logBasic(BaseMessages.getString(PKG,"String_Node_Str",outputPathPath.toUri().toString()));
        }
      }
 catch (      IOException ex) {
        result.setStopped(true);
        result.setNrErrors(1);
        result.setResult(false);
        logError(BaseMessages.getString(PKG,"String_Node_Str",outputPathPath.toUri().toString()),ex);
        return result;
      }
    }
    Properties pmrProperties=loadPMRProperties();
    if (useDistributedCache(conf,pmrProperties)) {
      String installPath=getProperty(conf,pmrProperties,PENTAHO_MAPREDUCE_PROPERTY_KETTLE_HDFS_INSTALL_DIR,null);
      String installId=getProperty(conf,pmrProperties,PENTAHO_MAPREDUCE_PROPERTY_KETTLE_INSTALLATION_ID,BuildVersion.getInstance().getVersion());
      try {
        if (Const.isEmpty(installPath)) {
          throw new IllegalArgumentException(BaseMessages.getString(PKG,"String_Node_Str"));
        }
        if (Const.isEmpty(installId)) {
          String pluginVersion=new PluginPropertiesUtil().getVersion();
          installId=BuildVersion.getInstance().getVersion();
          if (pluginVersion != null) {
            installId=installId + "String_Node_Str" + pluginVersion;
          }
          installId=installId + "String_Node_Str" + hadoopConfig.getIdentifier();
        }
        if (!installPath.endsWith(Const.FILE_SEPARATOR)) {
          installPath+=Const.FILE_SEPARATOR;
        }
        Path kettleEnvInstallDir=fs.asPath(installPath,installId);
        PluginInterface plugin=getPluginInterface();
        FileObject pmrLibArchive=KettleVFS.getFileObject(plugin.getPluginDirectory().getPath() + Const.FILE_SEPARATOR + getProperty(conf,pmrProperties,PENTAHO_MAPREDUCE_PROPERTY_PMR_LIBRARIES_ARCHIVE_FILE,null));
        if (shim.getDistributedCacheUtil().isKettleEnvironmentInstalledAt(fs,kettleEnvInstallDir)) {
          logDetailed(BaseMessages.getString(PKG,"String_Node_Str",kettleEnvInstallDir.toUri().getPath()));
        }
 else {
          String additionalPluginNames=getProperty(conf,pmrProperties,PENTAHO_MAPREDUCE_PROPERTY_ADDITIONAL_PLUGINS,null);
          installKettleEnvironment(shim,pmrLibArchive,fs,kettleEnvInstallDir,additionalPluginNames);
        }
        configureWithKettleEnvironment(shim,conf,fs,kettleEnvInstallDir);
      }
 catch (      Exception ex) {
        result.setStopped(true);
        result.setNrErrors(1);
        result.setResult(false);
        logError(BaseMessages.getString(PKG,"String_Node_Str"),ex);
        return result;
      }
    }
    RunningJob runningJob=shim.submitJob(conf);
    String loggingIntervalS=environmentSubstitute(loggingInterval);
    int logIntv=60;
    try {
      logIntv=Integer.parseInt(loggingIntervalS);
    }
 catch (    NumberFormatException e) {
      logError("String_Node_Str" + loggingIntervalS + "String_Node_Str"+ "String_Node_Str");
    }
    if (blocking) {
      try {
        int taskCompletionEventIndex=0;
        while (!parentJob.isStopped() && !runningJob.isComplete()) {
          if (logIntv >= 1) {
            printJobStatus(runningJob);
            taskCompletionEventIndex+=logTaskMessages(runningJob,taskCompletionEventIndex);
            Thread.sleep(logIntv * 1000);
          }
 else {
            Thread.sleep(60000);
          }
        }
        if (parentJob.isStopped() && !runningJob.isComplete()) {
          runningJob.killJob();
          result.setResult(false);
        }
        printJobStatus(runningJob);
        logTaskMessages(runningJob,taskCompletionEventIndex);
      }
 catch (      InterruptedException ie) {
        logError(ie.getMessage(),ie);
      }
      result.setResult(runningJob.isSuccessful());
    }
  }
 catch (  Throwable t) {
    t.printStackTrace();
    result.setStopped(true);
    result.setNrErrors(1);
    result.setResult(false);
    logError(Const.NVL(t.getMessage(),"String_Node_Str"),t);
  }
  if (appender != null) {
    LogWriter.getInstance().removeAppender(appender);
    appender.close();
    ResultFile resultFile=new ResultFile(ResultFile.FILE_TYPE_LOG,appender.getFile(),parentJob.getJobname(),getName());
    result.getResultFiles().put(resultFile.getFile().toString(),resultFile);
  }
  return result;
}

Fixed version (ground truth):
public Result execute(Result result,int arg1) throws KettleException {
  result.setNrErrors(0);
  Log4jFileAppender appender=null;
  String logFileName="String_Node_Str" + this.getName();
  try {
    appender=LogWriter.createFileAppender(logFileName,false,false);
    LogWriter.getInstance().addAppender(appender);
    log.setLogLevel(parentJob.getLogLevel());
  }
 catch (  Exception e) {
    logError(BaseMessages.getString(PKG,"String_Node_Str",logFileName,e.toString()));
    logError(Const.getStackTracker(e));
  }
  try {
    HadoopConfiguration hadoopConfig=getHadoopConfiguration();
    HadoopShim shim=hadoopConfig.getHadoopShim();
    ClassLoader loader=shim.getClass().getClassLoader();
    Configuration conf=shim.createConfiguration();
    String hadoopJobNameS=environmentSubstitute(hadoopJobName);
    conf.setJobName(hadoopJobNameS);
    TransExecutionConfiguration transExecConfig=new TransExecutionConfiguration();
    TransMeta transMeta=loadTransMeta(this,rep,mapTrans,mapRepositoryReference,mapRepositoryDir,mapRepositoryFile);
    TransConfiguration transConfig=new TransConfiguration(transMeta,transExecConfig);
    String mapInputStepNameS=environmentSubstitute(mapInputStepName);
    String mapOutputStepNameS=environmentSubstitute(mapOutputStepName);
    try {
      verifyTransMeta(transMeta,mapInputStepNameS,mapOutputStepNameS);
    }
 catch (    Exception ex) {
      throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"),ex);
    }
    conf.set("String_Node_Str",transConfig.getXML());
    conf.set("String_Node_Str",mapInputStepNameS);
    conf.set("String_Node_Str",mapOutputStepNameS);
    conf.set(Configuration.STRING_COMBINE_SINGLE_THREADED,combiningSingleThreaded ? "String_Node_Str" : "String_Node_Str");
    conf.set(Configuration.STRING_REDUCE_SINGLE_THREADED,reducingSingleThreaded ? "String_Node_Str" : "String_Node_Str");
    if (getSuppressOutputOfMapKey()) {
      conf.setMapOutputKeyClass(shim.getHadoopWritableCompatibleClass(null));
    }
    if (getSuppressOutputOfMapValue()) {
      conf.setMapOutputValueClass(shim.getHadoopWritableCompatibleClass(null));
    }
    if (!getSuppressOutputOfMapKey() || !getSuppressOutputOfMapValue() && transMeta != null) {
      StepMeta mapOut=transMeta.findStep(mapOutputStepNameS);
      RowMetaInterface prevStepFields=transMeta.getPrevStepFields(mapOut);
      if (mapOut.getStepMetaInterface() instanceof HadoopExitMeta) {
        String keyName=((HadoopExitMeta)mapOut.getStepMetaInterface()).getOutKeyFieldname();
        String valName=((HadoopExitMeta)mapOut.getStepMetaInterface()).getOutValueFieldname();
        int keyI=prevStepFields.indexOfValue(keyName);
        ValueMetaInterface keyVM=(keyI >= 0) ? prevStepFields.getValueMeta(keyI) : null;
        int valI=prevStepFields.indexOfValue(valName);
        ValueMetaInterface valueVM=(valI >= 0) ? prevStepFields.getValueMeta(valI) : null;
        if (!getSuppressOutputOfMapKey()) {
          if (keyVM == null) {
            throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
          }
          Class<?> hadoopWritableKey=shim.getHadoopWritableCompatibleClass(keyVM);
          conf.setMapOutputKeyClass(hadoopWritableKey);
          logDebug(BaseMessages.getString(PKG,"String_Node_Str",hadoopWritableKey.getName()));
        }
        if (!getSuppressOutputOfMapValue()) {
          if (valueVM == null) {
            throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
          }
          Class<?> hadoopWritableValue=shim.getHadoopWritableCompatibleClass(valueVM);
          conf.setMapOutputValueClass(hadoopWritableValue);
          logDebug(BaseMessages.getString(PKG,"String_Node_Str",hadoopWritableValue.getName()));
        }
      }
    }
    transMeta=loadTransMeta(this,rep,combinerTrans,combinerRepositoryReference,combinerRepositoryDir,combinerRepositoryFile);
    if (transMeta != null) {
      if (combiningSingleThreaded) {
        verifySingleThreadingValidity(transMeta);
      }
      transConfig=new TransConfiguration(transMeta,transExecConfig);
      conf.set("String_Node_Str",transConfig.getXML());
      String combinerInputStepNameS=environmentSubstitute(combinerInputStepName);
      String combinerOutputStepNameS=environmentSubstitute(combinerOutputStepName);
      conf.set("String_Node_Str",combinerInputStepNameS);
      conf.set("String_Node_Str",combinerOutputStepNameS);
      conf.setCombinerClass(shim.getPentahoMapReduceCombinerClass());
      try {
        verifyTransMeta(transMeta,combinerInputStepNameS,combinerOutputStepNameS);
      }
 catch (      Exception ex) {
        throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"),ex);
      }
    }
    transMeta=loadTransMeta(this,rep,reduceTrans,reduceRepositoryReference,reduceRepositoryDir,reduceRepositoryFile);
    if (transMeta != null) {
      if (reducingSingleThreaded) {
        verifySingleThreadingValidity(transMeta);
      }
      transConfig=new TransConfiguration(transMeta,transExecConfig);
      conf.set("String_Node_Str",transConfig.getXML());
      String reduceInputStepNameS=environmentSubstitute(reduceInputStepName);
      String reduceOutputStepNameS=environmentSubstitute(reduceOutputStepName);
      conf.set("String_Node_Str",reduceInputStepNameS);
      conf.set("String_Node_Str",reduceOutputStepNameS);
      conf.setReducerClass(shim.getPentahoMapReduceReducerClass());
      try {
        verifyTransMeta(transMeta,reduceInputStepNameS,reduceOutputStepNameS);
      }
 catch (      Exception ex) {
        throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"),ex);
      }
      if (getSuppressOutputOfKey()) {
        conf.setOutputKeyClass(shim.getHadoopWritableCompatibleClass(null));
      }
      if (getSuppressOutputOfValue()) {
        conf.setOutputValueClass(shim.getHadoopWritableCompatibleClass(null));
      }
      if (!getSuppressOutputOfKey() || !getSuppressOutputOfValue()) {
        StepMeta reduceOut=transMeta.findStep(reduceOutputStepNameS);
        RowMetaInterface prevStepFields=transMeta.getPrevStepFields(reduceOut);
        if (reduceOut.getStepMetaInterface() instanceof HadoopExitMeta) {
          String keyName=((HadoopExitMeta)reduceOut.getStepMetaInterface()).getOutKeyFieldname();
          String valName=((HadoopExitMeta)reduceOut.getStepMetaInterface()).getOutValueFieldname();
          int keyI=prevStepFields.indexOfValue(keyName);
          ValueMetaInterface keyVM=(keyI >= 0) ? prevStepFields.getValueMeta(keyI) : null;
          int valI=prevStepFields.indexOfValue(valName);
          ValueMetaInterface valueVM=(valI >= 0) ? prevStepFields.getValueMeta(valI) : null;
          if (!getSuppressOutputOfKey()) {
            if (keyVM == null) {
              throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
            }
            Class<?> hadoopWritableKey=shim.getHadoopWritableCompatibleClass(keyVM);
            conf.setOutputKeyClass(hadoopWritableKey);
            logDebug(BaseMessages.getString(PKG,"String_Node_Str",hadoopWritableKey.getName()));
          }
          if (!getSuppressOutputOfValue()) {
            if (valueVM == null) {
              throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
            }
            Class<?> hadoopWritableValue=shim.getHadoopWritableCompatibleClass(valueVM);
            conf.setOutputValueClass(hadoopWritableValue);
            logDebug(BaseMessages.getString(PKG,"String_Node_Str",hadoopWritableValue.getName()));
          }
        }
      }
    }
    conf.setMapRunnerClass(shim.getPentahoMapReduceMapRunnerClass());
    if (inputFormatClass != null) {
      String inputFormatClassS=environmentSubstitute(inputFormatClass).trim();
      Class<?> inputFormat=loader.loadClass(inputFormatClassS);
      conf.setInputFormat(inputFormat);
    }
    if (outputFormatClass != null) {
      String outputFormatClassS=environmentSubstitute(outputFormatClass).trim();
      Class<?> outputFormat=loader.loadClass(outputFormatClassS);
      conf.setOutputFormat(outputFormat);
    }
    String hdfsHostnameS=environmentSubstitute(hdfsHostname);
    String hdfsPortS=environmentSubstitute(hdfsPort);
    String jobTrackerHostnameS=environmentSubstitute(jobTrackerHostname);
    String jobTrackerPortS=environmentSubstitute(jobTrackerPort);
    List<String> configMessages=new ArrayList<String>();
    shim.configureConnectionInformation(hdfsHostnameS,hdfsPortS,jobTrackerHostnameS,jobTrackerPortS,conf,configMessages);
    for (    String m : configMessages) {
      logBasic(m);
    }
    FileSystem fs=shim.getFileSystem(conf);
    String inputPathS=environmentSubstitute(inputPath);
    Matcher m=Pattern.compile("String_Node_Str").matcher(inputPathS);
    StringBuffer sb=new StringBuffer();
    while (m.find()) {
      m.appendReplacement(sb,m.group().replace("String_Node_Str","String_Node_Str"));
    }
    m.appendTail(sb);
    String[] inputPathParts=sb.toString().split("String_Node_Str");
    List<Path> paths=new ArrayList<Path>();
    for (    String path : inputPathParts) {
      paths.add(fs.asPath(conf.getDefaultFileSystemURL(),path.replaceAll("String_Node_Str","String_Node_Str")));
    }
    Path[] finalPaths=paths.toArray(new Path[paths.size()]);
    final Path outputPathPath=fs.asPath(conf.getDefaultFileSystemURL(),environmentSubstitute(outputPath));
    conf.setInputPaths(finalPaths);
    conf.setOutputPath(outputPathPath);
    for (    UserDefinedItem item : userDefined) {
      if (item.getName() != null && !"String_Node_Str".equals(item.getName()) && item.getValue() != null && !"String_Node_Str".equals(item.getValue())) {
        String nameS=environmentSubstitute(item.getName());
        String valueS=environmentSubstitute(item.getValue());
        conf.set(nameS,valueS);
      }
    }
    conf.setJarByClass(shim.getPentahoMapReduceMapRunnerClass());
    String numMapTasksS=environmentSubstitute(numMapTasks);
    try {
      if (Integer.parseInt(numMapTasksS) < 0) {
        throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
      }
    }
 catch (    NumberFormatException e) {
      if (log.isDebug()) {
        logError(Const.getStackTracker(e));
      }
    }
    String numReduceTasksS=environmentSubstitute(numReduceTasks);
    try {
      if (Integer.parseInt(numReduceTasksS) < 0) {
        throw new KettleException(BaseMessages.getString(PKG,"String_Node_Str"));
      }
    }
 catch (    NumberFormatException e) {
      if (log.isDebug()) {
        logError(Const.getStackTracker(e));
      }
    }
    conf.setNumMapTasks(Const.toInt(numMapTasksS,1));
    conf.setNumReduceTasks(Const.toInt(numReduceTasksS,1));
    VariableSpace variableSpace=this.getVariables();
    XStream xStream=new XStream();
    xStream.alias("String_Node_Str",VariableSpace.class);
    String xmlVariableSpace=xStream.toXML(variableSpace);
    conf.setStrings("String_Node_Str",xmlVariableSpace);
    conf.setStrings("String_Node_Str",this.getLogLevel().toString());
    if (isCleanOutputPath()) {
      if (log.isBasic()) {
        logBasic(BaseMessages.getString(PKG,"String_Node_Str",outputPathPath.toUri().toString()));
      }
      try {
        if (!cleanOutputPath(fs,outputPathPath)) {
          logBasic(BaseMessages.getString(PKG,"String_Node_Str",outputPathPath.toUri().toString()));
        }
      }
 catch (      IOException ex) {
        result.setStopped(true);
        result.setNrErrors(1);
        result.setResult(false);
        logError(BaseMessages.getString(PKG,"String_Node_Str",outputPathPath.toUri().toString()),ex);
        return result;
      }
    }
    Properties pmrProperties=loadPMRProperties();
    if (useDistributedCache(conf,pmrProperties)) {
      String installPath=getProperty(conf,pmrProperties,PENTAHO_MAPREDUCE_PROPERTY_KETTLE_HDFS_INSTALL_DIR,null);
      String installId=getProperty(conf,pmrProperties,PENTAHO_MAPREDUCE_PROPERTY_KETTLE_INSTALLATION_ID,BuildVersion.getInstance().getVersion());
      try {
        if (Const.isEmpty(installPath)) {
          throw new IllegalArgumentException(BaseMessages.getString(PKG,"String_Node_Str"));
        }
        if (Const.isEmpty(installId)) {
          String pluginVersion=new PluginPropertiesUtil().getVersion();
          installId=BuildVersion.getInstance().getVersion();
          if (pluginVersion != null) {
            installId=installId + "String_Node_Str" + pluginVersion;
          }
          installId=installId + "String_Node_Str" + hadoopConfig.getIdentifier();
        }
        if (!installPath.endsWith(Const.FILE_SEPARATOR)) {
          installPath+=Const.FILE_SEPARATOR;
        }
        Path kettleEnvInstallDir=fs.asPath(installPath,installId);
        PluginInterface plugin=getPluginInterface();
        FileObject pmrLibArchive=KettleVFS.getFileObject(plugin.getPluginDirectory().getPath() + Const.FILE_SEPARATOR + getProperty(conf,pmrProperties,PENTAHO_MAPREDUCE_PROPERTY_PMR_LIBRARIES_ARCHIVE_FILE,null));
        if (shim.getDistributedCacheUtil().isKettleEnvironmentInstalledAt(fs,kettleEnvInstallDir)) {
          logDetailed(BaseMessages.getString(PKG,"String_Node_Str",kettleEnvInstallDir.toUri().getPath()));
        }
 else {
          String additionalPluginNames=getProperty(conf,pmrProperties,PENTAHO_MAPREDUCE_PROPERTY_ADDITIONAL_PLUGINS,null);
          installKettleEnvironment(shim,pmrLibArchive,fs,kettleEnvInstallDir,additionalPluginNames);
        }
        configureWithKettleEnvironment(shim,conf,fs,kettleEnvInstallDir);
      }
 catch (      Exception ex) {
        result.setStopped(true);
        result.setNrErrors(1);
        result.setResult(false);
        logError(BaseMessages.getString(PKG,"String_Node_Str"),ex);
        return result;
      }
    }
    RunningJob runningJob=shim.submitJob(conf);
    String loggingIntervalS=environmentSubstitute(loggingInterval);
    int logIntv=60;
    try {
      logIntv=Integer.parseInt(loggingIntervalS);
    }
 catch (    NumberFormatException e) {
      logError("String_Node_Str" + loggingIntervalS + "String_Node_Str"+ "String_Node_Str");
    }
    if (blocking) {
      try {
        int taskCompletionEventIndex=0;
        while (!parentJob.isStopped() && !runningJob.isComplete()) {
          if (logIntv >= 1) {
            printJobStatus(runningJob);
            taskCompletionEventIndex+=logTaskMessages(runningJob,taskCompletionEventIndex);
            Thread.sleep(logIntv * 1000);
          }
 else {
            Thread.sleep(60000);
          }
        }
        if (parentJob.isStopped() && !runningJob.isComplete()) {
          runningJob.killJob();
          result.setResult(false);
        }
        printJobStatus(runningJob);
        logTaskMessages(runningJob,taskCompletionEventIndex);
      }
 catch (      InterruptedException ie) {
        logError(ie.getMessage(),ie);
      }
      result.setResult(runningJob.isSuccessful());
    }
  }
 catch (  Throwable t) {
    t.printStackTrace();
    result.setStopped(true);
    result.setNrErrors(1);
    result.setResult(false);
    logError(Const.NVL(t.getMessage(),"String_Node_Str"),t);
  }
  if (appender != null) {
    LogWriter.getInstance().removeAppender(appender);
    appender.close();
    ResultFile resultFile=new ResultFile(ResultFile.FILE_TYPE_LOG,appender.getFile(),parentJob.getJobname(),getName());
    result.getResultFiles().put(resultFile.getFile().toString(),resultFile);
  }
  return result;
}