// -------------------------------------------------------------
File jobFile = new File(jobFname);
if (!jobFile.exists()) {
// file doesn't exist
throw new JobExecutionException("RunDirJobSubmitter: input file "
+ jobFname + " does not exist.");
} else if (!jobFile.isFile()) {
// file is a directory
throw new JobExecutionException("RunDirJobSubmitter: input file "
+ jobFname + " is not a file.");
}
File f = new File(inputFname);
if (!f.exists()) {
// file doesn't exist
throw new JobExecutionException("RunDirJobSubmitter: input file "
+ inputFname + " does not exist.");
} else if (!f.isFile()) {
// file is a directory
throw new JobExecutionException("RunDirJobSubmitter: input file "
+ inputFname + " is not a file.");
}
// ----------------------------------------------------------------
// create a default JobSpec
// ----------------------------------------------------------------
JobSpec spec = JobBuilder.buildJobSpec(jobFile.getAbsolutePath());
Job job = spec.getJob();
NameValueJobInput jobInput = (NameValueJobInput) spec.getIn();
// ----------------------------------------------------------------
// open the file to read. traverse through the list of directories
// name given & override the default Job's runDirName value with the
// directory name. then submit the Job.
// ----------------------------------------------------------------
try {
BufferedReader in = new BufferedReader(new FileReader(inputFname));
if (!in.ready())
throw new IOException();
String line = null;
String jobId = null;
while ((line = in.readLine()) != null) {
// overwrite the runDirName
jobInput.setNameValuePair("runDirName", line);
jobId = submitJob(job, jobInput);
LOG.log(Level.INFO, "Job Submitted: id: [" + jobId + "]");
}
in.close();
} catch (IOException e) {
throw new JobExecutionException("RunDirJobSubmitter: " + e);
}
}