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/04/27 00:45:11 UTC

svn commit: r1476430 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli: CliBase.java DuccJobSubmit.java DuccManagedReservationSubmit.java aio/AllInOneLauncher.java

Author: burn
Date: Fri Apr 26 22:45:10 2013
New Revision: 1476430

URL: http://svn.apache.org/r1476430
Log:
UIMA-2848 Set exit code for APs.  Simplify CLI by waiting if necessary for the rc.  Replaced tabs with blanks for consistent formatting

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/DuccJobSubmit.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationSubmit.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/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=1476430&r1=1476429&r2=1476430&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 Apr 26 22:45:10 2013
@@ -60,7 +60,7 @@ public abstract class CliBase
     protected CommandLine commandLine;
 
     protected long friendlyId = -1;
-    protected int  returnCode = 1000;
+    protected int  returnCode = 0;
 
     protected DuccProperties cli_props;
     protected ArrayList<String> errors   = new ArrayList<String>();
@@ -136,11 +136,11 @@ public abstract class CliBase
 
     void setWorkingDirectory()
     {
-		String working_directory = cli_props.getProperty(UiOption.WorkingDirectory.pname());
-		if(working_directory == null) {
-			working_directory = System.getProperty("user.dir");
-			cli_props.setProperty(UiOption.WorkingDirectory.pname(), working_directory);
-		}
+        String working_directory = cli_props.getProperty(UiOption.WorkingDirectory.pname());
+        if(working_directory == null) {
+            working_directory = System.getProperty("user.dir");
+            cli_props.setProperty(UiOption.WorkingDirectory.pname(), working_directory);
+        }
         File f = new File(working_directory);
         if ( ! f.exists() ) {
             throw new IllegalArgumentException("Working directory " + working_directory + " does not exist.");
@@ -155,11 +155,11 @@ public abstract class CliBase
      */
     boolean resolve_service_dependencies(String endpoint)
     {
-    	String key_ja = UiOption.ProcessJvmArgs.pname();
+        String key_ja = UiOption.ProcessJvmArgs.pname();
         if ( cli_props.containsKey(UiOption.JvmArgs.pname()) ) {
-        	key_ja = UiOption.JvmArgs.pname();
+            key_ja = UiOption.JvmArgs.pname();
         }
-    	String jvmargs = cli_props.getProperty(key_ja);
+        String jvmargs = cli_props.getProperty(key_ja);
         
         Properties jvmprops = DuccUiUtilities.jvmArgsToProperties(jvmargs);
 
@@ -171,13 +171,13 @@ public abstract class CliBase
             }
             return true;
         } catch ( Throwable t ) {
-        	message("ERROR:", t.toString());
+            message("ERROR:", t.toString());
             return false;
         }
     }
 
     void setUser()
-    	throws Exception
+        throws Exception
     {
         /*
          * marshal user
@@ -253,7 +253,7 @@ public abstract class CliBase
      * Use this init if you use the default log location and don't need a console callback.
      */
     protected synchronized void init(String myClassName, UiOption[] opts, String[] args, DuccProperties cli_props, String host_s, String port_s, String servlet)
-    	throws Exception
+        throws Exception
     {
         this.init(myClassName, opts, args, cli_props, host_s, port_s, servlet, null, null);
     }
@@ -263,18 +263,18 @@ public abstract class CliBase
      */
     protected synchronized void init(String myClassName, UiOption[] opts, String[] args, DuccProperties cli_props, 
             String host_s, String port_s, String servlet, IDuccCallback consoleCb)
-    	throws Exception
+        throws Exception
     {
         this.init(myClassName, opts, args, cli_props, host_s, port_s, servlet, consoleCb, null);
     }
 
     protected synchronized void init() {
-    	ducc_home = Utils.findDuccHome();
+        ducc_home = Utils.findDuccHome();
     }
     
     protected synchronized void init(String myClassName, UiOption[] opts, String[] args, DuccProperties cli_props,
-				     String host_s, String port_s, String servlet, IDuccCallback consoleCb, String logExtension)
-    	throws Exception
+                     String host_s, String port_s, String servlet, IDuccCallback consoleCb, String logExtension)
+        throws Exception
     {
         if ( init_done ) return;
         
@@ -414,22 +414,22 @@ public abstract class CliBase
         fos.close();
     }
 
