You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2013/01/15 18:24:38 UTC
svn commit: r1433537 [1/2] - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc:
api/ api/test/ cli/ cli/ws/ cli/ws/json/
Author: cwiklik
Date: Tue Jan 15 17:24:37 2013
New Revision: 1433537
URL: http://svn.apache.org/viewvc?rev=1433537&view=rev
Log:
UIMA-2575 committing for jim
Added:
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessCancel.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessSubmit.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/DuccWebQuery.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/DuccWebQueryMachines.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/DuccWebQueryReservations.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/MachineFacts.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/MachineFactsList.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/MachineFactsTest.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/NodePidList.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/ReservationFacts.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/ReservationFactsList.java (with props)
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ws/json/ReservationFactsTest.java (with props)
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/api/DuccMessage.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/api/test/MessageHandler.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobCancel.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobMonitor.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/DuccPerfStats.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccReservationCancel.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccReservationSubmit.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceApi.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceCancel.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceSubmit.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccUiConstants.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IServiceApi.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/api/DuccMessage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/api/DuccMessage.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/api/DuccMessage.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/api/DuccMessage.java Tue Jan 15 17:24:37 2013
@@ -20,18 +20,22 @@ package org.apache.uima.ducc.api;
public class DuccMessage implements IDuccMessageProcessor {
+ @Override
public void out(String message) {
System.out.println(message);
}
+ @Override
public void err(String message) {
System.err.println(message);
}
+ @Override
public void exception(Exception e) {
e.printStackTrace();
}
+ @Override
public void throwable(Throwable t) {
t.printStackTrace();
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/api/test/MessageHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/api/test/MessageHandler.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/api/test/MessageHandler.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/api/test/MessageHandler.java Tue Jan 15 17:24:37 2013
@@ -24,19 +24,23 @@ public class MessageHandler implements I
private String prefix = MessageHandler.class.getSimpleName()+": ";
+ @Override
public void out(String message) {
System.out.println(prefix+message);
}
+ @Override
public void err(String message) {
System.err.println(prefix+message);
}
+ @Override
public void exception(Exception e) {
System.out.println(prefix);
e.printStackTrace();
}
+ @Override
public void throwable(Throwable t) {
System.out.println(prefix);
t.printStackTrace();
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobCancel.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobCancel.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobCancel.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobCancel.java Tue Jan 15 17:24:37 2013
@@ -211,9 +211,11 @@ public class DuccJobCancel extends DuccU
public static void main(String[] args) {
try {
DuccJobCancel duccJobCancel = new DuccJobCancel();
- duccJobCancel.run(args);
+ int rc = duccJobCancel.run(args);
+ System.exit(rc == 0 ? 0 : 1);
} catch (Exception e) {
e.printStackTrace();
+ System.exit(1);
}
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobMonitor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobMonitor.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobMonitor.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobMonitor.java Tue Jan 15 17:24:37 2013
@@ -206,7 +206,7 @@ public class DuccJobMonitor extends Ducc
try {
int intValue1 = Integer.parseInt(v1);
int intValue2 = Integer.parseInt(v2);
- if(intValue1 > 0) {
+ if(intValue1 >= 0) {
if(intValue1 == intValue2) {
retVal = true;
}
@@ -287,6 +287,7 @@ public class DuccJobMonitor extends Ducc
}
}
+ @Override
public void setDuccEventDispatcher(DuccEventDispatcher eventDispatcher) {
throw new RuntimeException();
}
@@ -529,9 +530,11 @@ public class DuccJobMonitor extends Ducc
public static void main(String[] args) {
try {
DuccJobMonitor duccJobMonitor = new DuccJobMonitor();
- duccJobMonitor.run(args);
+ int rc = duccJobMonitor.run(args);
+ System.exit(rc == 0 ? 0 : 1);
} catch (Exception e) {
e.printStackTrace();
+ System.exit(1);
}
return;
}
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=1433537&r1=1433536&r2=1433537&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 Tue Jan 15 17:24:37 2013
@@ -21,13 +21,19 @@ package org.apache.uima.ducc.cli;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
@@ -41,6 +47,7 @@ import org.apache.commons.cli.PosixParse
import org.apache.uima.ducc.api.DuccMessage;
import org.apache.uima.ducc.api.IDuccMessageProcessor;
import org.apache.uima.ducc.common.IDucc;
+import org.apache.uima.ducc.common.NodeIdentity;
import org.apache.uima.ducc.common.crypto.Crypto;
import org.apache.uima.ducc.common.exception.DuccRuntimeException;
import org.apache.uima.ducc.common.utils.DuccPropertiesResolver;
@@ -61,14 +68,136 @@ import org.apache.uima.ducc.transport.ev
public class DuccJobSubmit extends DuccUi {
private IDuccMessageProcessor duccMessageProcessor = new DuccMessage();
-
+
+ private int console_listener_port;
+ private String console_host_address;
+
+ ConsoleListener console_listener = null;
+
public DuccJobSubmit() {
}
public DuccJobSubmit(IDuccMessageProcessor duccMessageProcessor) {
this.duccMessageProcessor = duccMessageProcessor;
}
-
+
+ protected void start_console_listener()
+ throws Throwable
+ {
+ console_listener = new ConsoleListener(this);
+ incrementWaitCounter();
+ Thread t = new Thread(console_listener);
+ t.start();
+ }
+
+ private void set_console_port(Properties props, String key)
+ {
+ if ( key != null ) {
+ String envval = "DUCC_CONSOLE_LISTENER";
+ String env = props.getProperty(key);
+ // Set the host:port for the console listener into the env
+ String console_address = console_host_address + ":" + console_listener_port;
+ String dp = envval + "=" + console_address;
+ env = env + " " + dp;
+ props.setProperty(key, env);
+ }
+ }
+
+ private void set_debug_parms(Properties props, String key, int port)
+ {
+ String debug_address = console_host_address + ":" + port;
+ String jvmargs = props.getProperty(key);
+ jvmargs = jvmargs + " -Xdebug";
+ jvmargs = jvmargs + " -Xrunjdwp:transport=dt_socket,address=" + debug_address;
+ props.put(key, jvmargs);
+ }
+
+ protected void enrich_parameters_for_debug(Properties props)
+ throws Exception
+ {
+
+ NodeIdentity ni = new NodeIdentity();
+ console_host_address = ni.getIp();
+
+ try {
+ int jp_debug_port = -1;
+ int jd_debug_port = -2; // a trick, must be different from jp_debug_port; see below
+
+ // we allow both jd and jp to debug, but the ports have to differ
+ if ( props.containsKey(DuccUiConstants.name_process_debug) ) {
+ jp_debug_port = Integer.parseInt(props.getProperty(DuccUiConstants.name_process_debug));
+ set_debug_parms(props, JobRequestProperties.key_process_jvm_args, jp_debug_port);
+ }
+
+ if ( props.containsKey(DuccUiConstants.name_driver_debug) ) {
+ jd_debug_port = Integer.parseInt(props.getProperty(DuccUiConstants.name_driver_debug));
+ set_debug_parms(props, JobRequestProperties.key_driver_jvm_args, jd_debug_port);
+ }
+
+ if ( jp_debug_port == jd_debug_port ) {
+ throw new IllegalArgumentException("Process and Driver debug ports must differ.");
+ }
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Invalid debug port (not numeric)");
+ }
+
+
+ boolean console_attach =
+ props.containsKey(DuccUiConstants.name_process_attach_console) ||
+ props.containsKey(DuccUiConstants.name_driver_attach_console);
+
+ if ( console_attach ) {
+ try {
+ start_console_listener();
+ } catch ( Throwable t ) {
+ throw new IllegalStateException("Cannot start console listener. Reason:" + t.getMessage());
+ }
+ }
+
+ if ( props.containsKey(DuccUiConstants.name_process_attach_console) ) {
+ set_console_port(props, DuccUiConstants.name_process_environment);
+ }
+
+ if (props.containsKey(DuccUiConstants.name_driver_attach_console) ) {
+ set_console_port(props, DuccUiConstants.name_driver_environment);
+ }
+
+ }
+
+ // wait_count is the number of notifications I have to wait for before exiting
+ // - one if a console listener is started; the listener will notify when done
+ // - one if a monitor is started, the monitor will notify when done
+ //
+ // If a console listener is started a monitor is also started, so the count is 2
+ // in that case.
+ private int wait_count = 0;
+ private int waitRc = 0;
+ private synchronized int waitForCompletion()
+ {
+ try {
+ while ( wait_count > 0 ) {
+ System.out.println("----------- WAITING " + wait_count + "--------------");
+ wait();
+ }
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return waitRc;
+ }
+
+ private synchronized void incrementWaitCounter()
+ {
+ wait_count++;
+ }
+
+ private synchronized void releaseWait(int rc)
+ {
+ waitRc = Math.max(waitRc, rc);
+ wait_count--;
+ notify();
+ }
+
@SuppressWarnings("static-access")
private void addOptions(Options options) {
options.addOption(OptionBuilder
@@ -77,6 +206,25 @@ public class DuccJobSubmit extends DuccU
options.addOption(OptionBuilder
.withDescription(DuccUiConstants.desc_debug).hasArg(false)
.withLongOpt(DuccUiConstants.name_debug).create());
+
+ // Remote console/debug
+ options.addOption(OptionBuilder
+ .withDescription(DuccUiConstants.desc_process_debug).hasArg(true)
+ .withLongOpt(DuccUiConstants.name_process_debug).create());
+
+ options.addOption(OptionBuilder
+ .withDescription(DuccUiConstants.desc_process_attach_console).hasArg(false)
+ .withLongOpt(DuccUiConstants.name_process_attach_console).create());
+
+ options.addOption(OptionBuilder
+ .withDescription(DuccUiConstants.desc_driver_debug).hasArg(true)
+ .withLongOpt(DuccUiConstants.name_driver_debug).create());
+
+ options.addOption(OptionBuilder
+ .withDescription(DuccUiConstants.desc_driver_attach_console).hasArg(false)
+ .withLongOpt(DuccUiConstants.name_driver_attach_console).create());
+ // End remote console/ debug
+
options.addOption(OptionBuilder
.withDescription(DuccUiConstants.desc_timestamp).hasArg(false)
.withLongOpt(DuccUiConstants.name_timestamp).create());
@@ -604,6 +752,14 @@ public class DuccJobSubmit extends DuccU
jobRequestProperties.setProperty(name, value);
}
}
+
+ try {
+ enrich_parameters_for_debug(jobRequestProperties);
+ } catch (Exception e1) {
+ System.out.println(e1.getMessage());
+ return DuccUiConstants.ERROR;
+ }
+
/*
* employ default log directory if not specified
*/
@@ -812,31 +968,15 @@ public class DuccJobSubmit extends DuccU
jobId = submitJobReplyDuccEvent.getProperties().getProperty(JobRequestProperties.key_id);
saveJobSpec(jobId, jobRequestProperties);
duccMessageProcessor.out("Job"+" "+jobId+" "+"submitted");
- if(jobRequestProperties.containsKey(DuccUiConstants.name_wait_for_completion)) {
- try {
- ArrayList<String> arrayList = new ArrayList<String>();
- arrayList.add("--"+DuccUiConstants.name_job_id);
- arrayList.add(jobId);
- arrayList.add("--"+DuccUiConstants.name_service_broker);
- arrayList.add(broker);
- if(jobRequestProperties.containsKey(DuccUiConstants.name_debug)) {
- arrayList.add("--"+DuccUiConstants.name_debug);
- }
- if(jobRequestProperties.containsKey(DuccUiConstants.name_timestamp)) {
- arrayList.add("--"+DuccUiConstants.name_timestamp);
- }
- if(jobRequestProperties.containsKey(DuccUiConstants.name_submit_cancel_job_on_interrupt)) {
- arrayList.add("--"+DuccUiConstants.name_monitor_cancel_job_on_interrupt);
- }
- String[] argList = arrayList.toArray(new String[0]);
- DuccJobMonitor duccJobMonitor = new DuccJobMonitor(this.duccMessageProcessor);
- retVal = duccJobMonitor.run(argList);
- } catch (Exception e) {
- duccMessageProcessor.exception(e);
- retVal = DuccUiConstants.ERROR;
- }
- }
+
+ if(jobRequestProperties.containsKey(DuccUiConstants.name_wait_for_completion) || ( console_listener != null) ) {
+ incrementWaitCounter();
+ MonitorListener ml = new MonitorListener(this, jobId, broker, jobRequestProperties);
+ Thread mlt = new Thread(ml); //MonitorListenerThread
+ mlt.start();
+ }
}
+ retVal = waitForCompletion();
return retVal;
}
@@ -870,10 +1010,229 @@ public class DuccJobSubmit extends DuccU
public static void main(String[] args) {
try {
DuccJobSubmit duccJobSubmit = new DuccJobSubmit();
- duccJobSubmit.run(args);
+ int rc = duccJobSubmit.run(args);
+ System.exit(rc == 0 ? 0 : 1);
} catch (Exception e) {
e.printStackTrace();
+ System.exit(1);
}
}
-
+
+ class StdioListener
+ implements Runnable
+ {
+ Socket sock;
+ InputStream is;
+ boolean done = false;
+ ConsoleListener cl;
+ String remote_host;
+ String leader;
+
+ StdioListener(Socket sock, ConsoleListener cl)
+ {
+ this.sock = sock;
+ this.cl = cl;
+
+ InetAddress ia = sock.getInetAddress();
+ remote_host = ia.getHostName();
+ System.out.println("===== Listener starting: " + remote_host + ":" + sock.getPort());
+ int ndx = remote_host.indexOf('.');
+ if ( ndx >= 0 ) {
+ // this is just for console decoration, keep it short, who cares about the domain
+ remote_host = remote_host.substring(0, ndx);
+ }
+ leader = "[" + remote_host + "] ";
+ }
+
+ public void close()
+ throws Throwable
+ {
+ System.out.println("===== Listener completing: " + remote_host + ":" + sock.getPort());
+ this.done = true;
+ is.close();
+ cl.delete(sock.getPort());
+ }
+
+ /**
+ * We received a buffer of bytes that needs to be put into a string and printed. We want
+ * to split along \n boundaries so we can insert the host name at the start of every line.
+ *
+ * Simple, except that the end of the buffer may not be \n, instead it could be the
+ * start of another line.
+ *
+ * We want to save the partial lines as the start of the next line so they can all be
+ * printed all nicely.
+ */
+ String partial = null;
+ public void printlines(byte[] buf, int count)
+ {
+ String tmp = new String(buf, 0, count);
+ String[] lines = tmp.split("\n");
+ int len = lines.length - 1;
+ if ( len < 0 ) {
+ // this is a lone linend. Spew the partial if it exists and just return.
+ if ( partial != null ) {
+ System.out.println(leader + partial);
+ partial = null;
+ }
+ return;
+ }
+
+
+ if ( partial != null ) {
+ // some leftover, it's the start of the first line of the new buffer.
+ lines[0] = partial + lines[0];
+ partial = null;
+ }
+
+ for ( int i = 0; i < len; i++ ) {
+ // spew everything but the last line
+ System.out.println(leader + lines[i]);
+ }
+
+ if ( tmp.endsWith("\n") ) {
+ // if the last line ends with linend, there is no partial, just spew
+ System.out.println(leader + lines[len]);
+ partial = null;
+ } else {
+ // otherwise, wait for the next buffer
+ partial = lines[len];
+ }
+ }
+
+ public void run()
+ {
+ byte[] buf = new byte[4096];
+ try {
+ is = sock.getInputStream();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return;
+ }
+
+ try {
+ int count = 0;
+ while ( (count = is.read(buf)) > 0 ) {
+ printlines(buf, count);
+ }
+ System.out.println(leader + "EOF: exiting");
+ } catch ( Throwable t ) {
+ t.printStackTrace();
+ }
+ try {
+ close();
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ class ConsoleListener
+ implements Runnable
+ {
+ ServerSocket sock;
+ DuccJobSubmit submit;
+ Map<Integer, StdioListener> listeners = new HashMap<Integer, StdioListener>();
+
+ ConsoleListener(DuccJobSubmit submit)
+ throws Throwable
+ {
+ this.submit = submit;
+ sock = new ServerSocket(0);
+ console_listener_port = sock.getLocalPort();
+ }
+
+ void shutdown()
+ {
+ try {
+ sock.close();
+ for ( StdioListener sl : listeners.values() ) {
+ sl.close();
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ void delete(int port)
+ {
+ listeners.remove(port);
+ if ( listeners.size() == 0 ) {
+ synchronized(submit) {
+ submit.releaseWait(0);
+ }
+ shutdown();
+ }
+ }
+
+ public void run()
+ {
+ System.out.println("Listening on " + console_host_address + " " + console_listener_port);
+
+ while ( true ) {
+ try {
+ Socket s = sock.accept();
+ StdioListener sl = new StdioListener(s, this);
+ int p = s.getPort();
+ listeners.put(p, sl);
+
+ Thread t = new Thread(sl);
+ t.start();
+ } catch (Throwable t) {
+ shutdown();
+ return;
+ }
+ }
+ }
+
+ }
+
+ class MonitorListener
+ implements Runnable
+ {
+ DuccJobSubmit djs = null;
+ String jobId = null;
+ String broker = null;
+ JobRequestProperties jobRequestProperties = null;
+
+ MonitorListener(DuccJobSubmit djs, String jobId, String broker, JobRequestProperties props)
+ {
+ this.djs = djs;
+ this.jobId = jobId;
+ this.broker = broker;
+ this.jobRequestProperties = props;
+ }
+
+ public void run()
+ {
+ int retVal = 0;
+ try {
+ ArrayList<String> arrayList = new ArrayList<String>();
+ arrayList.add("--"+DuccUiConstants.name_job_id);
+ arrayList.add(jobId);
+ arrayList.add("--"+DuccUiConstants.name_service_broker);
+ arrayList.add(broker);
+ if(jobRequestProperties.containsKey(DuccUiConstants.name_debug)) {
+ arrayList.add("--"+DuccUiConstants.name_debug);
+ }
+ if(jobRequestProperties.containsKey(DuccUiConstants.name_timestamp)) {
+ arrayList.add("--"+DuccUiConstants.name_timestamp);
+ }
+ if(jobRequestProperties.containsKey(DuccUiConstants.name_submit_cancel_job_on_interrupt)) {
+ arrayList.add("--"+DuccUiConstants.name_monitor_cancel_job_on_interrupt);
+ }
+ String[] argList = arrayList.toArray(new String[0]);
+ DuccJobMonitor duccJobMonitor = new DuccJobMonitor(duccMessageProcessor);
+ retVal = duccJobMonitor.run(argList);
+ } catch (Exception e) {
+ duccMessageProcessor.exception(e);
+ retVal = DuccUiConstants.ERROR;
+ }
+ synchronized(djs) {
+ djs.releaseWait(retVal);
+ }
+ }
+ }
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccPerfStats.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccPerfStats.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccPerfStats.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccPerfStats.java Tue Jan 15 17:24:37 2013
@@ -276,7 +276,7 @@ public class DuccPerfStats
System.out.println(" ducc_perf_stats -workitems");
System.out.println("");
System.out.println("Format job summary statistics from some log directory and print in CSV:");
- System.out.println(" ducc_perf_stats -logdir /home/bob/ducc/logs -job 33 -summary -csv");
+ System.out.println(" ducc_perf_stats -directory /home/bob/ducc/logs -job 33 -summary -csv");
System.out.println("");
System.out.println("When using CSV, the first line of the job summary stats contains two numbers");
System.out.println(" numitems numcas");
@@ -367,7 +367,13 @@ public class DuccPerfStats
protected void formatWorkItems()
{
WorkItemStateManager workItemStateManager = new WorkItemStateManager(dir);
- workItemStateManager.importData();
+ try {
+ workItemStateManager.importData();
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ return;
+ }
ConcurrentSkipListMap<Long,IWorkItemState> map = workItemStateManager.getMap();
int namemax = 0;
int nodemax = 0;
@@ -377,6 +383,7 @@ public class DuccPerfStats
IWorkItemState iws = map.get(l);
String id = iws.getWiId();
String node = iws.getNode();
+ if ( node == null ) node = "<unassigned>";
namemax = Math.max(namemax, id.length());
nodemax = Math.max(nodemax, node.length());
items.add(iws);
@@ -407,7 +414,9 @@ public class DuccPerfStats
String seq = iws.getSeqNo();
String id = iws.getWiId();
String node = iws.getNode();
+ if ( node == null ) node = "<unassigned>";
String pid = iws.getPid();
+ if ( pid == null ) pid = "<n/a>";
State state = iws.getState();
long proctime = iws.getMillisProcessing();
long overhead = iws.getMillisOverhead();
@@ -511,6 +520,7 @@ public class DuccPerfStats
DuccPerfStats dfs = new DuccPerfStats();
dfs.run(args);
+ System.exit(0);
}
@@ -629,7 +639,9 @@ public class DuccPerfStats
public int compare(IWorkItemState a, IWorkItemState b)
{
String aa = a.getNode();
+ if ( aa == null ) aa = "<unassigned>";
String bb = b.getNode();
+ if ( bb == null ) bb = "<unassigned>";
return aa.compareTo(bb);
}
}
@@ -639,8 +651,13 @@ public class DuccPerfStats
{
public int compare(IWorkItemState a, IWorkItemState b)
{
- long apid = Long.parseLong(a.getPid());
- long bpid = Long.parseLong(b.getPid());
+ String aspid = a.getPid();
+ String bspid = b.getPid();
+ if ( aspid == null ) aspid = "<n/a>";
+ if ( bspid == null ) bspid = "<n/a>";
+
+ long apid = Long.parseLong(aspid);
+ long bpid = Long.parseLong(bspid);
return (int)(apid - bpid);
}
}
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessCancel.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessCancel.java?rev=1433537&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessCancel.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessCancel.java Tue Jan 15 17:24:37 2013
@@ -0,0 +1,12 @@
+package org.apache.uima.ducc.cli;
+
+public class DuccProcessCancel extends DuccServiceCancel
+{
+
+ public int run(String[] args)
+ throws Exception
+ {
+ return super.run(args);
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessCancel.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessSubmit.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessSubmit.java?rev=1433537&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessSubmit.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessSubmit.java Tue Jan 15 17:24:37 2013
@@ -0,0 +1,25 @@
+package org.apache.uima.ducc.cli;
+
+import org.apache.uima.ducc.transport.event.common.IDuccWorkService.ServiceDeploymentType;
+
+public class DuccProcessSubmit extends DuccServiceSubmit
+{
+ public int run(String[] args)
+ throws Exception
+ {
+ super.setServiceType(ServiceDeploymentType.other);
+ return super.run(args);
+ }
+
+ public static void main(String[] args) {
+ try {
+ DuccProcessSubmit dps = new DuccProcessSubmit();
+ int rc = dps.run(args);
+ System.exit(rc == 0 ? 0 : 1);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+}
Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccProcessSubmit.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccReservationCancel.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccReservationCancel.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccReservationCancel.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccReservationCancel.java Tue Jan 15 17:24:37 2013
@@ -212,9 +212,11 @@ public class DuccReservationCancel exten
public static void main(String[] args) {
try {
DuccReservationCancel duccReservationCancel = new DuccReservationCancel();
- duccReservationCancel.run(args);
+ int rc = duccReservationCancel.run(args);
+ System.exit(rc == 0 ? 0 : 1);
} catch (Exception e) {
e.printStackTrace();
+ System.exit(1);
}
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccReservationSubmit.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccReservationSubmit.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccReservationSubmit.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccReservationSubmit.java Tue Jan 15 17:24:37 2013
@@ -20,6 +20,7 @@ package org.apache.uima.ducc.cli;
import java.io.File;
import java.io.FileInputStream;
+import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Properties;
@@ -51,8 +52,9 @@ import org.apache.uima.ducc.transport.ev
public class DuccReservationSubmit extends DuccUi {
- private String[] hosts;
private IDuccMessageProcessor duccMessageProcessor = new DuccMessage();
+ private String nodeList = "";
+ private String reservationId = "";
public DuccReservationSubmit() {
}
@@ -127,7 +129,6 @@ public class DuccReservationSubmit exten
addOptions(options);
CommandLineParser parser = new PosixParser();
CommandLine commandLine = parser.parse(options, args);
- this.hosts = new String[0];
/*
* give help & exit when requested
@@ -216,6 +217,10 @@ public class DuccReservationSubmit exten
;
}
/*
+ * identify invoker
+ */
+ reservationRequestProperties.setProperty(ReservationRequestProperties.key_submitter_pid_at_host, ManagementFactory.getRuntimeMXBean().getName());
+ /*
* send to Orchestrator & get reply
*/
// CamelContext context = new DefaultCamelContext();
@@ -285,54 +290,39 @@ public class DuccReservationSubmit exten
return DuccUiConstants.ERROR;
}
else {
- String reservationId = submitReservationReplyDuccEvent.getProperties().getProperty(ReservationRequestProperties.key_id);
+ reservationId = submitReservationReplyDuccEvent.getProperties().getProperty(ReservationRequestProperties.key_id);
+ nodeList = submitReservationReplyDuccEvent.getProperties().getProperty(ReservationRequestProperties.key_node_list);
duccMessageProcessor.out("Reservation"+" "+reservationId+" "+"submitted");
- String nodeList = submitReservationReplyDuccEvent.getProperties().getProperty(ReservationRequestProperties.key_node_list);
- String[] nodes = nodeList.split(";");
- this.hosts = new String[nodes.length];
- int nodeindex = 0;
- StringBuffer sb = new StringBuffer();
- StringBuffer nb = new StringBuffer();
- for ( String node: nodes ) {
- int ndx = node.indexOf(".");
- if ( ndx >= 0 ) {
- node = node.substring(0, ndx).trim();
- }
- hosts[nodeindex++] = node;
- sb.append(node);
- sb.append(" ");
- if(node.contains("[") && node.contains("]")) {
- String nodeOnly = node.substring(0,node.indexOf("["));
- nb.append(nodeOnly.trim());
- }
- else {
- nb.append(node);
- }
- nb.append(" ");
- }
- duccMessageProcessor.out("nodes: " + nb.toString().trim());
+ boolean success = nodeList.trim().length() > 0;
+ if(success) {
+ duccMessageProcessor.out("resID = "+reservationId);
+ duccMessageProcessor.out("nodes: "+nodeList);
+ }
+ else {
+ duccMessageProcessor.out("Resources Unavailable");
+ }
return new Integer(reservationId);
}
}
+ @Deprecated
+ public String getReservationId() {
+ return this.reservationId;
+ }
+
+ @Deprecated
public String[] getHosts() {
- return this.hosts;
+ return this.nodeList.split(" ");
}
public static void main(String[] args) {
try {
DuccReservationSubmit duccReservationSubmit = new DuccReservationSubmit();
- int resid = duccReservationSubmit.run(args);
- System.out.println("resID = "+resid);
- if (duccReservationSubmit.getHosts().length == 0) {
- System.out.println("No hosts returned");
- } else {
- for (String h : duccReservationSubmit.getHosts()) {
- System.out.println(h.trim());
- }
- }
+ int rc = duccReservationSubmit.run(args);
+ System.exit(rc == 0 ? 0 : 1);
} catch (Exception e) {
e.printStackTrace();
+ System.exit(1);
}
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceApi.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceApi.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceApi.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceApi.java Tue Jan 15 17:24:37 2013
@@ -87,7 +87,7 @@ public class DuccServiceApi
System.out.println(msg);
}
System.out.println("Usage:");
- System.exit(0);
+ System.exit(1);
}
static void usage(Options options)
@@ -95,6 +95,7 @@ public class DuccServiceApi
HelpFormatter formatter = new HelpFormatter();
formatter.setWidth(DuccUiConstants.help_width);
formatter.printHelp(DuccServiceApi.class.getName(), options);
+ System.exit(1);
}
@SuppressWarnings("static-access")
@@ -220,6 +221,14 @@ public class DuccServiceApi
// Other directives are not supported for registered services.
options.addOption(OptionBuilder
+ .withLongOpt (RegistrationOption.ClasspathOrder.decode())
+ .withDescription(RegistrationOption.ClasspathOrder.description())
+ .withArgName (RegistrationOption.ClasspathOrder.argname())
+ .hasArg(true)
+ .create()
+ );
+
+ options.addOption(OptionBuilder
.withLongOpt (RegistrationOption.Description.decode())
.withDescription(RegistrationOption.Description.description())
.withArgName (RegistrationOption.Description.argname())
@@ -324,33 +333,49 @@ public class DuccServiceApi
);
options.addOption(OptionBuilder
- .withLongOpt (RegistrationOption.ServiceCustomPing.decode())
- .withDescription(RegistrationOption.ServiceCustomPing.description())
- .withArgName (RegistrationOption.ServiceCustomPing.argname())
+ .withLongOpt (RegistrationOption.ServiceRequestEndpoint.decode())
+ .withDescription(RegistrationOption.ServiceRequestEndpoint.description())
+ .withArgName (RegistrationOption.ServiceRequestEndpoint.argname())
.hasArg(true)
.create()
);
options.addOption(OptionBuilder
- .withLongOpt (RegistrationOption.ServiceCustomEndpoint.decode())
- .withDescription(RegistrationOption.ServiceCustomEndpoint.description())
- .withArgName (RegistrationOption.ServiceCustomEndpoint.argname())
+ .withLongOpt (RegistrationOption.ServicePingClass.decode())
+ .withDescription(RegistrationOption.ServicePingClass.description())
+ .withArgName (RegistrationOption.ServicePingClass.argname())
.hasArg(true)
.create()
);
options.addOption(OptionBuilder
- .withLongOpt (RegistrationOption.ServiceCustomClasspath.decode())
- .withDescription(RegistrationOption.ServiceCustomClasspath.description())
- .withArgName (RegistrationOption.ServiceCustomClasspath.argname())
+ .withLongOpt (RegistrationOption.ServicePingClasspath.decode())
+ .withDescription(RegistrationOption.ServicePingClasspath.description())
+ .withArgName (RegistrationOption.ServicePingClasspath.argname())
.hasArg(true)
.create()
);
options.addOption(OptionBuilder
- .withLongOpt (RegistrationOption.ServiceCustomJvmArgs.decode())
- .withDescription(RegistrationOption.ServiceCustomJvmArgs.description())
- .withArgName (RegistrationOption.ServiceCustomJvmArgs.argname())
+ .withLongOpt (RegistrationOption.ServicePingJvmArgs.decode())
+ .withDescription(RegistrationOption.ServicePingJvmArgs.description())
+ .withArgName (RegistrationOption.ServicePingJvmArgs.argname())
+ .hasArg(true)
+ .create()
+ );
+
+ options.addOption(OptionBuilder
+ .withLongOpt (RegistrationOption.ServicePingDoLog.decode())
+ .withDescription(RegistrationOption.ServicePingDoLog.description())
+ .withArgName (RegistrationOption.ServicePingDoLog.argname())
+ .hasArg(false)
+ .create()
+ );
+
+ options.addOption(OptionBuilder
+ .withLongOpt (RegistrationOption.ServicePingTimeout.decode())
+ .withDescription(RegistrationOption.ServicePingTimeout.description())
+ .withArgName (RegistrationOption.ServicePingTimeout.argname())
.hasArg(true)
.create()
);
@@ -490,6 +515,7 @@ public class DuccServiceApi
private void overrideProperties(CommandLine cl, DuccProperties props, RegistrationOption opt)
{
+
String k = opt.decode();
String v = cl.getOptionValue(k, null);
if ( v == null ) return;
@@ -519,22 +545,21 @@ public class DuccServiceApi
// First read the properties file if given in
// ducc_services --register propsfile
String props = cl.getOptionValue(ServiceVerb.Register.decode());
+ debug = true;
if ( props != null ) {
reply.load(new FileInputStream(props));
if ( debug ) {
System.out.println("Service specification file:");
for ( Object key: reply.keySet() ) {
- System.out.println(" Key: " + "Value: " + reply.getStringProperty((String)key));
+ System.out.println(" Key: " + key + " Value: " + reply.getStringProperty((String)key));
}
}
}
- // Must enforce this for registered services
- reply.put("process_deployments_max", "1");
-
//
// Now pull in the override props.
//
+ overrideProperties(cl, reply, RegistrationOption.ClasspathOrder);
overrideProperties(cl, reply, RegistrationOption.Description);
overrideProperties(cl, reply, RegistrationOption.ProcessDD);
overrideProperties(cl, reply, RegistrationOption.ProcessMemorySize);
@@ -548,10 +573,35 @@ public class DuccServiceApi
overrideProperties(cl, reply, RegistrationOption.Jvm);
overrideProperties(cl, reply, RegistrationOption.ServiceDependency);
overrideProperties(cl, reply, RegistrationOption.ServiceLinger);
- overrideProperties(cl, reply, RegistrationOption.ServiceCustomPing);
- overrideProperties(cl, reply, RegistrationOption.ServiceCustomEndpoint);
- overrideProperties(cl, reply, RegistrationOption.ServiceCustomClasspath);
- overrideProperties(cl, reply, RegistrationOption.ServiceCustomJvmArgs);
+ overrideProperties(cl, reply, RegistrationOption.ServicePingClass);
+ overrideProperties(cl, reply, RegistrationOption.ServiceRequestEndpoint);
+ overrideProperties(cl, reply, RegistrationOption.ServicePingClasspath);
+ overrideProperties(cl, reply, RegistrationOption.ServicePingJvmArgs);
+ overrideProperties(cl, reply, RegistrationOption.ServicePingDoLog);
+ overrideProperties(cl, reply, RegistrationOption.ServicePingTimeout);
+
+ // now bop through the properties and make sure they and their values all valid
+ for ( Object o : reply.keySet() ) {
+ String k = (String) o;
+
+ RegistrationOption opt = RegistrationOption.encode(k);
+ if ( opt == RegistrationOption.Unknown ) {
+ throw new IllegalArgumentException("Invalid regisration option: " + k);
+ }
+
+ switch ( opt ) {
+ case ClasspathOrder:
+ String v = reply.getStringProperty(RegistrationOption.ClasspathOrder.decode());
+ if ( v == null ) continue;
+ if ( ClasspathOrderParms.encode(v) == ClasspathOrderParms.Unknown) {
+ throw new IllegalStateException("Invalid value for " + RegistrationOption.ClasspathOrder.decode());
+ }
+ break;
+ }
+ }
+
+ // Must enforce this for registered services
+ reply.put(DuccUiConstants.parm_process_deployments_max, "1");
//
// Now: let's resolve placeholders.
@@ -619,35 +669,38 @@ public class DuccServiceApi
// }
service_props.setProperty(k_ld, log_directory);
- // establish my endpoint
- String endpoint = service_props.getStringProperty(RegistrationOption.ServiceCustomEndpoint.decode(), null);
- if ( endpoint == null ) { // not custom ...
- //
- // No endpoint, resolve from the DD.
- //
+ //
+ // Establish my endpoint
+ //
+ String endpoint = service_props.getStringProperty(RegistrationOption.ServiceRequestEndpoint.decode(), null);
+ if ( endpoint == null ) { // not custom ... must be uima-as (or fail)
- //
// If claspath is not specified, pick it up from the submitter's environment
- //
String classpath = service_props.getStringProperty(RegistrationOption.ProcessClasspath.decode(), System.getProperty("java.class.path"));
service_props.setProperty(RegistrationOption.ProcessClasspath.decode(), classpath);
- String dd = service_props.getStringProperty(RegistrationOption.ProcessDD.decode());
+ // No endpoint, resolve from the DD.
+ String dd = service_props.getStringProperty(RegistrationOption.ProcessDD.decode()); // will throw if can't find the prop
endpoint = DuccUiUtilities.getEndpoint(working_dir, dd, jvmargs);
if ( debug ) {
System.out.println("Service endpoint resolves to " + endpoint);
}
- } else {
- String k_scp = RegistrationOption.ServiceCustomClasspath.decode();
- String classpath = service_props.getStringProperty(k_scp, System.getProperty("java.class.path"));
- service_props.setProperty(k_scp, classpath);
+ } else if ( endpoint.startsWith(ServiceType.Custom.decode()) ) {
- if ( ! endpoint.startsWith(ServiceType.Custom.decode()) ) {
- throw new IllegalArgumentException("Invalid custom endpoint: " + endpoint);
- }
- if ( service_props.getProperty(RegistrationOption.ServiceCustomPing.decode()) == null ) {
+ // must have a pinger specified
+ if ( service_props.getProperty(RegistrationOption.ServicePingClass.decode()) == null ) {
throw new IllegalArgumentException("Custom service is missing ping class name.");
}
+
+ String k_scp = RegistrationOption.ServicePingClasspath.decode();
+ String classpath = service_props.getStringProperty(k_scp, System.getProperty("java.class.path"));
+ service_props.setProperty(k_scp, classpath);
+ } else if ( endpoint.startsWith(ServiceType.UimaAs.decode()) ) {
+ // Infer the classpath
+ String classpath = service_props.getStringProperty(RegistrationOption.ProcessClasspath.decode(), System.getProperty("java.class.path"));
+ service_props.setProperty(RegistrationOption.ProcessClasspath.decode(), classpath);
+ } else {
+ throw new IllegalArgumentException("Invalid custom endpoint: " + endpoint);
}
// work out stuff I'm dependendent upon
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceCancel.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceCancel.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceCancel.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceCancel.java Tue Jan 15 17:24:37 2013
@@ -60,9 +60,9 @@ public class DuccServiceCancel extends D
.withDescription(DuccUiConstants.desc_help).hasArg(false)
.withLongOpt(DuccUiConstants.name_help).create());
options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_job_id)
- .withDescription(makeDesc(DuccUiConstants.desc_job_id,DuccUiConstants.exmp_job_id)).hasArg()
- .withLongOpt(DuccUiConstants.name_job_id).create());
+ .withArgName(DuccUiConstants.parm_service_id)
+ .withDescription(makeDesc(DuccUiConstants.desc_service_id,DuccUiConstants.exmp_service_id)).hasArg()
+ .withLongOpt(DuccUiConstants.name_service_id).create());
options.addOption(OptionBuilder
.withArgName(DuccUiConstants.parm_service_broker)
.withDescription(makeDesc(DuccUiConstants.desc_service_broker,DuccUiConstants.exmp_service_broker)).hasArg()
@@ -211,9 +211,11 @@ public class DuccServiceCancel extends D
public static void main(String[] args) {
try {
DuccServiceCancel duccServiceCancel = new DuccServiceCancel();
- duccServiceCancel.run(args);
+ int rc = duccServiceCancel.run(args);
+ System.exit(rc == 0 ? 0 : 1);
} catch (Exception e) {
e.printStackTrace();
+ System.exit(1);
}
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceSubmit.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceSubmit.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceSubmit.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccServiceSubmit.java Tue Jan 15 17:24:37 2013
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
+import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -52,6 +53,7 @@ import org.apache.uima.ducc.transport.ev
import org.apache.uima.ducc.transport.event.cli.ServiceRequestProperties;
import org.apache.uima.ducc.transport.event.cli.ServiceSpecificationProperties;
import org.apache.uima.ducc.transport.event.cli.SpecificationProperties;
+import org.apache.uima.ducc.transport.event.common.IDuccWorkService.ServiceDeploymentType;
import org.apache.uima.ducc.transport.event.sm.IService.ServiceType;
@@ -65,6 +67,8 @@ public class DuccServiceSubmit extends D
private Properties jvmargs = null;
private IDuccMessageProcessor duccMessageProcessor = new DuccMessage();
+ private ServiceDeploymentType serviceDeploymentType = ServiceDeploymentType.unspecified;
+
public DuccServiceSubmit() {
}
@@ -80,16 +84,10 @@ public class DuccServiceSubmit extends D
options.addOption(OptionBuilder
.withDescription(DuccUiConstants.desc_debug).hasArg(false)
.withLongOpt(DuccUiConstants.name_debug).create());
- /*
- options.addOption(OptionBuilder
- .withDescription(DuccUiConstants.desc_timestamp).hasArg(false)
- .withLongOpt(DuccUiConstants.name_timestamp).create());
- */
options.addOption(OptionBuilder
.withArgName(DuccUiConstants.parm_service_broker)
.withDescription(makeDesc(DuccUiConstants.desc_service_broker,DuccUiConstants.exmp_service_broker)).hasArg()
.withLongOpt(DuccUiConstants.name_service_broker).create());
-
options.addOption(OptionBuilder
.withArgName(DuccUiConstants.parm_service_endpoint)
.withDescription(makeDesc(DuccUiConstants.desc_service_endpoint,DuccUiConstants.exmp_service_endpoint)).hasArg()
@@ -98,22 +96,10 @@ public class DuccServiceSubmit extends D
.withArgName(DuccUiConstants.parm_description)
.withDescription(makeDesc(DuccUiConstants.desc_description,DuccUiConstants.exmp_description)).hasArg()
.withLongOpt(DuccUiConstants.name_description).create());
- /*
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_notifications)
- .withDescription(makeDesc(DuccUiConstants.desc_notifications,DuccUiConstants.exmp_notifications)).hasArg()
- .withLongOpt(DuccUiConstants.name_notifications).create());
- */
options.addOption(OptionBuilder
.withArgName(DuccUiConstants.parm_scheduling_class)
.withDescription(makeDesc(DuccUiConstants.desc_scheduling_class,DuccUiConstants.exmp_scheduling_class)).hasArg()
.withLongOpt(DuccUiConstants.name_scheduling_class).create());
- /*
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_scheduling_priority)
- .withDescription(makeDesc(DuccUiConstants.desc_scheduling_priority,DuccUiConstants.exmp_scheduling_priority)).hasArg()
- .withLongOpt(DuccUiConstants.name_scheduling_priority).create());
- */
options.addOption(OptionBuilder
.withArgName(DuccUiConstants.parm_log_directory)
.withDescription(makeDesc(DuccUiConstants.desc_log_directory,DuccUiConstants.exmp_log_directory)).hasArg()
@@ -126,39 +112,6 @@ public class DuccServiceSubmit extends D
.withArgName(DuccUiConstants.parm_jvm)
.withDescription(makeDesc(DuccUiConstants.desc_jvm,DuccUiConstants.exmp_jvm)).hasArg()
.withLongOpt(DuccUiConstants.name_jvm).create());
- /*
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_driver_jvm_args)
- .withDescription(makeDesc(DuccUiConstants.desc_driver_jvm_args,DuccUiConstants.exmp_driver_jvm_args)).hasArg()
- .withLongOpt(DuccUiConstants.name_driver_jvm_args).create());
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_driver_classpath)
- .withDescription(makeDesc(DuccUiConstants.desc_driver_classpath,DuccUiConstants.exmp_driver_classpath)).hasArg()
- .withLongOpt(DuccUiConstants.name_driver_classpath).create());
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_driver_environment)
- .withDescription(makeDesc(DuccUiConstants.desc_driver_environment,DuccUiConstants.exmp_driver_environment)).hasArg()
- .withLongOpt(DuccUiConstants.name_driver_environment).create());
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_driver_memory_size)
- .withDescription(makeDesc(DuccUiConstants.desc_driver_memory_size,DuccUiConstants.exmp_driver_memory_size)).hasArg()
- .withLongOpt(DuccUiConstants.name_driver_memory_size).create());
- */
- // allo CR only so we can detect it and refuse it as a service
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_driver_descriptor_CR)
- .withDescription(makeDesc(DuccUiConstants.desc_driver_descriptor_CR,DuccUiConstants.exmp_driver_descriptor_CR)).hasArg()
- .withLongOpt(DuccUiConstants.name_driver_descriptor_CR).create());
- /*
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_driver_descriptor_CR_overrides)
- .withDescription(makeDesc(DuccUiConstants.desc_driver_descriptor_CR_overrides,DuccUiConstants.exmp_driver_descriptor_CR_overrides)).hasArg()
- .withLongOpt(DuccUiConstants.name_driver_descriptor_CR_overrides).create());
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_driver_exception_handler)
- .withDescription(makeDesc(DuccUiConstants.desc_driver_exception_handler,DuccUiConstants.exmp_driver_exception_handler)).hasArg()
- .withLongOpt(DuccUiConstants.name_driver_exception_handler).create());
- */
options.addOption(OptionBuilder
.withArgName(DuccUiConstants.parm_process_jvm_args)
.withDescription(makeDesc(DuccUiConstants.desc_process_jvm_args,DuccUiConstants.exmp_process_jvm_args)).hasArg()
@@ -175,34 +128,12 @@ public class DuccServiceSubmit extends D
.withArgName(DuccUiConstants.parm_process_memory_size)
.withDescription(makeDesc(DuccUiConstants.desc_process_memory_size,DuccUiConstants.exmp_process_memory_size)).hasArg()
.withLongOpt(DuccUiConstants.name_process_memory_size).create());
+ // <UIMA service only>
options.addOption(OptionBuilder
.withArgName(DuccUiConstants.parm_process_DD)
.withDescription(makeDesc(DuccUiConstants.desc_process_DD,DuccUiConstants.exmp_process_DD)).hasArg()
.withLongOpt(DuccUiConstants.name_process_DD).create());
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_process_descriptor_CM)
- .withDescription(makeDesc(DuccUiConstants.desc_process_descriptor_CM,DuccUiConstants.exmp_process_descriptor_CM)).hasArg()
- .withLongOpt(DuccUiConstants.name_process_descriptor_CM).create());
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_process_descriptor_CM_overrides)
- .withDescription(makeDesc(DuccUiConstants.desc_process_descriptor_CM_overrides,DuccUiConstants.exmp_process_descriptor_CM_overrides)).hasArg()
- .withLongOpt(DuccUiConstants.name_process_descriptor_CM_overrides).create());
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_process_descriptor_AE)
- .withDescription(makeDesc(DuccUiConstants.desc_process_descriptor_AE,DuccUiConstants.exmp_process_descriptor_AE)).hasArg()
- .withLongOpt(DuccUiConstants.name_process_descriptor_AE).create());
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_process_descriptor_AE_overrides)
- .withDescription(makeDesc(DuccUiConstants.desc_process_descriptor_AE_overrides,DuccUiConstants.exmp_process_descriptor_AE_overrides)).hasArg()
- .withLongOpt(DuccUiConstants.name_process_descriptor_AE_overrides).create());
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_process_descriptor_CC)
- .withDescription(makeDesc(DuccUiConstants.desc_process_descriptor_CC,DuccUiConstants.exmp_process_descriptor_CC)).hasArg()
- .withLongOpt(DuccUiConstants.name_process_descriptor_CC).create());
- options.addOption(OptionBuilder
- .withArgName(DuccUiConstants.parm_process_descriptor_CC_overrides)
- .withDescription(makeDesc(DuccUiConstants.desc_process_descriptor_CC_overrides,DuccUiConstants.exmp_process_descriptor_CC_overrides)).hasArg()
- .withLongOpt(DuccUiConstants.name_process_descriptor_CC_overrides).create());
+
options.addOption(OptionBuilder
.withArgName(DuccUiConstants.parm_process_deployments_max)
.withDescription(makeDesc(DuccUiConstants.desc_process_deployments_max,DuccUiConstants.exmp_process_deployments_max)).hasArg()
@@ -234,17 +165,15 @@ public class DuccServiceSubmit extends D
.withDescription(makeDesc(DuccUiConstants.desc_process_get_meta_time_max,DuccUiConstants.exmp_process_get_meta_time_max)).hasArg()
.withLongOpt(DuccUiConstants.name_process_get_meta_time_max).create());
options.addOption(OptionBuilder
+ .withArgName(DuccUiConstants.parm_classpath_order)
+ .withDescription(DuccUiConstants.desc_classpath_order).hasArg()
+ .withLongOpt(DuccUiConstants.name_classpath_order).create());
+ // </UIMA service only>
+ options.addOption(OptionBuilder
.withArgName(DuccUiConstants.parm_specification)
.withDescription(DuccUiConstants.desc_specification).hasArg()
.withLongOpt(DuccUiConstants.name_specification).create());
- /*
- options.addOption(OptionBuilder
- .withDescription(DuccUiConstants.desc_wait_for_completion).hasArg(false)
- .withLongOpt(DuccUiConstants.name_wait_for_completion).create());
- options.addOption(OptionBuilder
- .withDescription(DuccUiConstants.desc_submit_cancel_service_on_interrupt).hasArg(false)
- .withLongOpt(DuccUiConstants.name_submit_cancel_service_on_interrupt).create());
- */
+
options.addOption(OptionBuilder
.withArgName (DuccUiConstants.parm_service_dependency)
.withDescription(makeDesc(DuccUiConstants.desc_service_dependency,DuccUiConstants.exmp_service_dependency))
@@ -255,12 +184,13 @@ public class DuccServiceSubmit extends D
);
options.addOption(OptionBuilder
- .withLongOpt (RegistrationOption.ServiceCustomEndpoint.decode())
- .withDescription(RegistrationOption.ServiceCustomEndpoint.description())
- .withArgName (RegistrationOption.ServiceCustomEndpoint.argname())
+ .withLongOpt (RegistrationOption.ServiceRequestEndpoint.decode())
+ .withDescription(RegistrationOption.ServiceRequestEndpoint.description())
+ .withArgName (RegistrationOption.ServiceRequestEndpoint.argname())
.hasArg(true)
.create()
);
+
}
//**********
@@ -285,21 +215,12 @@ public class DuccServiceSubmit extends D
private static final long serialVersionUID = 1L;
{
- put("", Arrays.asList( ServiceRequestProperties.key_process_DD,
- ServiceRequestProperties.key_process_descriptor_CM,
- ServiceRequestProperties.key_process_descriptor_AE,
- ServiceRequestProperties.key_process_descriptor_CC
+ put("", Arrays.asList( ServiceRequestProperties.key_process_DD
));
}
};
private static final String consumer_list = ServiceRequestProperties.key_process_DD
- +", "
- +ServiceRequestProperties.key_process_descriptor_CM
- +", "
- +ServiceRequestProperties.key_process_descriptor_AE
- +", "
- +ServiceRequestProperties.key_process_descriptor_CC
;
private boolean has_consumer(Properties properties) {
@@ -330,10 +251,17 @@ public class DuccServiceSubmit extends D
private static final long serialVersionUID = 1L;
{
- put(ServiceRequestProperties.key_process_DD, Arrays.asList( ServiceRequestProperties.key_process_descriptor_CM,
- ServiceRequestProperties.key_process_descriptor_AE,
- ServiceRequestProperties.key_process_descriptor_CC
- ));
+ put(ServiceRequestProperties.key_service_type_uima, Arrays.asList( ServiceRequestProperties.key_service_type_other
+ ));
+
+ put(ServiceRequestProperties.key_service_type_other, Arrays.asList( ServiceRequestProperties.key_process_DD,
+ ServiceRequestProperties.key_process_deployments_max,
+ ServiceRequestProperties.key_process_initialization_failures_cap,
+ ServiceRequestProperties.key_process_failures_limit,
+ ServiceRequestProperties.key_process_thread_count,
+ ServiceRequestProperties.key_process_per_item_time_max,
+ ServiceRequestProperties.key_process_get_meta_time_max
+ ));
}
};
@@ -355,64 +283,29 @@ public class DuccServiceSubmit extends D
}
return retVal;
}
-
- //**********
-
- 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) {
- duccMessageProcessor.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(ServiceRequestProperties.key_process_thread_count);
- if(p_threads == null) {
- p_threads = DuccUiConstants.dval_process_thread_count;
- }
- long threads = Long.parseLong(p_threads);
- String p_procs = properties.getProperty(ServiceRequestProperties.key_process_deployments_max);
- if(p_procs == null) {
- long procs = limit / threads;
- p_procs = "unlimited";
- String a_procs = ""+procs;
- duccMessageProcessor.err(ServiceRequestProperties.key_process_deployments_max+": requested="+p_procs+" adjusted="+a_procs);
- properties.setProperty(ServiceRequestProperties.key_process_deployments_max, a_procs);
- retVal = true;
- }
- else {
- long procs = Long.parseLong(p_procs);
- if( (procs * threads) > limit ) {
- procs = limit / threads;
- String a_procs = ""+procs;
- duccMessageProcessor.err(ServiceRequestProperties.key_process_deployments_max+": requested="+p_procs+" adjusted="+a_procs);
- properties.setProperty(ServiceRequestProperties.key_process_deployments_max, a_procs);
- retVal = true;
- }
- }
- }
- catch(Throwable t) {
- duccMessageProcessor.throwable(t);
- }
- return retVal;
- }
-
+
+
+ /**
+ * - Verify that the minimum properties for a pop are here
+ * - Verify no illegal properties for a pop
+ */
+ private boolean verifyPopProperties(Properties props)
+ {
+ String[] required = {
+ "process_executable",
+ "process_memory_size",
+ "scheduling_class"
+ };
+ boolean answer = true;
+ for ( String k : required ) {
+ if ( ! props.containsKey(k) ) {
+ System.out.println("Missing required property: " + k);
+ answer = false;
+ }
+ }
+ return answer;
+ }
+
//**********
private String getDuccProperty(String propertyName, String defaultValue) {
@@ -429,29 +322,13 @@ public class DuccServiceSubmit extends D
return propertyValue;
}
- private void adjust_process_jvm_args(Properties serviceRequestProperties) {
- String additionalJvmArgs = getDuccProperty(DuccPropertiesResolver.ducc_submit_process_jvm_args, null);
- if(additionalJvmArgs != null) {
- String jvmArgs = serviceRequestProperties.getProperty(ServiceRequestProperties.key_process_jvm_args);
- if(jvmArgs == null) {
- jvmArgs = additionalJvmArgs;
- }
- else {
- jvmArgs += " "+additionalJvmArgs;
- }
- serviceRequestProperties.setProperty(ServiceRequestProperties.key_process_jvm_args, jvmArgs);
- }
- }
-
- private void adjust_jvm_args(Properties serviceRequestProperties) {
- adjust_process_jvm_args(serviceRequestProperties);
- }
-
/*
* resolve ${defaultBrokerURL} in service dependencies - must fail if resolution needed but can't resolve
*/
boolean resolve_service_dependencies(String endpoint, Properties props)
{
+ if ( serviceDeploymentType == ServiceDeploymentType.other) return true;
+
String deps = props.getProperty(ServiceRequestProperties.key_service_dependency);
try {
deps = DuccUiUtilities.resolve_service_dependencies(endpoint, deps, jvmargs);
@@ -464,7 +341,42 @@ public class DuccServiceSubmit extends D
return false;
}
}
-
+
+ protected void setServiceType(ServiceDeploymentType type)
+ {
+ this.serviceDeploymentType = type;
+ }
+
+ private ServiceDeploymentType getServiceType(ServiceRequestProperties serviceRequestProperties)
+ {
+ // some dude set this so we belive him -
+ if ( serviceDeploymentType != ServiceDeploymentType.unspecified ) return serviceDeploymentType;
+
+ // if the service type is NOT set, then it has to be some kind of service, see if there's an endpoint
+ String service_endpoint = serviceRequestProperties.getProperty(RegistrationOption.ServiceRequestEndpoint.decode());
+
+ // No end point, it HAS to be UIMA-AS and therefore requires a DD to be valid
+ if (service_endpoint == null) {
+ String dd = (String) serviceRequestProperties.get(ServiceRequestProperties.key_process_DD);
+ if ( dd != null ) {
+ return ServiceDeploymentType.uima;
+ } else {
+ throw new IllegalArgumentException("Missing service endpoint and DD, cannot identify service type.");
+ }
+ }
+
+ if ( service_endpoint.startsWith(ServiceType.Custom.decode()) ) {
+ return ServiceDeploymentType.custom;
+ }
+
+ if ( service_endpoint.startsWith(ServiceType.UimaAs.decode()) ) {
+ return ServiceDeploymentType.uima;
+ }
+
+
+ throw new IllegalArgumentException("Invalid service type in endpoint, must be " + ServiceType.UimaAs.decode() + " or " + ServiceType.Custom.decode() + ".");
+ }
+
//**********
protected int help(Options options) {
@@ -587,23 +499,6 @@ public class DuccServiceSubmit extends D
serviceRequestProperties.setProperty(name, value);
}
}
-
- //
- // Simple sanity checking in case somebody tries to submit a regular job as a service
- //
- String[] forbidden = {
- DuccUiConstants.name_driver_descriptor_CR,
- DuccUiConstants.name_process_descriptor_AE,
- DuccUiConstants.name_process_descriptor_CC,
- DuccUiConstants.name_process_descriptor_CM,
- };
- for (String s : forbidden) {
- String tmp = (String) serviceRequestProperties.get(s);
- if ( tmp != null ) {
- duccMessageProcessor.out("Job is not a service, it contains " + s);
- return DuccUiConstants.ERROR;
- }
- }
/*
* employ default log directory if not specified
@@ -627,14 +522,20 @@ public class DuccServiceSubmit extends D
}
}
}
- // tack on "services" to complete logging directory
+
+ // tack on "services" or "processes" to complete logging directory
+ String log_extension = "services";
+ if ( serviceDeploymentType == ServiceDeploymentType.other ) {
+ log_extension = "processes";
+ }
if(log_directory.endsWith(File.separator)) {
- log_directory = log_directory+"services";
+ log_directory = log_directory + log_extension;
}
else {
- log_directory = log_directory+File.separator+"services";
+ log_directory = log_directory + File.separator + log_extension;
}
serviceRequestProperties.setProperty(ServiceRequestProperties.key_log_directory,log_directory);
+
/*
* employ default working directory if not specified
*/
@@ -651,106 +552,123 @@ public class DuccServiceSubmit extends D
process_classpath = System.getProperty("java.class.path");
serviceRequestProperties.setProperty(ServiceRequestProperties.key_process_classpath,process_classpath);
}
- /*
- * employ default process initialization failures cap if not specified
- */
- String process_initialization_failures_cap = serviceRequestProperties.getProperty(ServiceRequestProperties.key_process_initialization_failures_cap);
- if(process_initialization_failures_cap == null) {
- serviceRequestProperties.setProperty(ServiceRequestProperties.key_process_initialization_failures_cap,DuccUiConstants.dval_process_initialization_failures_cap);
- }
-
-// /*
-// * employ default process failures limit if not specified
-// */
-// String process_failures_limit = serviceRequestProperties.getProperty(ServiceRequestProperties.key_process_failures_limit);
-// if(process_failures_limit == null) {
-// serviceRequestProperties.setProperty(ServiceRequestProperties.key_process_failures_limit,DuccUiConstants.dval_process_failures_limit);
+
+// if(serviceRequestProperties.containsKey(ServiceRequestProperties.key_service_type_custom)) {
+// serviceDeploymentType = ServiceDeploymentType.custom;
// }
-// /*
-// * employ default broker/endpoint if not specified
-// */
-// String broker = serviceRequestProperties.getProperty(ServiceRequestProperties.key_service_broker);
-// if(broker == null) {
- //String broker = DuccUiUtilities.buildBrokerUrl();
+// else if(serviceRequestProperties.containsKey(ServiceRequestProperties.key_service_type_other)) {
+// serviceDeploymentType = ServiceDeploymentType.other;
// }
- //if(serviceRequestProperties.containsKey(DuccUiConstants.name_debug)) {
- // System.out.println("broker:"+" "+broker);
- //}
-
- String service_endpoint = serviceRequestProperties.getProperty(RegistrationOption.ServiceCustomEndpoint.decode());
- if(service_endpoint == null) {
- // A null endpoint means it MUST be UimaAs. Otherwise it's the user's responsibility to
- // have it set correctly, because really can't tell.
-
- //
- // The service endpoint is extracted from the DD. It is for internal use only, not publicly settable or documented.
- //
- try {
- String dd = (String) serviceRequestProperties.get(ServiceRequestProperties.key_process_DD);
- String wd = (String) serviceRequestProperties.get(ServiceRequestProperties.key_working_directory);
- //System.err.println("DD: " + dd);
- //System.err.println("WD: " + wd);
- //System.err.println("jvmargs: " + jvmarg_string);
- service_endpoint = DuccUiUtilities.getEndpoint(wd, dd, jvmargs);
- } catch ( IllegalArgumentException e ) {
- duccMessageProcessor.exception(e);
- duccMessageProcessor.err("Cannot read/process DD descriptor for endpoint: " + e.getMessage());
- return DuccUiConstants.ERROR;
- }
- } else {
- // If there is an endpoint and it is UIMA-AS then it is used blindly, but might want resolution
- // If there is an endpoint and it is CUSTOM then it's a custom service which is not yet supported
+// else {
+// serviceRequestProperties.put(ServiceRequestProperties.key_service_type_uima, "");
+// //serviceDeploymentType = ServiceDeploymentType.uima;
+// }
+
+ try {
+ serviceDeploymentType = getServiceType(serviceRequestProperties);
+ } catch ( Throwable t ) {
+ System.out.println(t.getMessage());
+ return DuccUiConstants.ERROR;
+ }
+ String service_endpoint = serviceRequestProperties.getProperty(RegistrationOption.ServiceRequestEndpoint.decode());
+ switch(serviceDeploymentType) {
+ case uima:
+ serviceRequestProperties.put(ServiceRequestProperties.key_service_type_uima, "");
+ if(service_endpoint == null) {
+ // A null endpoint means it MUST be UimaAs and we are going to derive it. Otherwise it's the user's responsibility to
+ // have it set correctly, because really can't tell.
+ //
+ // The service endpoint is extracted from the DD. It is for internal use only, not publicly settable or documented.
+ //
+ try {
+ String dd = (String) serviceRequestProperties.get(ServiceRequestProperties.key_process_DD);
+ String wd = (String) serviceRequestProperties.get(ServiceRequestProperties.key_working_directory);
+ //System.err.println("DD: " + dd);
+ //System.err.println("WD: " + wd);
+ //System.err.println("jvmargs: " + jvmarg_string);
+ service_endpoint = DuccUiUtilities.getEndpoint(wd, dd, jvmargs);
+ serviceRequestProperties.put(ServiceRequestProperties.key_service_request_endpoint, service_endpoint);
+ if(serviceRequestProperties.containsKey(DuccUiConstants.name_debug)) {
+ duccMessageProcessor.out("service_endpoint:"+" "+service_endpoint);
+ }
+ } catch ( IllegalArgumentException e ) {
+ duccMessageProcessor.exception(e);
+ duccMessageProcessor.err("Cannot read/process DD descriptor for endpoint: " + e.getMessage());
+ return DuccUiConstants.ERROR;
+ }
+ } else {
+ serviceRequestProperties.put(ServiceRequestProperties.key_service_request_endpoint, service_endpoint);
+ }
+ break;
- if ( service_endpoint.startsWith(ServiceType.Custom.decode()) ) {
- duccMessageProcessor.out("CUSTOM services are not yet supported for submission.");
+ case custom:
+ serviceRequestProperties.put(ServiceRequestProperties.key_service_type_custom, "");
+ if ( service_endpoint == null ) {
+ duccMessageProcessor.err("Missing endpoint for CUSTOM service.");
+ return DuccUiConstants.ERROR;
+ } else {
+ serviceRequestProperties.put(ServiceRequestProperties.key_service_request_endpoint, service_endpoint);
+ }
+ break;
+
+ case other:
+ if ( ! verifyPopProperties(serviceRequestProperties) ) {
+ // called method emits messages
+ return DuccUiConstants.ERROR;
+ }
+ serviceRequestProperties.put(ServiceRequestProperties.key_service_type_other, "");
+ break;
+
+ case unspecified:
+ // messages are emitted in getServiceType
return DuccUiConstants.ERROR;
- }
}
- serviceRequestProperties.put(ServiceRequestProperties.key_service_request_endpoint, service_endpoint);
- if(serviceRequestProperties.containsKey(DuccUiConstants.name_debug)) {
- duccMessageProcessor.out("service_endpoint:"+" "+service_endpoint);
- }
+ if ( ! resolve_service_dependencies(service_endpoint, serviceRequestProperties) ) {
+ return DuccUiConstants.ERROR;
+ }
+
if(serviceRequestProperties.containsKey(DuccUiConstants.name_debug)) {
serviceRequestProperties.dump();
}
- if ( ! resolve_service_dependencies(service_endpoint, serviceRequestProperties) ) {
- return DuccUiConstants.ERROR;
+ // TODO: Need to rework these checks
+ if ( false ) {
+ /*
+ * check for required options
+ */
+ if (missing_required_options(serviceRequestProperties)) {
+ return DuccUiConstants.ERROR;
+ }
+ /*
+ * check for mutually exclusive options
+ */
+ if (has_mutually_exclusive_options(serviceRequestProperties)) {
+ return DuccUiConstants.ERROR;
+ }
+ /*
+ * check for minimum set of options
+ */
+ switch(serviceDeploymentType) {
+ case uima:
+ if (!has_consumer(serviceRequestProperties)) {
+ return DuccUiConstants.ERROR;
+ }
+ break;
+ }
}
-
- /*
- * check for required options
- */
- if (missing_required_options(serviceRequestProperties)) {
- return DuccUiConstants.ERROR;
- }
- /*
- * check for mutually exclusive options
- */
- if (has_mutually_exclusive_options(serviceRequestProperties)) {
- return DuccUiConstants.ERROR;
- }
- /*
- * check for minimum set of options
- */
- if (!has_consumer(serviceRequestProperties)) {
- return DuccUiConstants.ERROR;
- }
- /*
+
+ /*
* set DUCC_LD_LIBRARY_PATH in process environment
*/
if (!DuccUiUtilities.ducc_environment(duccMessageProcessor, serviceRequestProperties, ServiceRequestProperties.key_process_environment)) {
return DuccUiConstants.ERROR;
}
+
/*
- * limit total number of threads
- */
- adjust_max_threads(serviceRequestProperties);
- /*
- * adjust driver and process jvm args
+ * identify invoker
*/
- adjust_jvm_args(serviceRequestProperties);
+ serviceRequestProperties.setProperty(ServiceRequestProperties.key_submitter_pid_at_host, ManagementFactory.getRuntimeMXBean().getName());
/*
* send to JM & get reply
*/
@@ -886,9 +804,11 @@ public class DuccServiceSubmit extends D
public static void main(String[] args) {
try {
DuccServiceSubmit duccServiceSubmit = new DuccServiceSubmit();
- duccServiceSubmit.run(args);
+ int rc = duccServiceSubmit.run(args);
+ System.exit(rc == 0 ? 0 : 1);
} catch (Exception e) {
e.printStackTrace();
+ System.exit(1);
}
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccUiConstants.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccUiConstants.java?rev=1433537&r1=1433536&r2=1433537&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccUiConstants.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccUiConstants.java Tue Jan 15 17:24:37 2013
@@ -23,6 +23,7 @@ import org.apache.uima.ducc.common.utils
import org.apache.uima.ducc.transport.event.cli.JobRequestProperties;
import org.apache.uima.ducc.transport.event.cli.JobSpecificationProperties;
import org.apache.uima.ducc.transport.event.cli.ReservationSpecificationProperties;
+import org.apache.uima.ducc.transport.event.cli.ServiceRequestProperties;
public class DuccUiConstants {
@@ -56,7 +57,33 @@ public class DuccUiConstants {
public static final String labl_debug = "Debug";
public static final String exmp_debug = "";
public static final String dval_debug = null;
-
+
+ // Remote debug and console support
+ public static final String name_process_debug = JobRequestProperties.key_process_debug;
+ public static final String desc_process_debug = "Start remote Job Process in Eclipse debug mode.";
+ public static final String labl_process_debug = "ProcessDebug";
+ public static final String exmp_process_debug = "";
+ public static final String dval_process_debug = null;
+
+ public static final String name_driver_debug = JobRequestProperties.key_driver_debug;
+ public static final String desc_driver_debug = "Start remote Job Driver in Eclipse debug mode.";
+ public static final String labl_driver_debug = "DriverDebug";
+ public static final String exmp_driver_debug = "";
+ public static final String dval_driver_debug = null;
+
+ public static final String name_process_attach_console = JobRequestProperties.key_process_attach_console;
+ public static final String desc_process_attach_console = "Direct remote Job Process console to the local console.";
+ public static final String labl_process_attach_console = "ProcessAttachConsole";
+ public static final String exmp_process_attach_console = "";
+ public static final String dval_process_attach_console = null;
+
+ public static final String name_driver_attach_console = JobRequestProperties.key_driver_attach_console;
+ public static final String desc_driver_attach_console = "Direct remote Job Driver console to the local console.";
+ public static final String labl_driver_attach_console = "DriverAttachConsole";
+ public static final String exmp_driver_attach_console = "";
+ public static final String dval_driver_attach_console = null;
+ // End remote debug and console support
+
public static final String name_service_broker = JobRequestProperties.key_service_broker;
public static final String parm_service_broker = "address";
public static final String desc_service_broker = "Service broker.";
@@ -92,6 +119,14 @@ public class DuccUiConstants {
public static final String labl_reservation_id = "Reservation Id";
public static final String exmp_reservation_id = "1234";
public static final String dval_reservation_id = null;
+
+ public static final String name_service_id = JobRequestProperties.key_id;
+ public static final String parm_service_id = "number";
+ public static final String desc_service_id = "Service Id.";
+ public static final String labl_service_id = "Service Id";
+ public static final String exmp_service_id = "4321";
+ public static final String dval_service_id = null;
+
/*
* submit common
@@ -384,6 +419,27 @@ public class DuccUiConstants {
public static final String exmp_service = null;
public static final String dval_service = null;
+ public static final String name_service_type_uima = ServiceRequestProperties.key_service_type_uima; // default
+ public static final String parm_service_type_uima = null;
+ public static final String desc_service_type_uima = "UIMA service type.";
+ public static final String labl_service_type_uima = null;
+ public static final String exmp_service_type_uima = null;
+ public static final String dval_service_type_uima = null;
+
+ public static final String name_service_type_custom = ServiceRequestProperties.key_service_type_custom;
+ public static final String parm_service_type_custom = null;
+ public static final String desc_service_type_custom = "custom service type.";
+ public static final String labl_service_type_custom = null;
+ public static final String exmp_service_type_custom = null;
+ public static final String dval_service_type_custom = null;
+
+ public static final String name_service_type_other = ServiceRequestProperties.key_service_type_other;
+ public static final String parm_service_type_other = null;
+ public static final String desc_service_type_other = "other service type.";
+ public static final String labl_service_type_other = null;
+ public static final String exmp_service_type_other = null;
+ public static final String dval_service_type_other = null;
+
/*
* submit Reservation
*/