@Override
    public void run() {
      PrintWriter writer = null;
      try {
        String enc = conf.get(AppConfig.EXEC_ENCODING_NAME);
        InputStreamReader isr = new InputStreamReader(in, enc);
        BufferedReader reader = new BufferedReader(isr);
        writer = new PrintWriter(new OutputStreamWriter(out, enc));

        String line;
        while ((line = reader.readLine()) != null) {
          writer.println(line);
          String percent = TempletonUtils.extractPercentComplete(line);
          String childid = TempletonUtils.extractChildJobId(line);
          updateJobStatePercentAndChildId(conf, jobid.toString(), percent, childid);
        }
        writer.flush();
        if(out != System.err && out != System.out) {
          //depending on FileSystem implementation flush() may or may not do anything 
          writer.close();
        }
      } catch (IOException e) {
        LOG.error("templeton: execute error: ", e);
      } finally {
        // Need to close() because in some FileSystem
        // implementations flush() is no-op.
        // Close the file handle if it is a hdfs file.
        // But if it is stderr/stdout, skip it since
        // WebHCat is not supposed to close it
        if (needCloseOutput && writer!=null) {
          writer.close();
        }
      }
    }
Updates the job state percent and childid in the templeton storage. Update only
takes place for non-null values.
hcatalog/webhcat/svr/src/main/java/org/apache/hive/hcatalog/templeton/tool/LaunchMapper.java