-	void adjustLdLibraryPath(DuccProperties requestProps, String key) 
+    void adjustLdLibraryPath(DuccProperties requestProps, String key) 
     {
-		String source = "LD_LIBRARY_PATH";
-		String target = "DUCC_"+source;
-		String environment_string = requestProps.getProperty(key);
-		Properties environment_properties = DuccUiUtilities.environmentMap(environment_string);
-		if (environment_properties.containsKey(source)) {
-			if (environment_properties.containsKey(target)) {
+        String source = "LD_LIBRARY_PATH";
+        String target = "DUCC_"+source;
+        String environment_string = requestProps.getProperty(key);
+        Properties environment_properties = DuccUiUtilities.environmentMap(environment_string);
+        if (environment_properties.containsKey(source)) {
+            if (environment_properties.containsKey(target)) {
                 message("WARN", key, " environment conflict:", target, "takes precedence over", source);
-			} else {
-				target += "="+environment_properties.getProperty(source);
-				environment_string += " "+target;
-				requestProps.setProperty(key, environment_string);
-			}
-		}
-	}
+            } else {
+                target += "="+environment_properties.getProperty(source);
+                environment_string += " "+target;
+                requestProps.setProperty(key, environment_string);
+            }
+        }
+    }
 
     /**
      * Extract messages and job pid from reply.  This sets messages and errors into the appropriate
@@ -447,23 +447,23 @@ public abstract class CliBase
         boolean rc = true;
         Properties properties = reply.getProperties();
         @SuppressWarnings("unchecked")
-		ArrayList<String> value_submit_warnings = (ArrayList<String>) properties.get(UiOption.SubmitWarnings.pname());
+        ArrayList<String> value_submit_warnings = (ArrayList<String>) properties.get(UiOption.SubmitWarnings.pname());
         if(value_submit_warnings != null) {
-        	message("Job warnings:");
-        	Iterator<String> reasons = value_submit_warnings.iterator();
-        	while(reasons.hasNext()) {
-        		message("WARN:", reasons.next());
-        	}
+            message("Job warnings:");
+            Iterator<String> reasons = value_submit_warnings.iterator();
+            while(reasons.hasNext()) {
+                message("WARN:", reasons.next());
+            }
         }
         @SuppressWarnings("unchecked")
-		ArrayList<String> value_submit_errors = (ArrayList<String>) properties.get(UiOption.SubmitErrors.pname());
+        ArrayList<String> value_submit_errors = (ArrayList<String>) properties.get(UiOption.SubmitErrors.pname());
         if(value_submit_errors != null) {
-        	message("Job errors:");
-        	Iterator<String> reasons = value_submit_errors.iterator();
-        	while(reasons.hasNext()) {
-        		message("ERROR:", reasons.next());
-        	}
-	        rc = false;
+            message("Job errors:");
+            Iterator<String> reasons = value_submit_errors.iterator();
+            while(reasons.hasNext()) {
+                message("ERROR:", reasons.next());
+            }
+            rc = false;
         }
 
         String pid =  reply.getProperties().getProperty(UiOption.JobId.pname());
@@ -510,7 +510,7 @@ public abstract class CliBase
             return false;
         }
         cli_props.setProperty(key, value);
-    	return true;
+        return true;
     }
 
     public boolean isDebug()
@@ -563,8 +563,12 @@ public abstract class CliBase
         }
     }
 
+    /*
+     * Return code is only available when the monitor wait completes ... if not waiting then assume success
+     */
     public int getReturnCode()
     {
+        waitForCompletion();
         return returnCode;
     }
 
@@ -589,12 +593,11 @@ public abstract class CliBase
 
     // TODO TODO TODO - do we have to support lots of these for multi-threaded stuff?  Hope not ...
     protected synchronized void startMonitors(boolean start_stdin, DuccContext context)
-    	throws Exception
+        throws Exception
     {
         int wait_count = 0;
 
         if ( console_listener != null ) {
-            startConsoleListener(start_stdin);
             wait_count++;
         }
         
@@ -608,27 +611,25 @@ public abstract class CliBase
             
         if ( monitor_attach ) {
             wait_count++;
-            startMonitor(context);
         }
 
+        // Probably over-cautious but create the waiter before starting the threads that use it
         if ( wait_count > 0 ) {
             waiter = new CountDownLatch(wait_count);
+            if ( console_listener != null ) {
+                startConsoleListener(start_stdin);
+            }
+            if ( monitor_attach ) {
+                startMonitor(context);
+            }
         }
     }
 
     protected synchronized void startMonitor(DuccContext context)
     {
         monitor_listener = new MonitorListener(this, friendlyId, cli_props, context);
-
-        if (	cli_props.containsKey(UiOption.WaitForCompletion.pname()) || 
-        		cli_props.containsKey(UiOption.CancelOnInterrupt.pname()) ||
-        		cli_props.containsKey(UiOption.CancelJobOnInterrupt.pname()) || 
-        		cli_props.containsKey(UiOption.CancelManagedReservationOnInterrupt.pname()) ||
-        		(console_listener != null) 
-        	) {
-            Thread mlt = new Thread(monitor_listener);  //MonitorListenerThread
-            mlt.start();
-        }
+        Thread mlt = new Thread(monitor_listener);  //MonitorListenerThread
+        mlt.start();
     }
 
     /**
@@ -637,7 +638,7 @@ public abstract class CliBase
      * submission fails.
      */
     protected void initConsoleListener()
