You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by bu...@apache.org on 2015/02/28 00:43:47 UTC
svn commit: r1662857 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli:
CliBase.java CommandLine.java DuccJobSubmit.java
Author: burn
Date: Fri Feb 27 23:43:47 2015
New Revision: 1662857
URL: http://svn.apache.org/r1662857
Log:
UIMA-4268 Reject job if DD specified along with a CM, AE, or CC ... or if none specified
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CliBase.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CommandLine.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CliBase.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CliBase.java?rev=1662857&r1=1662856&r2=1662857&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CliBase.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CliBase.java Fri Feb 27 23:43:47 2015
@@ -57,8 +57,6 @@ public abstract class CliBase
protected String ducc_home;
protected IDuccEventDispatcher dispatcher;
- //protected Options cliOptions;
- //protected Parser parser;
protected CommandLine commandLine;
protected long friendlyId = -1;
@@ -84,9 +82,6 @@ public abstract class CliBase
protected Properties userSpecifiedProperties;
- // Options added to the saved spec file that must be removed if used as a --specification option
- //private List<UiOption> addedOptions = Arrays.asList(UiOption.SubmitPid, UiOption.User);
-
/**
* All extenders must implement execute - this method does whatever processing on the input
* is needed and passes the CLI request to the internal DUCC processes.
@@ -209,26 +204,6 @@ public abstract class CliBase
}
}
-// /*
-// * Also used by DuccMonitor
-// */
-// static public Options makeOptions(UiOption[] optlist)
-// {
-// Options opts = new Options();
-// for ( UiOption opt : optlist ) {
-// String arg = opt.argname();
-// Option o = new Option(opt.sname(), opt.pname(), (arg != null), opt.makeDesc());
-// o.setArgName(arg);
-// o.setOptionalArg(arg != null && arg.endsWith("(optional)"));
-// if (opt.multiargs()) {
-// o.setArgs(Option.UNLIMITED_VALUES); // (Untested as we have no multiarg options)
-// }
-// opts.addOption(o);
-// // Note: avoid OptionBuilder as is not thread-safe
-// }
-// return opts;
-// }
-
protected String[] mkArgs(Properties props)
{
List<String> arglist = new ArrayList<String>();
@@ -313,18 +288,6 @@ public abstract class CliBase
usage(e.getMessage());
}
- // cliOptions = makeOptions(uiOpts);
- // If given only a properties file parse as if only have defaults
-// if (args == null) {
-// // strings, uioptions, proerties
-// commandLine.parse(null, uiOpts, props);
-// } else {
-// fixupQuotedArgs(args);
-// commandLine = parser.parse(cliOptions, args);
-// }
-// if (commandLine.getOptions().length == 0 || commandLine.hasOption(UiOption.Help.pname())) {
-// usage(null);
-// }
if ( commandLine.contains(UiOption.Help)) {
usage(null);
}
@@ -352,9 +315,6 @@ public abstract class CliBase
fis.close();
CliFixups.cleanupProps(defaults, myClassName); // By default does nothing
- // No longer needed we believe
- // sanitize(defaults, commandLine); // Check for illegals as commons cli 1.2 throws a NPE !
-
// If invoked with overriding properties add to or replace the defaults
if (props != null) {
defaults.putAll(props);
@@ -364,13 +324,6 @@ public abstract class CliBase
}
commandLine.verify(); // Insure all the rules specified by the IUiOpts are enforced
- // Check if any orphaned args left
- // new CommandLine parser will throw IllegalArgumentException if this happens
-// List<?> extraArgs = commandLine.getArgList();
-// if (extraArgs.size() > 0) {
-// throw new ParseException("Superfluous arguments provided (perhaps quotes omitted?): " + extraArgs);
-// }
-
// Copy options into cli_props
setOptions(uiOpts);
@@ -426,21 +379,10 @@ public abstract class CliBase
if (val.contains("${")) {
val = resolvePlaceholders(val);
}
- // no need to check for dups, the parser does this
-// String oval = (String) cli_props.get(opt.getLongOpt());
-// if (oval != null && !oval.equals(val)) {
-// throw new Exception("Duplicate option specified: " + opt.getLongOpt());
-// }
}
val = val.trim();
- // SM cannot handle an empty list of service dependencies
- // new parser: ServiceDependency configured to require an argument.
-// if (val.length() == 0 && opt.getLongOpt().equals(UiOption.ServiceDependency.pname())) {
-// if (debug) System.out.println("CLI dropped empty option " + opt.getLongOpt());
-// } else {
- cli_props.put(opt.pname(), val);
- if (debug) System.out.println("CLI set " + opt.pname() + " = '" + val + "'");
- //}
+ cli_props.put(opt.pname(), val);
+ if (debug) System.out.println("CLI set " + opt.pname() + " = '" + val + "'");
}
}
@@ -492,50 +434,6 @@ public abstract class CliBase
}
/*
- * Clean up the properties in a specification file
- * Remove any added by the CLI that the parse would call illegal
- * Check for invalid options as Commons CLI 1.2 throws a NPE
- * Correct booleans by treating empty as "true" and removing anything
- * other than 'true' or 'yes' or '1' (CLI 1.2 mishandles others)
- */
-
- /*
- * Notes for removal of commons.cli:
- * - Do not need to check for invalid options, the parser does that and throws
- * - Do not need to deal with missing boolean for no-opt parms, the parsesr does that
- * What's left? Removing stuff like 'user' and 'pid' if you're reusing a
- * previously-submitted properties file. We probably don't need this either.
- *
- * Consulting Burn, it appears we probably don't need sanitize.
-
- * So for now I'll just remove it and see what happens,
- */
- // private void sanitize(Properties props, Options opts) {
- // CliFixups.cleanupProps(props, myClassName); // By default does nothing
- // for (String key : props.stringPropertyNames()) {
- // if (addedOptions.contains(key)) {
- // props.remove(key);
- // } else {
- // Option opt = cliOptions.getOption(key);
- // if (opt == null) {
- // throw new IllegalArgumentException("Invalid option '" + key + "' in specification file");
- // }
- // if (!opt.hasArg()) {
- // String val = props.getProperty(key);
- // if (val.length() == 0) {
- // props.setProperty(key, "true");
- // } else if (!val.equalsIgnoreCase("true") &&
- // !val.equalsIgnoreCase("yes") &&
- // !val.equals("1")) {
- // message("WARN: Ignoring illegal value: ", key, "=", val);
- // props.remove(key);
- // }
- // }
- // }
- // }
- // }
-
- /*
* Resolve any ${..} placeholders against user's system properties and environment
*/
private String resolvePlaceholders(String contents) {
@@ -675,15 +573,6 @@ public abstract class CliBase
return true;
}
- /**
- * Return internal API debug status.
- * @return True if the API debugging flag is set; false otherwise.
- */
-/* public boolean isDebug()
- {
- return debug;
- }*/
-
protected IDuccCallback getCallback()
{
return consoleCb;
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CommandLine.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CommandLine.java?rev=1662857&r1=1662856&r2=1662857&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CommandLine.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/CommandLine.java Fri Feb 27 23:43:47 2015
@@ -78,7 +78,7 @@ public class CommandLine
}
/**
- * Returns whether the parsesd command line contained the specified option (by IUiOption).
+ * Returns whether the parsed command line contained the specified option (by IUiOption).
*
* @param opt This is the option to test for.
*
@@ -91,7 +91,7 @@ public class CommandLine
}
/**
- * Returns whether the parsesd command line contained the specified option (by string name).
+ * Returns whether the parsed command line contained the specified option (by string name).
*
* @param opt This is the option to test for.
*
@@ -135,7 +135,7 @@ public class CommandLine
public String get(IUiOption k)
throws IllegalArgumentException
{
- // what was the parsesd value of this opt
+ // what was the parsed value of this opt
if ( legal_options.containsKey(k) ) {
return option_to_value.get(k);
}
@@ -449,7 +449,7 @@ public class CommandLine
} else if ( args[i].startsWith("-") ) {
k = args[i].substring(1);
} else {
- throw new IllegalArgumentException("Unrecognized keywoard: " + args[i]);
+ throw new IllegalArgumentException("Unrecognized keyword: " + args[i]);
}
IUiOption opt = name_to_option.get(k);
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java?rev=1662857&r1=1662856&r2=1662857&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java Fri Feb 27 23:43:47 2015
@@ -151,6 +151,7 @@ public class DuccJobSubmit
throws Exception
{
init (this.getClass().getName(), opts, args, jobRequestProperties, consoleCb);
+ check_descriptor_options();
if(isAllInOne()) {
allInOneLauncher = new AllInOneLauncher(args, consoleCb);
}
@@ -169,6 +170,7 @@ public class DuccJobSubmit
throws Exception
{
init (this.getClass().getName(), opts, props, jobRequestProperties, consoleCb);
+ check_descriptor_options();
if(isAllInOne()) {
String[] args = mkArgs(props);
allInOneLauncher = new AllInOneLauncher(args, consoleCb);
@@ -201,6 +203,19 @@ public class DuccJobSubmit
}
}
+ private void check_descriptor_options() {
+ boolean isDDjob = jobRequestProperties.containsKey(UiOption.ProcessDD.pname());
+ boolean isPPjob = jobRequestProperties.containsKey(UiOption.ProcessDescriptorCM.pname())
+ || jobRequestProperties.containsKey(UiOption.ProcessDescriptorAE.pname())
+ || jobRequestProperties.containsKey(UiOption.ProcessDescriptorCC.pname());
+ if (isDDjob && isPPjob) {
+ throw new IllegalArgumentException("--process_descriptor_DD is mutually exclusive with the AE, CC, & CM descriptor options");
+ }
+ if (!isDDjob && !isPPjob) {
+ throw new IllegalArgumentException("Missing --process_descriptor_xx option .. DD or at least one of AE, CC, CM required");
+ }
+ }
+
private void set_debug_parms(Properties props, String key, int port)
{
String debug_jvmargs = "-Xdebug -Xrunjdwp:transport=dt_socket,address=" + host_address + ":" + port;