private void findJobInstances(final File jobInstallPath, final Map<JobInstance, InstallationRecord> jobs) {
    try {
      String jobInstallCanonPath = jobInstallPath.getCanonicalPath();
      File configPath = Paths.get(jobInstallCanonPath, CFG_SUBPATH).toFile();
      if (!(configPath.exists() && configPath.isDirectory())) {
        log.debug("Config path not found: " + configPath);
        return;
      }

      for (File configFile : configPath.listFiles()) {

        if (configFile.isFile()) {

          String configFilePath = configFile.getCanonicalPath();
          Config config = jobConfigFactory.getConfig(new URI("file://" + configFilePath));

          if (config.containsKey(JobConfig.JOB_NAME) && config.containsKey(JobConfig.STREAM_JOB_FACTORY_CLASS)) {

            String jobName = config.get(JobConfig.JOB_NAME);
            String jobId = config.get(JobConfig.JOB_ID, "1");
            JobInstance jobInstance = new JobInstance(jobName, jobId);

            if (jobs.containsKey(jobInstance)) {
              throw new IllegalStateException(
                  String.format("Found more than one job config with jobName:%s and jobId:%s", jobName, jobId));
            }
            InstallationRecord jobInstall =
                new InstallationRecord(jobName, jobId, jobInstallCanonPath, configFilePath, getBinPath(jobInstallCanonPath));
            jobs.put(jobInstance, jobInstall);
          }
        }
      }
    } catch (Exception e) {
      throw new SamzaException("Exception finding job instance in path: " + jobInstallPath, e);
    }
  }
Finds all the job instances in the specified path and adds a corresponding {@link JobInstance} and
{@link InstallationRecord} for each instance.

@param jobInstallPath  the path to search for job instances.
@param jobs            the map to which the job instances will be added.
samza-rest/src/main/java/org/apache/samza/rest/proxy/installation/SimpleInstallationFinder.java