code: public static Set<String> findApplicationIdFromLog(String logFilePath, Logger log) {
  
      File logFile = new File(logFilePath);
  
      if (!logFile.exists()) {
        throw new IllegalArgumentException("the logFilePath does not exist: " + logFilePath);
      }
      if (!logFile.isFile()) {
        throw new IllegalArgumentException("the logFilePath specified  is not a valid file: "
            + logFilePath);
      }
      if (!logFile.canRead()) {
        throw new IllegalArgumentException(
            "unable to read the logFilePath specified: " + logFilePath);
      }
  
      BufferedReader br = null;
      Set<String> applicationIds = new HashSet<String>();
  
      try {
  //      br = new BufferedReader(new FileReader(logFile));
        br = new BufferedReader(new InputStreamReader(
            new FileInputStream(logFile), StandardCharsets.UTF_8));
        String line;
  
        // finds all the application IDs
        while ((line = br.readLine()) != null) {
          String[] inputs = line.split("\\s");
          if (inputs != null) {
            for (String input : inputs) {
              Matcher m = APPLICATION_ID_PATTERN.matcher(input);
              if (m.find()) {
                String appId = m.group(1);
                applicationIds.add(appId);
              }
            }
          }
        }
      } catch (IOException e) {
        log.error("Error while trying to find applicationId for log", e);
      } finally {
        try {
          if (br != null) {
            br.close();
          }
        } catch (Exception e) {
          // do nothing
        }
      }
      return applicationIds;
    }
docs: <pre>
  Takes in a log file, will grep every line to look for the application_id pattern.
  If it finds multiple, it will return all of them, de-duped (this is possible in the case of pig jobs)
  This can be used in conjunction with the @killJobOnCluster method in this file.
  </pre>
  
  @return a Set. May be empty, but will never be null