Commit in lcsim on MAIN | |||
resources/org/lcsim/schemas/lcsim/1.0/lcsim.xsd | +1 | -1 | 1.9 -> 1.10 |
src/org/lcsim/job/JobControlManager.java | +290 | -370 | 1.56 -> 1.57 |
+291 | -371 |
make input files optional in .lcsim files
diff -u -r1.9 -r1.10 --- lcsim.xsd 10 Jun 2010 18:35:02 -0000 1.9 +++ lcsim.xsd 8 Apr 2012 23:45:31 -0000 1.10 @@ -110,7 +110,7 @@
<xs:element name="lcsim"> <xs:complexType> <xs:all>
- <xs:element ref="inputFiles" minOccurs="1" maxOccurs="1"/>
+ <xs:element ref="inputFiles" minOccurs="0" maxOccurs="1"/>
<xs:element ref="control" minOccurs="0" maxOccurs="1"/> <xs:element ref="classpath" minOccurs="0" maxOccurs="1"/> <xs:element ref="define" minOccurs="0" maxOccurs="1"/>
diff -u -r1.56 -r1.57 --- JobControlManager.java 27 Mar 2012 03:08:41 -0000 1.56 +++ JobControlManager.java 8 Apr 2012 23:45:31 -0000 1.57 @@ -20,8 +20,8 @@
import java.util.LinkedHashMap; import java.util.List; import java.util.Map;
-import java.util.Properties;
import java.util.Map.Entry;
+import java.util.Properties;
import java.util.regex.Matcher; import java.util.regex.Pattern;
@@ -32,10 +32,8 @@
import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser;
-import org.freehep.application.studio.Studio; -import org.freehep.jas.services.DynamicClassLoader;
import org.freehep.record.loop.LoopSourceExhaustedException;
-import org.freehep.util.FreeHEPLookup;
+import org.freehep.record.loop.event.RecordSuppliedEvent;
import org.jdom.Attribute; import org.jdom.Document; import org.jdom.Element;
@@ -44,11 +42,13 @@
import org.jdom.output.Format; import org.jdom.output.XMLOutputter; import org.lcsim.LCSimVersion;
+import org.lcsim.event.EventHeader;
import org.lcsim.units.Constants; import org.lcsim.util.Driver; import org.lcsim.util.DriverAdapter; import org.lcsim.util.cache.FileCache; import org.lcsim.util.loop.LCIOEventSource;
+import org.lcsim.util.loop.LCSimConditionsManagerImplementation;
import org.lcsim.util.loop.LCSimLoop; import org.lcsim.util.xml.ClasspathEntityResolver; import org.lcsim.util.xml.JDOMExpressionFactory;
@@ -80,15 +80,14 @@
* which it should be discarded. If the {@link #run()} method is called twice on * the same manager, a fatal exception will be thrown. *
- * @version $Id: JobControlManager.java,v 1.56 2012/03/27 03:08:41 jeremy Exp $
+ * @version $Id: JobControlManager.java,v 1.57 2012/04/08 23:45:31 jeremy Exp $
* @author Jeremy McCormick */ // TODO Allow no input files when only Driver list is needed.
-// TODO Add job setting "checkInputFiles" which can be switched to false if input file existence should NOT be checked before job starts.
public class JobControlManager { // The LCIO record loop.
- private LCSimLoop loop = new LCSimLoop();
+ private LCSimLoop loop;
// Driver management. private Map<String, Driver> driverMap = new LinkedHashMap<String, Driver>();
@@ -108,7 +107,6 @@
// Boolean job options. private boolean performDryRun; private boolean rewrite;
- private boolean checkInputFilesExist = true;
// Settings effecting logging verbosity. private boolean printInputFiles;
@@ -125,9 +123,6 @@
// True once job parameters are setup from CL and XML. private boolean wasSetup;
- - // Flag so that only one job is run by the manager. - private boolean ranJob;
// The manager's class loader. private ClassLoader loader;
@@ -148,30 +143,27 @@
// Reg exp to extract variables from a string with the form "${varName}". private static final Pattern varPattern = Pattern.compile("[$][{][a-zA-Z_-]*[}]");
+ private DriverAdapter driverAdapter = null; +
/** * The default constructor. */
- public JobControlManager() - { - try - {
+ public JobControlManager() { + try {
fileCache = new FileCache();
- } - catch (IOException x) - {
+ } catch (IOException x) {
throw new RuntimeException(x); }
+ LCSimConditionsManagerImplementation.register();
} /** * Run the manager using a main. Takes command-line options (see class description). * @param args The command line arguments. */
- public static void main(String args[]) - {
+ public static void main(String args[]) {
JobControlManager mgr = new JobControlManager();
- if (args.length == 0) - {
+ if (args.length == 0) {
mgr.logStream.println("java -jar lcsim-bin.jar [options] steeringFile.xml"); HelpFormatter help = new HelpFormatter(); help.printHelp(" ", options);
@@ -228,52 +220,40 @@
CommandLine cl = null; // Parse CL arguments.
- try - {
+ try {
cl = parser.parse(options, args);
- } - catch (ParseException x) - { - throw new RuntimeException(x);
+ } catch (ParseException x) { + throw new RuntimeException("Problem parsing command line options.", x);
} // Turn on verbose mode. This setting may be overridden by control section from XML.
- if (cl.hasOption("v")) - {
+ if (cl.hasOption("v")) {
setVerbose(true); } // Turn on quiet mode. If "-v" is also specified, this will have no effect.
- else if (cl.hasOption("q")) - {
+ else if (cl.hasOption("q")) {
setVerbose(false); } // Load properties file containing variable definitions.
- if (cl.hasOption("p")) - {
+ if (cl.hasOption("p")) {
String[] propValues = cl.getOptionValues("p");
- for (String propFileName : propValues) - {
+ for (String propFileName : propValues) {
InputStream in = null;
- try - {
+ try {
in = new FileInputStream(propFileName); }
- catch (FileNotFoundException e) - {
+ catch (FileNotFoundException e) {
throw new RuntimeException(e); } Properties props = new Properties();
- try - {
+ try {
props.load(in); }
- catch (IOException e) - {
+ catch (IOException e) {
throw new RuntimeException(e); }
- for (Entry<Object,Object> entry : props.entrySet()) - {
+ for (Entry<Object,Object> entry : props.entrySet()) {
String key = (String) entry.getKey(); String value = (String) entry.getValue(); addVariableDefinition(key, value);
@@ -282,14 +262,11 @@
} // Process user variable definitions.
- if (cl.hasOption("D")) - {
+ if (cl.hasOption("D")) {
String[] defValues = cl.getOptionValues("D");
- for (String def : defValues) - {
+ for (String def : defValues) {
String[] s = def.split("=");
- if (s.length != 2) - {
+ if (s.length != 2) {
throw new RuntimeException("Bad variable format: " + def); } String key = s[0];
@@ -299,49 +276,40 @@
} // Rewrite XML file with variables resolved.
- if (cl.hasOption("w")) - {
+ if (cl.hasOption("w")) {
this.rewrite = true; String rewritePath = cl.getOptionValue("w"); this.rewriteFile = new File(rewritePath);
- if (this.rewriteFile.exists()) - {
+ if (this.rewriteFile.exists()) {
throw new RuntimeException("Rewrite file already exists: " + rewritePath); } } // Set max number of events to run.
- if (cl.hasOption("n")) - {
+ if (cl.hasOption("n")) {
this.maxEvents = Integer.valueOf(cl.getOptionValue("n")); } // Set number of events to skip.
- if (cl.hasOption("s")) - {
+ if (cl.hasOption("s")) {
this.skipEvents = Integer.valueOf(cl.getOptionValue("s")); } // Perform a dry run, not processing any events but doing job setup.
- if (cl.hasOption("x")) - {
+ if (cl.hasOption("x")) {
this.performDryRun = true; } // The path to the XML steering file, which has no command switch.
- if (cl.getArgList().size() == 0) - {
+ if (cl.getArgList().size() == 0) {
throw new RuntimeException("Missing LCSim XML file argument.");
- } - else if (cl.getArgList().size() > 1) - {
+ } else if (cl.getArgList().size() > 1) {
throw new RuntimeException("Too many extra arguments."); } // Setup the XML steering file and check for its existence. File xmlRunControlFile = new File((String) cl.getArgList().get(0));
- if (!xmlRunControlFile.exists()) - {
+ if (!xmlRunControlFile.exists()) {
throw new RuntimeException("The steering file " + args[0] + " does not exist!"); }
@@ -358,8 +326,7 @@
*/ public void addVariableDefinition(String key, String value) {
- if (verbose) - {
+ if (verbose) {
logStream.println(key + " = " + value); } if (!this.variableMap.containsKey(key))
@@ -373,86 +340,66 @@
} /**
- * Execute a job using the current parameters. This is publically accessible - * in case the CL interface isn't being used and {@link #setup(File)} was called - * manually.
+ * Execute a job using the current parameters.
*/
- public void run()
+ public boolean run()
{
- // Only one job can be run with the manager, after which a new one should be created. - if (this.ranJob) - { - throw new RuntimeException("Cannot run multiple jobs! Create another JobManager."); - } -
// If setup was not called first, then abort the job.
- if (!wasSetup) - { - throw new RuntimeException("Aborting job! The method JobManager.setup(File) was never called.");
+ if (!wasSetup) { + //throw new RuntimeException("Aborting job! The method JobManager.setup(File) was never called."); + logStream.println("Aborting job! Setup was never called."); + return false;
}
- if (printVersion) - {
+ if (printVersion) {
(new LCSimVersion()).printOut(logStream); logStream.println(); }
- // Add the drivers to the loop. - for (Driver driver : driverExec) - { - loop.add(driver); - }
+ // Need to make sure loop is setup before running. + getLCSimLoop();
- try - {
+ try {
// Add the LCIO files to the loop.
- loop.setLCIORecordSource(new LCIOEventSource("test", inputFiles));
+ loop.setLCIORecordSource(new LCIOEventSource(this.getClass().getSimpleName(), inputFiles));
// Driver statistics printout. PrintStream statsStream = null;
- if (printDriverStatistics) - {
+ if (printDriverStatistics) {
statsStream = logStream; }
- // Execute job if not a dry run. - if (!performDryRun) - { - if (verbose) - {
+ // Execute the entire job if not a dry run. + if (!performDryRun) { + if (verbose) {
logStream.println("Start time: " + (new Date())); logStream.println(); }
- if (skipEvents > 0) - { - if (verbose) - {
+ if (skipEvents > 0) { + if (verbose) {
logStream.println("Skipping " + skipEvents + " events."); } loop.skip(skipEvents); }
- // Execute the loop.
+ // Execute the loop.
loop.loop(maxEvents, statsStream);
- if (verbose) - {
+ if (verbose) {
logStream.println(); logStream.println("End time: " + (new Date())); } } // A dry run does not process any events.
- else - {
+ else {
// Always print this info msg. logStream.println("Executed dry run. No events processed!"); } } // Record source was exhausted before max events was hit. This is probably fine, // but print message in case more were expected.
- catch (LoopSourceExhaustedException x) - {
+ catch (LoopSourceExhaustedException x) {
logStream.println(x.getMessage()); } // Catch other fatal exceptions thrown from the loop.
@@ -463,17 +410,24 @@
// Cleanup. loop.dispose();
+ loop = null;
- // Set flag so that manager is NOT reused for another job. - this.ranJob = true;
+ // Job was successful. + return true;
} /** * Get the <code>LCSimLoop</code> of this JobManager. * @return The LCSimLoop. */
- public LCSimLoop getLCSimLoop() - {
+ public LCSimLoop getLCSimLoop() { + if (loop == null) { + loop = new LCSimLoop(); + // Add the drivers to the loop. + for (Driver driver : driverExec) { + loop.add(driver); + } + }
return loop; }
@@ -483,8 +437,7 @@
* method has been called. * @return A <code>List</code> of <code>Drivers</code>. */
- public List<Driver> getDriverExecList() - {
+ public List<Driver> getDriverExecList() {
return this.driverExec; }
@@ -494,12 +447,9 @@
*/ public void setup(File file) {
- try - {
+ try {
setup((new FileInputStream(file)));
- } - catch (FileNotFoundException x) - {
+ } catch (FileNotFoundException x) {
throw new RuntimeException(x); } }
@@ -508,8 +458,7 @@
* Setup job parameters from an embedded resource. * This method calls {@link #setup(InputStream)}. */
- public void setup(String resourceURL) - {
+ public void setup(String resourceURL) {
setup(this.getClass().getResourceAsStream(resourceURL)); }
@@ -517,8 +466,8 @@
* Setup job parameters from an <code>InputStream</code> with XML text. * @param in The XML input stream. */
- public void setup(InputStream in) - {
+ public void setup(InputStream in) { +
// Make the Document builder. SAXBuilder builder = new SAXBuilder();
@@ -532,12 +481,9 @@
// Build the document. Document doc = null;
- try - {
+ try {
doc = builder.build(in);
- } - catch (Exception x) - {
+ } catch (Exception x) {
throw new RuntimeException(x); }
@@ -555,8 +501,10 @@
*/ private void setup(Document doc) {
- if (wasSetup) - throw new RuntimeException("Setup was already called!");
+ if (wasSetup) { + logStream.println("Ignoring call to setup as it was already called."); + return; + }
// Set the root element. root = doc.getRootElement();
@@ -566,8 +514,7 @@
// Rewrite XML after variable substitution. Correctness of values, // such as existence of input file paths, is NOT checked.
- if (this.rewrite) - {
+ if (this.rewrite) {
rewriteXMLSteering(doc); }
@@ -575,8 +522,7 @@
setupJobControlParameters(); // Print system properties.
- if (printSystemProperties) - {
+ if (printSystemProperties) {
printSystemProperties(logStream); }
@@ -637,8 +583,8 @@
match.reset(); // Loop over the matches.
- while (match.find()) - {
+ while (match.find()) { +
// Variable string with ${...} enclosure included. String var = match.group();
@@ -663,8 +609,7 @@
} // Recursively process all child elements of this one.
- for (Iterator it = element.getChildren().iterator(); it.hasNext(); ) - {
+ for (Iterator it = element.getChildren().iterator(); it.hasNext(); ) {
substituteVariables((Element)it.next()); } }
@@ -674,22 +619,17 @@
* The output path is set by command line argument to "-w". * @param doc The XML steering doc with variables substituted. */
- private void rewriteXMLSteering(Document doc) - { - if (verbose) - {
+ private void rewriteXMLSteering(Document doc) { + if (verbose) {
logStream.println("Rewriting XML to " + this.rewriteFile + " ..."); } XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(Format.getPrettyFormat());
- try - {
+ try {
FileOutputStream out = new FileOutputStream(this.rewriteFile); outputter.output(doc, out); out.close();
- } - catch (Exception e) - {
+ } catch (Exception e) {
throw new RuntimeException(e); } }
@@ -700,15 +640,14 @@
*/ private void setupDrivers() {
- if (printDriversDetailed) - {
+ if (printDriversDetailed) {
logStream.println("--- Drivers ---"); } // Loop over the list of driver elements. List<Element> drivers = root.getChild("drivers").getChildren("driver");
- for (Element driver : drivers) - {
+ for (Element driver : drivers) { +
// Get the name of the Driver. String name = driver.getAttributeValue("name");
@@ -716,8 +655,7 @@
String type = driver.getAttributeValue("type"); // Translate from a short name (optional).
- if (availableDrivers.get(type) != null) - {
+ if (availableDrivers.get(type) != null) {
type = availableDrivers.get(type); }
@@ -727,12 +665,9 @@
// Class of the Driver. Class driverClass;
- try - {
+ try {
driverClass = loader.loadClass(type);
- } - catch (ClassNotFoundException x) - {
+ } catch (ClassNotFoundException x) {
throw new RuntimeException("The Driver class " + type + " was not found.", x); }
@@ -741,17 +676,13 @@
// The Driver instance. Driver newDriver;
- try - {
+ try {
newDriver = (Driver) driverClass.newInstance(); }
- catch (InstantiationException x) - {
+ catch (InstantiationException x) {
throw new RuntimeException("Failed to create a Driver of class " + type + ". " + "This class might be missing a public constructor with no arguments.",x);
- } - catch (IllegalAccessException x) - {
+ } catch (IllegalAccessException x) {
throw new RuntimeException("Cannot access Driver type " + type + ". " + "You may need to make this class or its constructor public.",x); }
@@ -760,8 +691,7 @@
List<Element> parameters = driver.getChildren(); // Process the parameters.
- for (Element parameterElement : parameters) - {
+ for (Element parameterElement : parameters) {
// The parameter's setter method that we will find. Method setter = null;
@@ -775,34 +705,30 @@
// Find setter methods that look like good matches for this parameter. List<Method> methods = getSetterMethods(driverClass); List<Method> methodCandidates = new ArrayList<Method>();
- for (Method method : methods) - {
+ for (Method method : methods) {
String propHack = method.getName().replaceFirst("set", "");
+ // FIXME: Converting to lower case need not happen + users might not find desireable.
propHack = propHack.substring(0, 1).toLowerCase() + propHack.substring(1);
- if (propHack.equals(pname)) - {
+ if (propHack.equals(pname)) {
methodCandidates.add(method); } } // Found the single setter method.
- if (methodCandidates.size() == 1) - {
+ if (methodCandidates.size() == 1) {
setter = methodCandidates.get(0);
- if (setter.getParameterTypes().length > 1) - {
+ if (setter.getParameterTypes().length > 1) {
throw new RuntimeException("The set method has too many arguments for parameter: " + pname); } propertyType = setter.getParameterTypes()[0];
- } - // Found several, overloaded methods. Try to disambiguate them.
+ } + // Found several, overloaded methods. Try to disambiguate them.
else if (methodCandidates.size() > 1) { if (parameterElement.getAttribute("type") == null) throw new RuntimeException("Parameter " + pname + " in Driver " + driverClass.getCanonicalName() + " is overloaded, but a type field is missing from the parameter's XML element.");
- try - {
+ try {
// Try a primitive type first. propertyType = getPrimitiveType(parameterElement.getAttribute("type").getValue());
@@ -810,8 +736,7 @@
if (propertyType == null) propertyType = Class.forName(parameterElement.getAttribute("type").getValue()); }
- catch (ClassNotFoundException x) - {
+ catch (ClassNotFoundException x) {
throw new RuntimeException("Bad user type: " + parameterElement.getAttribute("type").getValue() + " for parameter " + pname + "."); } // Find a method that matches the user type.
@@ -826,21 +751,18 @@
} } // No method found. The parameter name is probably invalid.
- else if (methodCandidates.size() == 0) - {
+ else if (methodCandidates.size() == 0) {
throw new RuntimeException("No set method found for parameter: " + pname); } // No setter method found.
- if (setter == null) - {
+ if (setter == null) {
throw new RuntimeException("Unable to find set method for parameter: " + pname); } // Convert the parameter to the appropriate type. IParameterConverter converter = paramConverter.getConverterForType(propertyType);
- if (converter == null) - {
+ if (converter == null) {
throw new RuntimeException( "No converter found for parameter " + parameterElement.getName() + " with type " + propertyType.getName() + ".");
@@ -850,8 +772,7 @@
// Call the setter with the parameter as argument. Object pargs[] = new Object[1]; pargs[0] = nextParameter;
- try - {
+ try {
// This invokes the setter method of the driver. setter.invoke(newDriver, pargs);
@@ -859,8 +780,7 @@
if (printDriversDetailed) logStream.println(" " + pname + " = " + parameterElement.getText().trim()); }
- catch (Exception x) - {
+ catch (Exception x) {
throw new RuntimeException("Problem processing parameter " + parameterElement.getName() + ".", x); } } // parameter loop
@@ -869,23 +789,19 @@
addDriver(name, newDriver); } // driver loop
- if (printDriversDetailed) - {
+ if (printDriversDetailed) {
logStream.println("--- End Drivers ---"); } // Make a list of Drivers to be executed. List<Element> exec = root.getChild("execute").getChildren("driver");
- for (Element execDriver : exec) - {
+ for (Element execDriver : exec) {
String driverName = execDriver.getAttributeValue("name"); Driver driverFind = driverMap.get(driverName);
- if (driverFind != null) - {
+ if (driverFind != null) {
driverExec.add(driverFind); }
- else - {
+ else {
throw new RuntimeException("A Driver called " + driverName + " was not found."); } }
@@ -898,8 +814,7 @@
*/ private void addDriver(String name, Driver driver) {
- if (driverMap.containsKey(name)) - {
+ if (driverMap.containsKey(name)) {
throw new RuntimeException("Duplicate driver name: " + name); } driverMap.put(name, driver);
@@ -908,8 +823,7 @@
private void printSystemProperties(PrintStream ps) { logStream.println("--- System Properties ---");
- for (Entry<Object, Object> entry : System.getProperties().entrySet()) - {
+ for (Entry<Object, Object> entry : System.getProperties().entrySet()) {
logStream.println(entry.getKey() + " = " + entry.getValue()); } logStream.println("-- End System Properties");
@@ -941,24 +855,20 @@
File file = null; // Try to process the file text as a URL.
- try - {
+ try {
URL fileURL = new URL(fileLoc); // Local file URL.
- if (fileLoc.startsWith("file:")) - {
+ if (fileLoc.startsWith("file:")) {
file = new File(fileURL.getPath()); } // Remote file URL. else {
- try - {
+ try {
file = this.fileCache.getCachedFile(fileURL); }
- catch (IOException x) - {
+ catch (IOException x) {
throw new RuntimeException("Unable to fetch file " + fileLoc + " to the cache directory.", x); } }
@@ -970,8 +880,7 @@
} // Add to list.
- if (fileList != null) - {
+ if (fileList != null) {
fileList.add(file); }
@@ -984,55 +893,51 @@
@SuppressWarnings("unchecked") private void setupInputFiles() {
+ if (root.getChild("inputFiles") == null) { + logStream.println("No input files in XML file. Dry run will be peformed."); + this.performDryRun = true; + return; + } +
// Process the <file> elements. List<Element> files = root.getChild("inputFiles").getChildren("file");
- for (Element fileElem : files) - {
+ for (Element fileElem : files) {
processFileElement(fileElem, this.inputFiles); } // Read lists of file locations given by <fileList> elements. List<Element> fileLists = root.getChild("inputFiles").getChildren("fileList");
- for (Element fileList : fileLists) - {
+ for (Element fileList : fileLists) {
String filePath = fileList.getText(); BufferedReader input;
- try - {
+ try {
input = new BufferedReader(new FileReader(new File(filePath)));
- } - catch (FileNotFoundException x)
+ } catch (FileNotFoundException x)
{ throw new RuntimeException("File not found: " + filePath, x); } String line = null;
- try - {
+ try {
// Read the next file, turn the text into an XML element, and process it using common method.
- while (( line = input.readLine()) != null) - {
+ while (( line = input.readLine()) != null) {
processFileText(line.trim(), inputFiles); } }
- catch (IOException x) - {
+ catch (IOException x) {
throw new RuntimeException(x); } } // Process <fileSet> elements. List<Element> fileSets = (List<Element>)root.getChild("inputFiles").getChildren("fileSet");
- for (Element fileSet : fileSets) - {
+ for (Element fileSet : fileSets) {
Attribute basedirAttrib = fileSet.getAttribute("baseDir"); String basedir = "";
- if (basedirAttrib != null) - {
+ if (basedirAttrib != null) {
basedir = basedirAttrib.getValue(); } List<Element> fsFiles = fileSet.getChildren("file");
- for (Element file : fsFiles) - {
+ for (Element file : fsFiles) {
String filePath = basedir + File.separator + file.getText().trim(); processFileText(filePath, inputFiles); }
@@ -1040,35 +945,26 @@
// Read <fileRegExp> elements, which may only reference local files, not URLs. List<Element> fileRegExps = (List<Element>)root.getChild("inputFiles").getChildren("fileRegExp");
- for (Element fileRegExp : fileRegExps) - {
+ for (Element fileRegExp : fileRegExps) {
Pattern pattern = Pattern.compile(fileRegExp.getText()); String basedir = fileRegExp.getAttributeValue("baseDir"); File dir = new File(basedir); if (!dir.isDirectory()) throw new RuntimeException(basedir + " is not a valid directory!"); String dirlist[] = dir.list();
- if (verbose) - {
+ if (verbose) {
logStream.println(); }
- for (String file : dirlist) - { - if (file.endsWith(".slcio")) - {
+ for (String file : dirlist) { + if (file.endsWith(".slcio")) {
Matcher matcher = pattern.matcher(file);
- if (matcher.matches()) - {
+ if (matcher.matches()) {
processFileText(basedir + File.separator + file, inputFiles);
- if (verbose) - {
+ if (verbose) {
logStream.println("Matched file <" + file.toString() + "> to pattern <" + pattern.toString() + ">"); }
- } - else - { - if (verbose) - {
+ } else { + if (verbose) {
logStream.println("Did NOT match file <" + file.toString() + "> to pattern <" + pattern.toString() + ">"); } }
@@ -1076,13 +972,10 @@
} }
- // Check that all the files exist. - if (checkInputFilesExist) - { - for (File file : inputFiles) - { - if (!file.exists()) - {
+ // Check that all the files exist if job is not a dry run. + if (!performDryRun) { + for (File file : inputFiles) { + if (!file.exists()) {
logStream.println("The input file " + file.getAbsolutePath() + " does not exist!"); throw new RuntimeException("The input file " + file.getAbsolutePath() + " does not exist!"); }
@@ -1090,29 +983,31 @@
} // Print out the input file list.
- if (printInputFiles) - {
+ if (printInputFiles) {
logStream.println(); logStream.println("--- Input Files ---"); int index = 1;
- for (File file : inputFiles) - {
+ for (File file : inputFiles) {
logStream.println("[" + index + "] " + file.getAbsolutePath()); ++index; } logStream.println("--- End Input Files ---"); logStream.println();
- }
+ } + + if (inputFiles.size() == 0) { + logStream.println("No input files were found. Job mode will be dry run."); + this.performDryRun = true; + }
} /** * Set logging verbosity. * @param verbose True to turn on verbose mode; false to turn on quiet mode. */
- private void setVerbose(boolean verbose) - {
+ private void setVerbose(boolean verbose) {
this.verbose = verbose; this.printInputFiles = verbose; this.printDriversDetailed = verbose;
@@ -1125,8 +1020,8 @@
/** * Setup the job control parameters using the XML steering document. */
- private void setupJobControlParameters() - {
+ private void setupJobControlParameters() { +
Element control = root.getChild("control"); if (control == null)
@@ -1134,8 +1029,7 @@
// Verbose mode. Element verboseElement = control.getChild("verbose");
- if (verboseElement != null) - {
+ if (verboseElement != null) {
verbose = Boolean.valueOf(verboseElement.getText()); setVerbose(verbose); }
@@ -1143,12 +1037,10 @@
// Log file setup needs to come first.[truncated at 1000 lines; 381 more skipped]
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1