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 2013/05/09 00:56:37 UTC
svn commit: r1480496 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli:
DuccJobSubmit.java DuccMonitor.java IUiOptions.java aio/AllInOneLauncher.java
Author: burn
Date: Wed May 8 22:56:36 2013
New Revision: 1480496
URL: http://svn.apache.org/r1480496
Log:
UIMA-2879 Support debugging & callbacks & classpath-order in all-in-one
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccMonitor.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOneLauncher.java
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=1480496&r1=1480495&r2=1480496&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 Wed May 8 22:56:36 2013
@@ -161,45 +161,24 @@ public class DuccJobSubmit
throws Exception
{
this(args, null);
- if(isAllInOne()) {
- String[] aioArgs = args.toArray(new String[0]);
- allInOneLauncher = new AllInOneLauncher(aioArgs);
- }
}
public DuccJobSubmit(String[] args)
throws Exception
{
this(args, null);
- if(isAllInOne()) {
- String[] aioArgs = args;
- allInOneLauncher = new AllInOneLauncher(aioArgs);
- }
}
public DuccJobSubmit(Properties props)
throws Exception
{
this(props, null);
- if(isAllInOne()) {
- String[] aioArgs = mkArgs(props);
- allInOneLauncher = new AllInOneLauncher(aioArgs);
- }
}
public DuccJobSubmit(ArrayList<String> args, IDuccCallback consoleCb)
throws Exception
{
- String[] arg_array = args.toArray(new String[args.size()]);
- init();
- if(DuccUiUtilities.isSupportedBeta()) {
- opts = opts_beta;
- }
- init(this.getClass().getName(), opts, arg_array, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
- if(isAllInOne()) {
- String[] aioArgs = args.toArray(new String[0]);
- allInOneLauncher = new AllInOneLauncher(aioArgs, consoleCb);
- }
+ this(args.toArray(new String[args.size()]), consoleCb);
}
public DuccJobSubmit(String[] args, IDuccCallback consoleCb)
@@ -207,12 +186,11 @@ public class DuccJobSubmit
{
init();
if(DuccUiUtilities.isSupportedBeta()) {
- opts = opts_beta;
+ opts = opts_beta;
}
init(this.getClass().getName(), opts, args, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
if(isAllInOne()) {
- String[] aioArgs = args;
- allInOneLauncher = new AllInOneLauncher(aioArgs, consoleCb);
+ allInOneLauncher = new AllInOneLauncher(args, consoleCb);
}
}
@@ -229,8 +207,8 @@ public class DuccJobSubmit
}
init(this.getClass().getName(), opts, null, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
if(isAllInOne()) {
- String[] aioArgs = mkArgs(props);
- allInOneLauncher = new AllInOneLauncher(aioArgs, consoleCb);
+ String[] args = mkArgs(props);
+ allInOneLauncher = new AllInOneLauncher(args, consoleCb);
}
}
@@ -410,19 +388,9 @@ public class DuccJobSubmit
//**********
public boolean execute() throws Exception {
- if(isAllInOne()) {
- return execute_aio();
+ if(allInOneLauncher != null) {
+ return allInOneLauncher.execute();
}
- return execute_job();
- }
-
- private boolean execute_aio() throws Exception {
- return allInOneLauncher.execute();
- }
-
- private boolean execute_job()
- throws Exception
- {
try {
enrich_parameters_for_debug(jobRequestProperties);
@@ -580,36 +548,35 @@ public class DuccJobSubmit
return rc;
}
- private boolean isAllInOne() {
- return jobRequestProperties.containsKey(UiOption.AllInOne.pname());
+ /*
+ * Return appropriate rc when job has completed
+ */
+ public int getReturnCode() {
+ if (allInOneLauncher != null) {
+ return allInOneLauncher.getReturnCode();
+ }
+ return super.getReturnCode();
}
- private static void main_job(String[] args, DuccJobSubmit ds) throws Exception {
- boolean rc = ds.execute();
- // If the return is 'true' then as best the API can tell, the submit worked
- if ( rc ) {
- System.out.println("Job " + ds.getDuccId() + " submitted");
- int exit_code = ds.getReturnCode(); // after waiting if requested
- System.exit(exit_code);
- } else {
- System.out.println("Could not submit job");
- System.exit(1);
- }
- }
-
- private static void main_aio(String[] args) throws Exception {
- AllInOneLauncher main_allInOneLauncher = new AllInOneLauncher(args);
- main_allInOneLauncher.execute();
+ private boolean isAllInOne() {
+ return jobRequestProperties.containsKey(UiOption.AllInOne.pname());
}
-
+
+ /*
+ * Main methid
+ */
public static void main(String[] args) {
try {
DuccJobSubmit ds = new DuccJobSubmit(args, null);
- if(ds.isAllInOne()) {
- main_aio(args);
- }
- else {
- main_job(args, ds);
+ boolean rc = ds.execute();
+ // If the return is 'true' then as best the API can tell, the submit worked
+ if ( rc ) {
+ System.out.println("Job " + ds.getDuccId() + " submitted");
+ int exit_code = ds.getReturnCode(); // after waiting if requested
+ System.exit(exit_code);
+ } else {
+ System.out.println("Could not submit job");
+ System.exit(1);
}
}
catch(Exception e) {
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccMonitor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccMonitor.java?rev=1480496&r1=1480495&r2=1480496&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccMonitor.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccMonitor.java Wed May 8 22:56:36 2013
@@ -403,56 +403,35 @@ public abstract class DuccMonitor {
info(thisMessage);
lastMessage = thisMessage;
}
- if(state.equals(StateCompleted)) {
- if(monitorInfo.procs.equals("0")) {
- if(monitorInfo.total.equals(monitorInfo.done)) {
- if(monitorInfo.code.equals("0")) {
- message = new StringBuffer();
- message.append("id:"+id);
- message.append(" ");
- message.append("code:"+monitorInfo.code);
- thisMessage = message.toString();
- info(thisMessage);
- message = new StringBuffer();
- message.append("id:"+id);
- message.append(" ");
- message.append("rc:"+RC_SUCCESS);
- thisMessage = message.toString();
- info(thisMessage);
- return RC_SUCCESS;
- }
- else {
- message = new StringBuffer();
- message.append("id:"+id);
- message.append(" ");
- message.append("code:"+monitorInfo.code);
- thisMessage = message.toString();
- info(thisMessage);
- message = new StringBuffer();
- message.append("id:"+id);
- message.append(" ");
- message.append("rc:"+RC_FAILURE);
- thisMessage = message.toString();
- info(thisMessage);
- return RC_FAILURE;
- }
- }
- else {
+ if (state.equals(StateCompleted)) {
+ if (monitorInfo.procs.equals("0")) {
+ if (monitorInfo.total.equals(monitorInfo.done)) {
+ int rc = RC_FAILURE;
+ message = new StringBuffer();
+ message.append("id:" + id);
+ try {
+ rc = Integer.parseInt(monitorInfo.code);
+ message.append(" rc:" + rc);
+ } catch (NumberFormatException e) {
+ message.append(" code:" + monitorInfo.code);
+ }
+ thisMessage = message.toString();
+ info(thisMessage);
+ return rc;
+ } else {
if(!monitorInfo.errorLogs.isEmpty()) {
message = new StringBuffer();
message.append("id:"+id);
- message.append(" ");
ArrayList<String> errorLogs = monitorInfo.errorLogs;
for(String errorLog : errorLogs) {
- message.append("file:"+errorLog);
+ message.append(" file:"+errorLog);
}
thisMessage = message.toString();
info(thisMessage);
}
message = new StringBuffer();
message.append("id:"+id);
- message.append(" ");
- message.append("rc:"+RC_FAILURE);
+ message.append(" rc:"+RC_FAILURE);
thisMessage = message.toString();
info(thisMessage);
return RC_FAILURE;
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java?rev=1480496&r1=1480495&r2=1480496&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java Wed May 8 22:56:36 2013
@@ -813,7 +813,7 @@ public interface IUiOptions
public String deflt() { return null; }
public String label() { return "SchedulingClass"; }
public boolean multiargs() { return false; }
- public boolean required() { return true; }
+ public boolean required() { return false; }
},
ServiceLinger {
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOneLauncher.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOneLauncher.java?rev=1480496&r1=1480495&r2=1480496&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOneLauncher.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOneLauncher.java Wed May 8 22:56:36 2013
@@ -1,5 +1,5 @@
/*
-as * Licensed to the Apache Software Foundation (ASF) under one
+ * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@@ -35,6 +35,7 @@ import org.apache.uima.ducc.cli.DuccMana
import org.apache.uima.ducc.cli.IDuccCallback;
import org.apache.uima.ducc.cli.aio.IMessageHandler.Level;
import org.apache.uima.ducc.cli.aio.IMessageHandler.Toggle;
+import org.apache.uima.ducc.common.utils.DuccPropertiesResolver;
import org.apache.uima.ducc.common.utils.DuccSchedulerClasses;
import org.apache.uima.ducc.transport.event.cli.JobRequestProperties;
@@ -53,8 +54,6 @@ public class AllInOneLauncher extends Cl
private String allInOneType = null;
- private String attach_console = null;
-
private String jvm = null;
private String log_directory = null;
private String working_directory = null;
@@ -63,6 +62,7 @@ public class AllInOneLauncher extends Cl
private String environment = null;
private String process_jvm_args = null;
+ private String debug_jvm_args = null;
private String driver_descriptor_CR = null;
private String driver_descriptor_CR_overrides = null;
@@ -101,10 +101,12 @@ public class AllInOneLauncher extends Cl
private UiOption[] opts = DuccJobSubmit.opts;
private HashMap<String,String> optionsMap = new HashMap<String,String>();
+
+
public AllInOneLauncher(String[] args) throws Exception {
this.args = args;
- init(this.getClass().getName(), opts, args, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
+ init(this.getClass().getName(), opts, args, jobRequestProperties, or_host, or_port, "or", null, null);
}
public AllInOneLauncher(String[] args, IDuccCallback consoleCb) throws Exception {
@@ -112,7 +114,7 @@ public class AllInOneLauncher extends Cl
mh = new MessageHandler(consoleCb);
init(this.getClass().getName(), opts, args, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
}
-
+
private boolean isLocal() {
return allInOneType.equalsIgnoreCase(local);
}
@@ -170,15 +172,11 @@ public class AllInOneLauncher extends Cl
private void examine_process_debug() {
String mid = "examine_process_debug";
mh.frameworkTrace(cid, mid, enter);
- if(jobRequestProperties.containsKey(UiOption.Debug.pname())) {
- return;
- }
String pname = UiOption.ProcessDebug.pname();
- debug = jobRequestProperties.containsKey(pname);
- if(debug) {
- enableDebugFlags();
- String message = "true";
- mh.frameworkDebug(cid, mid, message);
+ if (jobRequestProperties.containsKey(pname)) {
+ int port = Integer.parseInt(jobRequestProperties.getProperty(pname));
+ debug_jvm_args = " -Xdebug -Xrunjdwp:transport=dt_socket,address=" + host_address + ":" + port;
+ mh.frameworkDebug(cid, mid, debug_jvm_args);
used(pname);
}
mh.frameworkTrace(cid, mid, exit);
@@ -239,8 +237,7 @@ public class AllInOneLauncher extends Cl
mh.frameworkTrace(cid, mid, enter);
String pname = UiOption.ProcessAttachConsole.pname();
if(jobRequestProperties.containsKey(pname)) {
- attach_console = jobRequestProperties.getProperty(pname);
- String message = attach_console;
+ String message = "attach_console";
mh.frameworkDebug(cid, mid, message);
used(pname);
}
@@ -311,9 +308,14 @@ public class AllInOneLauncher extends Cl
String pname = UiOption.ProcessJvmArgs.pname();
if(jobRequestProperties.containsKey(pname)) {
process_jvm_args = jobRequestProperties.getProperty(pname);
+ if (debug_jvm_args != null) {
+ process_jvm_args += debug_jvm_args;
+ }
String message = process_jvm_args;
mh.frameworkDebug(cid, mid, message);
used(pname);
+ } else {
+ process_jvm_args = debug_jvm_args;
}
mh.frameworkTrace(cid, mid, exit);
}
@@ -325,83 +327,50 @@ public class AllInOneLauncher extends Cl
mh.frameworkTrace(cid, mid, exit);
}
- private void examine_classpath() {
+ private void examine_classpath() throws IOException {
String mid = "examine_classpath";
mh.frameworkTrace(cid, mid, enter);
String pname = UiOption.Classpath.pname();
- if(jobRequestProperties.containsKey(pname)) {
+ if (jobRequestProperties.containsKey(pname)) {
classpath = jobRequestProperties.getProperty(pname);
- String message = classpath;
- mh.frameworkDebug(cid, mid, message);
used(pname);
- }
- mh.frameworkTrace(cid, mid, exit);
- }
-
- private void examine_process_classpath() {
- String mid = "examine_process_classpath";
- mh.frameworkTrace(cid, mid, enter);
- if(jobRequestProperties.containsKey(UiOption.Classpath.pname())) {
- return;
- }
- String pname = UiOption.ProcessClasspath.pname();
- if(jobRequestProperties.containsKey(pname)) {
- classpath = jobRequestProperties.getProperty(pname);
- String message = classpath;
- mh.frameworkDebug(cid, mid, message);
- used(pname);
- }
- mh.frameworkTrace(cid, mid, exit);
- }
-
- private void examine_driver_classpath() {
- String mid = "examine_driver_classpath";
- mh.frameworkTrace(cid, mid, enter);
- // ignored
- mh.frameworkTrace(cid, mid, exit);
- }
-
- private void examine_classpath_order() {
- String mid = "examine_classpath_order";
- String pname = UiOption.ClasspathOrder.pname();
- if(jobRequestProperties.containsKey(pname)) {
- String value = jobRequestProperties.getProperty(pname);
- if(value != null) {
- if(value.equalsIgnoreCase(ClasspathOrderParms.UserBeforeDucc.name())) {
- classpath_user_first = true;
- }
- else if(value.equalsIgnoreCase(ClasspathOrderParms.DuccBeforeUser.name())) {
- classpath_user_first = false;
- }
- else {
- throw new IllegalArgumentException(UiOption.ClasspathOrder.pname()+": "+value);
- }
+ } else {
+ pname = UiOption.ProcessClasspath.pname();
+ if (jobRequestProperties.containsKey(pname)) {
+ classpath = jobRequestProperties.getProperty(pname);
+ used(pname);
+ } else {
+ classpath = System.getProperty("java.class.path");
}
- String message = value;
- mh.frameworkDebug(cid, mid, message);
- used(pname);
}
- }
-
- private void reconcile_classpath() {
- String mid = "reconcile_classpath";
- if(classpath != null) {
- if(classpath_user_first) {
- classpath = System.getProperty("java.class.path")+File.pathSeparatorChar+classpath;
- String message = "user first";
- mh.frameworkInfo(cid, mid, message);
- }
- else {
- classpath = classpath+File.pathSeparatorChar+System.getProperty("java.class.path");
- String message = "user last";
- mh.frameworkInfo(cid, mid, message);
- }
+ String message = classpath;
+ mh.frameworkDebug(cid, mid, message);
+
+ pname = UiOption.ClasspathOrder.pname();
+ String value;
+ if (jobRequestProperties.containsKey(pname)) {
+ value = jobRequestProperties.getProperty(pname);
+ used(pname);
+ } else {
+ value = DuccPropertiesResolver.getInstance().getProperty(DuccPropertiesResolver.ducc_orchestrator_job_factory_classpath_order);
+ }
+ if (ClasspathOrderParms.UserBeforeDucc.pname().equalsIgnoreCase(value)) {
+ classpath_user_first = true;
+ } else if (ClasspathOrderParms.DuccBeforeUser.pname().equalsIgnoreCase(value)) {
+ classpath_user_first = false;
+ } else {
+ throw new IllegalArgumentException(UiOption.ClasspathOrder.pname()+": "+value);
}
- else {
- classpath = System.getProperty("java.class.path");
- String message = "user only";
- mh.frameworkInfo(cid, mid, message);
+ message = value;
+ mh.frameworkDebug(cid, mid, message);
+
+ String duccClasspath = getDuccClasspath();
+ if (classpath_user_first) {
+ classpath = classpath + File.pathSeparatorChar + duccClasspath;
+ } else {
+ classpath = duccClasspath + File.pathSeparatorChar + classpath;
}
+ mh.frameworkTrace(cid, mid, exit);
}
private void examine_environment() {
@@ -457,67 +426,30 @@ public class AllInOneLauncher extends Cl
String mid = "examine_scheduling_class";
mh.frameworkTrace(cid, mid, enter);
String pname = UiOption.SchedulingClass.pname();
- if(isLocal()) {
- String message = pname+"="+scheduling_class+" not considered";
- mh.frameworkDebug(cid, mid, message);
- used(pname);
- }
- else {
- String user_scheduling_class = jobRequestProperties.getProperty(pname);
- if(user_scheduling_class == null) {
- throw new MissingArgumentException(pname);
- }
+ if (jobRequestProperties.containsKey(pname)) {
DuccSchedulerClasses duccSchedulerClasses = DuccSchedulerClasses.getInstance();
- if(duccSchedulerClasses.isPreemptable(user_scheduling_class)) {
- String default_scheduling_class = duccSchedulerClasses.getDebugClassDefaultName();
- String specific_scheduling_class = duccSchedulerClasses.getDebugClassSpecificName(user_scheduling_class);
- if(specific_scheduling_class != null) {
+ scheduling_class = jobRequestProperties.getProperty(pname);
+ String message = pname + "=" + scheduling_class + " [original]";
+ if (isLocal()) {
+ message = pname + "=" + scheduling_class + " not considered";
+ } else if (duccSchedulerClasses.isPreemptable(scheduling_class)) {
+ String specific_scheduling_class = duccSchedulerClasses.getDebugClassSpecificName(scheduling_class);
+ if (specific_scheduling_class != null) {
scheduling_class = specific_scheduling_class;
- String message = pname+"="+scheduling_class+" [replacement, specific]";
- mh.frameworkDebug(cid, mid, message);
- used(pname);
- }
- else if(default_scheduling_class != null) {
- scheduling_class = default_scheduling_class;
- String message = pname+"="+scheduling_class+" [replacement, default]";
- mh.frameworkDebug(cid, mid, message);
- used(pname);
- }
- else {
- scheduling_class = user_scheduling_class;
- String message = pname+"="+scheduling_class+" [original]";
- mh.frameworkDebug(cid, mid, message);
- used(pname);
+ message = pname + "=" + scheduling_class + " [replacement, specific]";
+ } else {
+ String default_scheduling_class = duccSchedulerClasses.getDebugClassDefaultName();
+ if (default_scheduling_class != null) {
+ scheduling_class = default_scheduling_class;
+ message = pname + "=" + scheduling_class + " [replacement, default]";
+ }
}
}
- }
- mh.frameworkTrace(cid, mid, exit);
- }
-
- /*
- private void examine_scheduling_class() {
- String mid = "examine_scheduling_class";
- mh.frameworkTrace(cid, mid, enter);
- String pname = UiOption.SchedulingClass.pname();
- if(isLocal()) {
- String message = pname+"="+scheduling_class;
mh.frameworkDebug(cid, mid, message);
used(pname);
}
- else if(jobRequestProperties.containsKey(pname)) {
- String user_scheduling_class = jobRequestProperties.getProperty(pname);
- String message = pname+"="+scheduling_class;
- if(user_scheduling_class == null) {
- }
- else if(!user_scheduling_class.trim().equals(scheduling_class)) {
- message = pname+"="+scheduling_class+" "+"replaces"+" "+user_scheduling_class;
- }
- mh.frameworkInfo(cid, mid, message);
- used(pname);
- }
mh.frameworkTrace(cid, mid, exit);
}
- */
private void examine_process_deployments_max() {
String mid = "examine_process_deployments_max";
@@ -849,7 +781,7 @@ public class AllInOneLauncher extends Cl
}
}
- private void examine() throws MissingArgumentException, IllegalArgumentException {
+ private void examine() throws MissingArgumentException, IllegalArgumentException, IOException {
String mid = "examine";
mh.frameworkTrace(cid, mid, "enter");
@@ -883,10 +815,6 @@ public class AllInOneLauncher extends Cl
// classpath
examine_classpath();
- examine_process_classpath();
- examine_driver_classpath();
- examine_classpath_order();
- reconcile_classpath();
// environment
examine_environment();
@@ -949,6 +877,16 @@ public class AllInOneLauncher extends Cl
mh.frameworkTrace(cid, mid, "exit");
}
+ private String getDuccClasspath() throws IOException {
+ StringBuilder sb = new StringBuilder();
+ File uimalib = new File(ducc_home + "/lib/uima");
+ for (File f : uimalib.listFiles()) {
+ sb.append(File.pathSeparator);
+ sb.append(f.getCanonicalPath());
+ }
+ return sb.substring(2);
+ }
+
private void launch_local() throws IOException {
String mid = "launch_local";
mh.frameworkTrace(cid, mid, "enter");
@@ -976,7 +914,6 @@ public class AllInOneLauncher extends Cl
}
}
- //commandArray.add("org.apache.uima.ducc.cli.aio.AllInOne");
commandArray.add(AllInOne.class.getCanonicalName());
for(String arg : args) {
@@ -1011,7 +948,7 @@ public class AllInOneLauncher extends Cl
env.put(name, value);
}
}
-
+ pb.redirectErrorStream(true);
Process process = pb.start();
String line;
@@ -1020,26 +957,14 @@ public class AllInOneLauncher extends Cl
InputStreamReader isr = new InputStreamReader(is);
BufferedReader ibr = new BufferedReader(isr);
while ((line = ibr.readLine()) != null) {
- if(consoleCb != null) {
- consoleCb.status(line);
- }
- else {
- System.out.println(line);
- }
+ consoleCb.status(line);
}
-
- InputStream es = process.getErrorStream();
- InputStreamReader esr = new InputStreamReader(es);
- BufferedReader ebr = new BufferedReader(esr);
- while ((line = ebr.readLine()) != null) {
- if(consoleCb != null) {
- consoleCb.status(line);
- }
- else {
- System.err.println(line);
- }
+ ibr.close();
+ try {
+ returnCode = process.waitFor();
+ } catch (InterruptedException e) {
}
-
+
mh.frameworkTrace(cid, mid, "exit");
}
@@ -1060,54 +985,45 @@ public class AllInOneLauncher extends Cl
return sb.toString();
}
+ /*
+ * Options that AllInOne needs
+ */
+ UiOption[] allInOneOpts = {
+ UiOption.Debug,
+ UiOption.Timestamp,
+ UiOption.DriverDescriptorCR,
+ UiOption.DriverDescriptorCROverrides,
+ UiOption.ProcessDD,
+ UiOption.ProcessDescriptorCM,
+ UiOption.ProcessDescriptorCMOverrides,
+ UiOption.ProcessDescriptorAE,
+ UiOption.ProcessDescriptorAEOverrides,
+ UiOption.ProcessDescriptorCC,
+ UiOption.ProcessDescriptorCCOverrides };
+
+ /*
+ * Create a string hold the args for the java command.
+ * If any values contain blanks they would have to be quoted, instead restrict the args
+ * to just those needed to run the pipeline.
+ */
private String getProcessExecutableArgs() {
String mid = "getProcessExecutableArgs";
mh.frameworkTrace(cid, mid, "enter");
StringBuffer sb = new StringBuffer();
if(process_jvm_args != null) {
sb.append(process_jvm_args);
- sb.append(" ");
}
- sb.append("-classpath");
+ sb.append(" -classpath");
sb.append(" ");
sb.append(classpath);
sb.append(" ");
- sb.append(this.getClass().getCanonicalName());
+ sb.append(AllInOne.class.getCanonicalName());
sb.append(" ");
- boolean skipNext = false;
- for(String arg : args) {
- if(skipNext) {
- skipNext = false;
- }
- else if(arg.trim().equalsIgnoreCase("--"+UiOption.AllInOne.pname())) {
- skipNext = true;
- sb.append(arg);
- sb.append(" ");
- sb.append(local);
- sb.append(" ");
- }
- else if(arg.trim().equalsIgnoreCase("--"+UiOption.DriverClasspath.pname())) {
- skipNext = true;
- }
- else if(arg.trim().equalsIgnoreCase("--"+UiOption.ProcessClasspath.pname())) {
- skipNext = true;
- }
- else if(arg.trim().equalsIgnoreCase("--"+UiOption.Classpath.pname())) {
- skipNext = true;
- }
- else if(arg.trim().equalsIgnoreCase("--"+UiOption.DriverEnvironment.pname())) {
- skipNext = true;
- }
- else if(arg.trim().equalsIgnoreCase("--"+UiOption.ProcessEnvironment.pname())) {
- skipNext = true;
- }
- else if(arg.trim().equalsIgnoreCase("--"+UiOption.Environment.pname())) {
- skipNext = true;
- }
- else {
- sb.append(arg);
- sb.append(" ");
- }
+ for (UiOption opt : allInOneOpts) {
+ String val = jobRequestProperties.getProperty(opt.pname());
+ if (val != null) {
+ sb.append(" --" + opt.pname() + " " + val);
+ }
}
mh.frameworkTrace(cid, mid, "exit");
return sb.toString();
@@ -1121,11 +1037,9 @@ public class AllInOneLauncher extends Cl
addArg(cmdLine, getProcessExecutable());
addArg(cmdLine, "--"+UiOption.ProcessExecutableArgs.pname());
addArg(cmdLine, getProcessExecutableArgs());
- addArg(cmdLine, "--"+UiOption.SchedulingClass.pname());
- addArg(cmdLine, scheduling_class);
- if(attach_console != null) {
- addArg(cmdLine, "--"+UiOption.ProcessAttachConsole.pname());
- addArg(cmdLine, attach_console);
+ if(scheduling_class != null) {
+ addArg(cmdLine, "--"+UiOption.SchedulingClass.pname());
+ addArg(cmdLine, scheduling_class);
}
if(environment != null) {
addArg(cmdLine, "--"+UiOption.Environment.pname());
@@ -1149,44 +1063,27 @@ public class AllInOneLauncher extends Cl
}
if(wait_for_completion) {
addArg(cmdLine, "--"+UiOption.WaitForCompletion.pname());
- addArg(cmdLine, "true");
}
if(cancel_on_interrupt) {
addArg(cmdLine, "--"+UiOption.CancelOnInterrupt.pname());
- addArg(cmdLine, "true");
- }
- String[] argList = cmdLine.toArray(new String[0]);
- DuccManagedReservationSubmit mr = null;
- if(consoleCb != null) {
- mr = new DuccManagedReservationSubmit(argList, consoleCb);
- }
- else {
- mr = new DuccManagedReservationSubmit(argList, consoleCb);
}
+ addArg(cmdLine, "--"+UiOption.ProcessAttachConsole.pname()); // Always return console output to match "local"
+
+ String[] argList = cmdLine.toArray(new String[cmdLine.size()]);
+
+ DuccManagedReservationSubmit mr = new DuccManagedReservationSubmit(argList, consoleCb);
boolean rc = mr.execute();
String dt = "Managed Reservation";
if (rc) {
String line = dt + " " + mr.getDuccId() + " submitted.";
- if(consoleCb != null) {
- consoleCb.status(line);
- }
- else {
- System.out.println(line);
- }
- int code = mr.getReturnCode();
- System.exit(code);
+ consoleCb.status(line);
+ returnCode = mr.getReturnCode();
}
else {
String line = "Could not submit " + dt;
- if(consoleCb != null) {
- consoleCb.status(line);
- }
- else {
- System.out.println(line);
- }
- System.exit(1);
+ consoleCb.status(line);
}
mh.frameworkDebug(cid, mid, "rc="+rc);
@@ -1210,21 +1107,23 @@ public class AllInOneLauncher extends Cl
}
public boolean execute() throws Exception {
- go();
- return true;
- }
-
- protected void go() throws Exception {
- String mid = "go";
+ String mid = "execute";
mh.frameworkTrace(cid, mid, "enter");
examine();
+ returnCode = -1; // Some "failure" value in case the local/remote launch doesn't complete
launch();
mh.frameworkTrace(cid, mid, "exit");
+ return true;
+ }
+
+ public int getReturnCode() {
+ return returnCode;
}
public static void main(String[] args) throws Exception {
AllInOneLauncher allInOneLauncher = new AllInOneLauncher(args);
- allInOneLauncher.go();
+ allInOneLauncher.execute();
+ System.exit(allInOneLauncher.getReturnCode());
}