-    	throws Exception
+        throws Exception
     {
         console_attach =
             cli_props.containsKey(UiOption.ProcessAttachConsole.pname()) ||
@@ -649,8 +650,8 @@ public abstract class CliBase
             String key_pe = UiOption.ProcessEnvironment.pname();
             String key_de = UiOption.DriverEnvironment.pname();
             if ( cli_props.containsKey(UiOption.Environment.pname()) ) {
-            	key_pe = UiOption.Environment.pname();
-            	key_de = UiOption.Environment.pname();
+                key_pe = UiOption.Environment.pname();
+                key_de = UiOption.Environment.pname();
             }
             
             if ( cli_props.containsKey(UiOption.ProcessAttachConsole.pname()) ) {
@@ -667,7 +668,7 @@ public abstract class CliBase
      * Be sure to call this BEFORE submission, to insure the callback address is set in properties.
      */
     protected synchronized void startConsoleListener(boolean start_stdin)
-    	throws Exception
+        throws Exception
     {        
         if ( console_attach ) {
             console_listener.startStdin(start_stdin);
@@ -730,14 +731,14 @@ public abstract class CliBase
     public boolean waitForCompletion()
     {
         try {
-			if ( waiter != null ) {
+            if ( waiter != null ) {
                 waiter.await();
                 return true;
             }
-		} catch (InterruptedException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+        } catch (InterruptedException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
         return false;
     }
 

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=1476430&r1=1476429&r2=1476430&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 Apr 26 22:45:10 2013
@@ -35,14 +35,14 @@ import org.apache.uima.ducc.transport.ev
 
 public class DuccJobSubmit 
     extends CliBase 
-{	
+{    
     private JobRequestProperties jobRequestProperties = new JobRequestProperties();        
     static String or_port = "ducc.orchestrator.http.port";
     static String or_host = "ducc.orchestrator.node";
-	
-	// public DuccJobSubmit(IDuccMessageProcessor duccMessageProcessor) {
-// 		this.duccMessageProcessor = duccMessageProcessor;
-// 	}
+    
+    // public DuccJobSubmit(IDuccMessageProcessor duccMessageProcessor) {
+//         this.duccMessageProcessor = duccMessageProcessor;
+//     }
     
     public static UiOption[] opts_release = new UiOption[] {
         UiOption.Help,
@@ -154,46 +154,46 @@ public class DuccJobSubmit 
     
     public static UiOption[] opts = opts_release;
     
-	public DuccJobSubmit(ArrayList<String> args)
+    public DuccJobSubmit(ArrayList<String> args)
         throws Exception
     {
         this(args, null);
     }
 
-	public DuccJobSubmit(String[] args)
+    public DuccJobSubmit(String[] args)
         throws Exception
     {
         this(args, null);
     }
 
-	public DuccJobSubmit(Properties props)
+    public DuccJobSubmit(Properties props)
         throws Exception
     {
         this(props, null);
     }
 
-	public DuccJobSubmit(ArrayList<String> args, IDuccCallback consoleCb)
+    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;
+            opts = opts_beta;
         }
         init(this.getClass().getName(), opts, arg_array, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
     }
 
-	public DuccJobSubmit(String[] args, IDuccCallback consoleCb)
+    public DuccJobSubmit(String[] args, IDuccCallback consoleCb)
         throws Exception
     {
-		init();
-		if(DuccUiUtilities.isSupportedBeta()) {
-       		opts = opts_beta;
+        init();
+        if(DuccUiUtilities.isSupportedBeta()) {
+               opts = opts_beta;
         }
-		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", consoleCb, null);
     }
 
-	public DuccJobSubmit(Properties props, IDuccCallback consoleCb)
+    public DuccJobSubmit(Properties props, IDuccCallback consoleCb)
         throws Exception
     {
         for ( Object k : props.keySet() ) {      
@@ -202,7 +202,7 @@ public class DuccJobSubmit 
         }
         init();
         if(DuccUiUtilities.isSupportedBeta()) {
-        	opts = opts_beta;
+            opts = opts_beta;
         }
         init(this.getClass().getName(), opts, null, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
     }
@@ -257,224 +257,224 @@ public class DuccJobSubmit 
         }
 
     }
-	
-	private long getThreadsLimit() {
-		long limit = 0;
-		try {
-			String p_limit = DuccPropertiesResolver.getInstance().getProperty(DuccPropertiesResolver.ducc_submit_threads_limit);
-			if(p_limit != null) {
-				p_limit = p_limit.trim();
-				if(!p_limit.equals("unlimited")) {
-					limit = Long.parseLong(p_limit);
-				}
-			}
-		}
-		catch(Throwable t) {
+    
+    private long getThreadsLimit() {
+        long limit = 0;
+        try {
+            String p_limit = DuccPropertiesResolver.getInstance().getProperty(DuccPropertiesResolver.ducc_submit_threads_limit);
+            if(p_limit != null) {
+                p_limit = p_limit.trim();
+                if(!p_limit.equals("unlimited")) {
+                    limit = Long.parseLong(p_limit);
+                }
+            }
+        }
+        catch(Throwable t) {
             message(t.toString());
-		}
-		return limit;
-	}
-	
-	private boolean adjust_max_threads(Properties properties) {
-		boolean retVal = false;
-		try {
-			long limit = getThreadsLimit();
-			if(limit == 0) {
-				return retVal;
-			}
-			String p_threads = properties.getProperty(UiOption.ProcessThreadCount.pname());
-			if(p_threads == null) {
-				p_threads = UiOption.ProcessThreadCount.deflt();;
-			}
-
-			long threads = Long.parseLong(p_threads);
-			String p_procs = properties.getProperty(UiOption.ProcessDeploymentsMax.pname());
-			if(p_procs == null) {
-				long procs = limit / threads;
-				p_procs = "unlimited";
-				String a_procs = ""+procs;
-				message(UiOption.ProcessDeploymentsMax.pname(), ": requested[" + p_procs + "] adjusted to[" + a_procs + "]");
-				properties.setProperty(UiOption.ProcessDeploymentsMax.pname(), a_procs);
-				retVal = true;
-			}
-			else {
-				long procs = Long.parseLong(p_procs);
-				if( (procs * threads) > limit ) {
-					procs = limit / threads;
-					String a_procs = ""+procs;
-					message(UiOption.ProcessDeploymentsMax.pname(), ": requested["+p_procs+"] adjusted to["+a_procs + "]");
-					properties.setProperty(UiOption.ProcessDeploymentsMax.pname(), a_procs);
-					retVal = true;
-				}
-			}
-		}
-		catch(Throwable t) {
+        }
+        return limit;
+    }
+    
+    private boolean adjust_max_threads(Properties properties) {
+        boolean retVal = false;
+        try {
+            long limit = getThreadsLimit();
+            if(limit == 0) {
+                return retVal;
+            }
+            String p_threads = properties.getProperty(UiOption.ProcessThreadCount.pname());
+            if(p_threads == null) {
+                p_threads = UiOption.ProcessThreadCount.deflt();;
+            }
+
+            long threads = Long.parseLong(p_threads);
+            String p_procs = properties.getProperty(UiOption.ProcessDeploymentsMax.pname());
+            if(p_procs == null) {
+                long procs = limit / threads;
+                p_procs = "unlimited";
+                String a_procs = ""+procs;
+                message(UiOption.ProcessDeploymentsMax.pname(), ": requested[" + p_procs + "] adjusted to[" + a_procs + "]");
+                properties.setProperty(UiOption.ProcessDeploymentsMax.pname(), a_procs);
+                retVal = true;
+            }
+            else {
+                long procs = Long.parseLong(p_procs);
+                if( (procs * threads) > limit ) {
+                    procs = limit / threads;
+                    String a_procs = ""+procs;
+                    message(UiOption.ProcessDeploymentsMax.pname(), ": requested["+p_procs+"] adjusted to["+a_procs + "]");
+                    properties.setProperty(UiOption.ProcessDeploymentsMax.pname(), a_procs);
+                    retVal = true;
+                }
+            }
+        }
+        catch(Throwable t) {
             message(t.toString());
-		}
-		return retVal;
-	}
-	
-	//**********
-	
-	private String getDuccProperty(String propertyName, String defaultValue) {
-		String propertyValue = defaultValue;
-		try {
-			String value = DuccPropertiesResolver.getInstance().getProperty(propertyName);
-			if(value != null) {
-				propertyValue = value;
-			}
-		}
-		catch(Throwable t) {
+        }
+        return retVal;
+    }
+    
+    //**********
+    
+    private String getDuccProperty(String propertyName, String defaultValue) {
+        String propertyValue = defaultValue;
+        try {
+            String value = DuccPropertiesResolver.getInstance().getProperty(propertyName);
+            if(value != null) {
+                propertyValue = value;
+            }
+        }
+        catch(Throwable t) {
             message(t.toString());
-		}
-		return propertyValue;
-	}
-	
+        }
+        return propertyValue;
+    }
+    
     private void adjust_specific_jvm_args(String additionalArgs, UiOption args_option)
     {
-		String additionalJvmArgs = getDuccProperty(additionalArgs, null);
-		if(additionalJvmArgs != null) {
-			String jvmArgs = jobRequestProperties.getProperty(args_option.pname());
-			if(jvmArgs == null) {
-				jvmArgs = additionalJvmArgs;
-			}
-			else {
-				jvmArgs += " "+additionalJvmArgs;
-			}
-			jobRequestProperties.setProperty(args_option.pname(), jvmArgs);
-		}
+        String additionalJvmArgs = getDuccProperty(additionalArgs, null);
+        if(additionalJvmArgs != null) {
+            String jvmArgs = jobRequestProperties.getProperty(args_option.pname());
+            if(jvmArgs == null) {
+                jvmArgs = additionalJvmArgs;
+            }
+            else {
+                jvmArgs += " "+additionalJvmArgs;
+            }
+            jobRequestProperties.setProperty(args_option.pname(), jvmArgs);
+        }
 
     }
 
-	//**********		
-	
-	public boolean execute() 
+    //**********        
+    
+    public boolean execute() 
         throws Exception 
     {
                     
         try {
-			enrich_parameters_for_debug(jobRequestProperties);
+            enrich_parameters_for_debug(jobRequestProperties);
         } catch (Exception e1) {
             message(e1.toString());
             return false;
-		}
+        }
         
         boolean cp0 = jobRequestProperties.containsKey(UiOption.Classpath.pname());
         boolean cpd = jobRequestProperties.containsKey(UiOption.DriverClasspath.pname());
         boolean cpp = jobRequestProperties.containsKey(UiOption.ProcessClasspath.pname());
         
         if(cp0 && cpd) {
-        	throw new IllegalArgumentException("Conflict: cannot specify both "+UiOption.Classpath.pname()+" and "+UiOption.DriverClasspath.pname());
+            throw new IllegalArgumentException("Conflict: cannot specify both "+UiOption.Classpath.pname()+" and "+UiOption.DriverClasspath.pname());
         }
         if(cp0 && cpp) {
-        	throw new IllegalArgumentException("Conflict: cannot specify both "+UiOption.Classpath.pname()+" and "+UiOption.ProcessClasspath.pname());
+            throw new IllegalArgumentException("Conflict: cannot specify both "+UiOption.Classpath.pname()+" and "+UiOption.ProcessClasspath.pname());
         }
         if(cp0) {
-        	// Nothing to do
+            // Nothing to do
         }
         else {
-        	if(cpd || cpp) {
-        		/*
-        		 * employ default driver classpath if not specified
-        		 */
-        		String driver_classpath = jobRequestProperties.getProperty(UiOption.DriverClasspath.pname());
-        		if(driver_classpath == null) {
-        			driver_classpath = System.getProperty("java.class.path");
-        			jobRequestProperties.setProperty(UiOption.DriverClasspath.pname(), driver_classpath);
-        		}
-        		/*
-        		 * employ default process classpath if not specified
-        		 */
-        		String process_classpath = jobRequestProperties.getProperty(UiOption.ProcessClasspath.pname());
-        		if(process_classpath == null) {
-        			process_classpath = System.getProperty("java.class.path");
-        			jobRequestProperties.setProperty(UiOption.ProcessClasspath.pname(), process_classpath);
-        		}
-        	}
-        	else {
-        		/*
-        		 * employ default classpath if not specified
-        		 */
-        		String classpath = jobRequestProperties.getProperty(UiOption.Classpath.pname());
-        		if(classpath == null) {
-        			classpath = System.getProperty("java.class.path");
-        			jobRequestProperties.setProperty(UiOption.Classpath.pname(), classpath);
-        		}
-        	}
-        }
-        
-		/*
-		 * employ default process initialization failures cap if not specified
-		 */
-		String process_initialization_failures_cap = jobRequestProperties.getProperty(UiOption.ProcessInitializationFailuresCap.pname());
-		if(process_initialization_failures_cap == null) {
-			jobRequestProperties.setProperty(UiOption.ProcessInitializationFailuresCap.pname(), UiOption.ProcessInitializationFailuresCap.deflt());
-		}
-
-		/*
-		 * employ default process failures limit if not specified
-		 */
-		String process_failures_limit = jobRequestProperties.getProperty(UiOption.ProcessFailuresLimit.pname());
-		if(process_failures_limit == null) {
-			jobRequestProperties.setProperty(UiOption.ProcessFailuresLimit.pname(), UiOption.ProcessFailuresLimit.deflt());
-		}
-		if (jobRequestProperties.containsKey(UiOption.Debug.pname())) {
-			jobRequestProperties.dump();
-		}
-
-		/*
-		 * set DUCC_LD_LIBRARY_PATH in driver, process environment
-		 */
+            if(cpd || cpp) {
+                /*
+                 * employ default driver classpath if not specified
+                 */
+                String driver_classpath = jobRequestProperties.getProperty(UiOption.DriverClasspath.pname());
+                if(driver_classpath == null) {
+                    driver_classpath = System.getProperty("java.class.path");
+                    jobRequestProperties.setProperty(UiOption.DriverClasspath.pname(), driver_classpath);
+                }
+                /*
+                 * employ default process classpath if not specified
+                 */
+                String process_classpath = jobRequestProperties.getProperty(UiOption.ProcessClasspath.pname());
+                if(process_classpath == null) {
+                    process_classpath = System.getProperty("java.class.path");
+                    jobRequestProperties.setProperty(UiOption.ProcessClasspath.pname(), process_classpath);
+                }
+            }
+            else {
+                /*
+                 * employ default classpath if not specified
+                 */
+                String classpath = jobRequestProperties.getProperty(UiOption.Classpath.pname());
+                if(classpath == null) {
+                    classpath = System.getProperty("java.class.path");
+                    jobRequestProperties.setProperty(UiOption.Classpath.pname(), classpath);
+                }
+            }
+        }
+        
+        /*
+         * employ default process initialization failures cap if not specified
+         */
+        String process_initialization_failures_cap = jobRequestProperties.getProperty(UiOption.ProcessInitializationFailuresCap.pname());
+        if(process_initialization_failures_cap == null) {
+            jobRequestProperties.setProperty(UiOption.ProcessInitializationFailuresCap.pname(), UiOption.ProcessInitializationFailuresCap.deflt());
+        }
+
+        /*
+         * employ default process failures limit if not specified
+         */
+        String process_failures_limit = jobRequestProperties.getProperty(UiOption.ProcessFailuresLimit.pname());
+        if(process_failures_limit == null) {
+            jobRequestProperties.setProperty(UiOption.ProcessFailuresLimit.pname(), UiOption.ProcessFailuresLimit.deflt());
+        }
+        if (jobRequestProperties.containsKey(UiOption.Debug.pname())) {
+            jobRequestProperties.dump();
+        }
+
+        /*
+         * set DUCC_LD_LIBRARY_PATH in driver, process environment
+         */
         boolean ev0 = jobRequestProperties.containsKey(UiOption.Environment.pname());
         boolean evd = jobRequestProperties.containsKey(UiOption.DriverEnvironment.pname());
         boolean evp = jobRequestProperties.containsKey(UiOption.ProcessEnvironment.pname());
         if(ev0 && evd) {
-        	throw new IllegalArgumentException("Conflict: cannot specify both "+UiOption.Environment.pname()+" and "+UiOption.DriverEnvironment.pname());
+            throw new IllegalArgumentException("Conflict: cannot specify both "+UiOption.Environment.pname()+" and "+UiOption.DriverEnvironment.pname());
         }
         if(ev0 && evp) {
-        	throw new IllegalArgumentException("Conflict: cannot specify both "+UiOption.Environment.pname()+" and "+UiOption.ProcessEnvironment.pname());
+            throw new IllegalArgumentException("Conflict: cannot specify both "+UiOption.Environment.pname()+" and "+UiOption.ProcessEnvironment.pname());
         }
         if(ev0) {
-        	if (!DuccUiUtilities.ducc_environment(this, jobRequestProperties, UiOption.Environment.pname())) {
-    			return false;
-    		}
+            if (!DuccUiUtilities.ducc_environment(this, jobRequestProperties, UiOption.Environment.pname())) {
+                return false;
+            }
         }
         else {
-        	if(evd || evp) {
-        		if (!DuccUiUtilities.ducc_environment(this, jobRequestProperties, UiOption.DriverEnvironment.pname())) {
-        			return false;
-        		}
-        		if (!DuccUiUtilities.ducc_environment(this, jobRequestProperties, UiOption.ProcessEnvironment.pname())) {
-        			return false;
-        		}
-        	}
-        	else {
-        		if (!DuccUiUtilities.ducc_environment(this, jobRequestProperties, UiOption.Environment.pname())) {
-        			return false;
-        		}
-        	}
-        }
-        
-		/*
-		 * limit total number of threads
-		 */
-		adjust_max_threads(jobRequestProperties);
-
-		/*
-		 * adjust driver and process jvm args
-		 */
+            if(evd || evp) {
+                if (!DuccUiUtilities.ducc_environment(this, jobRequestProperties, UiOption.DriverEnvironment.pname())) {
+                    return false;
+                }
+                if (!DuccUiUtilities.ducc_environment(this, jobRequestProperties, UiOption.ProcessEnvironment.pname())) {
+                    return false;
+                }
+            }
+            else {
+                if (!DuccUiUtilities.ducc_environment(this, jobRequestProperties, UiOption.Environment.pname())) {
+                    return false;
+                }
+            }
+        }
+        
+        /*
+         * limit total number of threads
+         */
+        adjust_max_threads(jobRequestProperties);
+
+        /*
+         * adjust driver and process jvm args
+         */
         boolean jad = jobRequestProperties.containsKey(UiOption.DriverJvmArgs.pname());
         boolean jap = jobRequestProperties.containsKey(UiOption.ProcessJvmArgs.pname());
         
         if(jad || jap) {
-        	adjust_specific_jvm_args(DuccPropertiesResolver.ducc_submit_driver_jvm_args, UiOption.DriverJvmArgs);
-        	adjust_specific_jvm_args(DuccPropertiesResolver.ducc_submit_process_jvm_args, UiOption.ProcessJvmArgs);
+            adjust_specific_jvm_args(DuccPropertiesResolver.ducc_submit_driver_jvm_args, UiOption.DriverJvmArgs);
+            adjust_specific_jvm_args(DuccPropertiesResolver.ducc_submit_process_jvm_args, UiOption.ProcessJvmArgs);
         }
 
-		/*
-		 * identify invoker
-		 */
-		jobRequestProperties.setProperty(UiOption.SubmitPid.pname(), ManagementFactory.getRuntimeMXBean().getName());
+        /*
+         * identify invoker
+         */
+        jobRequestProperties.setProperty(UiOption.SubmitPid.pname(), ManagementFactory.getRuntimeMXBean().getName());
 
         /*
          * resolve ${defaultBrokerURL} in service dependencies - must fail if resolution needed but can't resolve
@@ -505,49 +505,44 @@ public class DuccJobSubmit 
             startMonitors(false, DuccContext.Job);       // starts conditionally, based on job spec and console listener present
         }
 
-		return rc;
-	}
-	
-	private boolean isAllInOne() {
-		return jobRequestProperties.containsKey(UiOption.AllInOne.pname());
-	}
-	
-	private static void main_job(String[] args, DuccJobSubmit ds) throws Exception {
-		boolean rc = ds.execute();
+        return rc;
+    }
+    
+    private boolean isAllInOne() {
+        return jobRequestProperties.containsKey(UiOption.AllInOne.pname());
+    }
+    
+    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 ) {                
-            // Fetch the Ducc ID
-        	System.out.println("Job " + ds.getDuccId() + " submitted");
-            int exit_code = 0;          // first best guess, waiting for completion.
-            if ( ds.waitForCompletion() ) {
-                exit_code = ds.getReturnCode();       // updated from wait.
-                System.out.println("Job return code: " + exit_code);
-            }
-        	System.exit(exit_code);
+            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 allInOneLauncher = new AllInOneLauncher(args);
-		allInOneLauncher.go();
-	}
-	
-	public static void main(String[] args) {
-		try {
-			DuccJobSubmit ds = new DuccJobSubmit(args, null);
-			if(ds.isAllInOne()) {
-				main_aio(args);
-			}
-			else {
-				main_job(args, ds);
-			}
-		}
-		catch(Exception e) {
-			System.out.println("Cannot initialize: " + e);
+    }
+    
+    private static void main_aio(String[] args) throws Exception {
+        AllInOneLauncher allInOneLauncher = new AllInOneLauncher(args);
+        allInOneLauncher.go();
+    }
+    
+    public static void main(String[] args) {
+        try {
+            DuccJobSubmit ds = new DuccJobSubmit(args, null);
+            if(ds.isAllInOne()) {
+                main_aio(args);
+            }
+            else {
+                main_job(args, ds);
+            }
+        }
+        catch(Exception e) {
+            System.out.println("Cannot initialize: " + e);
             System.exit(1);
-		}
-	}
+        }
+    }
 }

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationSubmit.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationSubmit.java?rev=1476430&r1=1476429&r2=1476430&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationSubmit.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationSubmit.java Fri Apr 26 22:45:10 2013
@@ -105,7 +105,7 @@ public class DuccManagedReservationSubmi
         serviceRequestProperties = new ServiceRequestProperties(); 
         init();
         if(DuccUiUtilities.isSupportedBeta()) {
-        	opts = opts_beta;
+            opts = opts_beta;
         }
         init(this.getClass().getName(), opts, args, serviceRequestProperties, or_host, or_port, "or", consoleCb);
     }
@@ -117,7 +117,7 @@ public class DuccManagedReservationSubmi
         serviceRequestProperties = new ServiceRequestProperties();   
         init();
         if(DuccUiUtilities.isSupportedBeta()) {
-        	opts = opts_beta;
+            opts = opts_beta;
         }
         init(this.getClass().getName(), opts, arg_array, serviceRequestProperties, or_host, or_port, "or", consoleCb);
     }
@@ -134,7 +134,7 @@ public class DuccManagedReservationSubmi
         }
         init();
         if(DuccUiUtilities.isSupportedBeta()) {
-        	opts = opts_beta;
+            opts = opts_beta;
         }
         init(this.getClass().getName(), opts, null, serviceRequestProperties, or_host, or_port, "or", consoleCb);
     }
@@ -154,24 +154,24 @@ public class DuccManagedReservationSubmi
         boolean ev0 = serviceRequestProperties.containsKey(UiOption.Environment.pname());
         boolean evp = serviceRequestProperties.containsKey(UiOption.ProcessEnvironment.pname());
         if(ev0 && evp) {
-        	throw new IllegalArgumentException("Conflict: cannot specify both "+UiOption.Environment.pname()+" and "+UiOption.ProcessEnvironment.pname());
+            throw new IllegalArgumentException("Conflict: cannot specify both "+UiOption.Environment.pname()+" and "+UiOption.ProcessEnvironment.pname());
         }
         if(ev0) {
-        	if (!DuccUiUtilities.ducc_environment(this, serviceRequestProperties, UiOption.Environment.pname())) {
-    			return false;
-    		}
+            if (!DuccUiUtilities.ducc_environment(this, serviceRequestProperties, UiOption.Environment.pname())) {
+                return false;
+            }
         }
         else {
-        	if(evp) {
-        		if (!DuccUiUtilities.ducc_environment(this,serviceRequestProperties, UiOption.ProcessEnvironment.pname())) {
-        			return false;
-        		}
-        	}
-        	else {
-        		if (!DuccUiUtilities.ducc_environment(this, serviceRequestProperties, UiOption.Environment.pname())) {
-        			return false;
-        		}
-        	}
+            if(evp) {
+                if (!DuccUiUtilities.ducc_environment(this,serviceRequestProperties, UiOption.ProcessEnvironment.pname())) {
+                    return false;
+                }
+            }
+            else {
+                if (!DuccUiUtilities.ducc_environment(this, serviceRequestProperties, UiOption.Environment.pname())) {
+                    return false;
+                }
+            }
         }
 
         SubmitServiceDuccEvent ev = new SubmitServiceDuccEvent(serviceRequestProperties);
@@ -179,9 +179,6 @@ public class DuccManagedReservationSubmi
         
         try {
             reply = (SubmitServiceReplyDuccEvent) dispatcher.dispatchAndWaitForDuccReply(ev);
-        } catch (Exception e) {
-            message("ERROR:", dt, "not submitted:", e.toString());
-            return false;
         } finally {
             dispatcher.close();
         }
@@ -192,19 +189,19 @@ public class DuccManagedReservationSubmi
         boolean retval = true;
         Properties properties = reply.getProperties();
         @SuppressWarnings("unchecked")
-		ArrayList<String> or_warnings = (ArrayList<String>) properties.get(UiOption.SubmitWarnings.pname());
+        ArrayList<String> or_warnings = (ArrayList<String>) properties.get(UiOption.SubmitWarnings.pname());
         if (or_warnings != null) {
-        	for ( String s : or_warnings) {
+            for ( String s : or_warnings) {
                message("WARN:", s);
-        	}
+            }
         }
 
         @SuppressWarnings("unchecked")
         ArrayList<String> or_errors = (ArrayList<String>) properties.get(UiOption.SubmitErrors.pname());
         if(or_errors != null) {
-        	for ( String s : or_errors ) {
+            for ( String s : or_errors ) {
                 message("ERROR:", s);
-        	}
+            }
             retval = false;
         }
 
@@ -228,6 +225,7 @@ public class DuccManagedReservationSubmi
         
     public static void main(String[] args) 
     {
+        int code = 1; // Assume the worst
         try {
             // Instantiate the object with args similar to the CLI, or a pre-built properties file
             DuccManagedReservationSubmit ds = new DuccManagedReservationSubmit(args);
@@ -238,25 +236,16 @@ public class DuccManagedReservationSubmi
 
             // If the return is 'true' then as best the API can tell, the submit worked
             if ( rc ) {
-                // Fetch the Ducc ID
-            	System.out.println(dt+" "+ds.getDuccId()+" submitted.");
-            	int code = 0;
-            	if(ds.waitForCompletion()) {
-            		code = ds.getReturnCode();
-            	}
-                if ( code == 1000 ) {
-                    System.out.println(dt + ": no return code.");
-                } else {
-                    System.out.println(dt+" return code: "+code);
-                }
-            	System.exit(0);
+                System.out.println(dt+" "+ds.getDuccId()+" submitted.");
+                code = ds.getReturnCode();
             } else {
-                System.out.println("Could not submit "+dt);
-                System.exit(1);
+                System.out.println(dt+" Could not submit ");
             }
         } catch (Exception e) {
-            System.out.println("Cannot initialize: " + e.getMessage());
-            System.exit(1);
+            System.out.println(dt+" Cannot initialize: " + e.getMessage());
+        } finally {
+            // Set the process exit code
+            System.exit(code);
         }
     }
     

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=1476430&r1=1476429&r2=1476430&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 Fri Apr 26 22:45:10 2013
@@ -32,6 +32,7 @@ import org.apache.commons.cli.MissingArg
 import org.apache.uima.ducc.cli.CliBase;
 import org.apache.uima.ducc.cli.DuccJobSubmit;
 import org.apache.uima.ducc.cli.DuccManagedReservationSubmit;
+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;
@@ -1106,24 +1107,15 @@ public class AllInOneLauncher extends Cl
 		boolean rc = ds.execute();
 		
 		String dt = "Managed Reservation";
-		if ( rc ) {
-            // Fetch the Ducc ID
-        	System.out.println(dt+" "+ds.getDuccId()+" submitted.");
-        	int code = 0;
-        	if(ds.waitForCompletion()) {
-        		code = ds.getReturnCode();
-        	}
-            if ( code == 1000 ) {
-                System.out.println(dt + ": no return code.");
-            } else {
-                System.out.println(dt+" return code: "+code);
-            }
-        	System.exit(0);
-        } else {
-            System.out.println("Could not submit "+dt);
-            System.exit(1);
-        }
-		
+    if (rc) {
+      System.out.println(dt + " " + ds.getDuccId() + " submitted.");
+      int code = ds.getReturnCode();
+      System.exit(code);
+    } else {
+      System.out.println("Could not submit " + dt);
+      System.exit(1);
+    }
+
 		mh.frameworkDebug(cid, mid, "rc="+rc);
 		mh.frameworkTrace(cid, mid, "exit");
 	}