public SliveTest(Configuration base) {
this.base = base;
}
public int run(String[] args) {
ParsedOutput parsedOpts = null;
try {
ArgumentParser argHolder = new ArgumentParser(args);
parsedOpts = argHolder.parse();
if (parsedOpts.shouldOutputHelp()) {
parsedOpts.outputHelp();
return 1;
}
} catch (Exception e) {
LOG.error("Unable to parse arguments due to error: ", e);
return 1;
}
LOG.info("Running with option list " + Helper.stringifyArray(args, " "));
ConfigExtractor config = null;
try {
ConfigMerger cfgMerger = new ConfigMerger();
Configuration cfg = cfgMerger.getMerged(parsedOpts,
new Configuration(base));
if (cfg != null) {
config = new ConfigExtractor(cfg);
}
} catch (Exception e) {
LOG.error("Unable to merge config due to error: ", e);
return 1;
}
if (config == null) {
LOG.error("Unable to merge config & options!");
return 1;
}
try {
LOG.info("Options are:");
ConfigExtractor.dumpOptions(config);
} catch (Exception e) {
LOG.error("Unable to dump options due to error: ", e);
return 1;
}
boolean jobOk = false;
try {
LOG.info("Running job:");
runJob(config);
jobOk = true;
} catch (Exception e) {
LOG.error("Unable to run job due to error: ", e);
}
if (jobOk) {
try {
LOG.info("Reporting on job:");
writeReport(config);
} catch (Exception e) {
LOG.error("Unable to report on job due to error: ", e);
}
}
// attempt cleanup (not critical)
boolean cleanUp = getBool(parsedOpts
.getValue(ConfigOption.CLEANUP.getOpt()));
if (cleanUp) {
try {
LOG.info("Cleaning up job:");
cleanup(config);