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/09 14:09:14 UTC
svn commit: r1465982 - in /uima/sandbox/uima-ducc/trunk:
uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ uima-ducc-spawn/src/
Author: burn
Date: Tue Apr 9 12:09:14 2013
New Revision: 1465982
URL: http://svn.apache.org/r1465982
Log:
UIMA-2792 Further simplify callback to make it easy for client to capture the redirected logfile name and so create an equivalent log file
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/ConsoleListener.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DefaultCallback.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/DuccManagedReservationMonitor.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccMonitor.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IDuccCallback.java
uima/sandbox/uima-ducc/trunk/uima-ducc-spawn/src/ducc_ling.c
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=1465982&r1=1465981&r2=1465982&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 Tue Apr 9 12:09:14 2013
@@ -309,6 +309,13 @@ public abstract class CliBase
// .withDescription(makeDesc(DuccUiConstants.desc_driver_descriptor_CR,DuccUiConstants.exmp_driver_descriptor_CR)).hasArg()
// .withLongOpt(DuccUiConstants.name_driver_descriptor_CR).create());
+ // If given only a properties file convert to an array of strings for the parser
+ if (args == null) {
+ args = mkArgs(cli_props);
+ cli_props.clear();
+ }
+
+ // Initially don't check for required options as they may be in a specification file
options = makeOptions(opts, false);
commandLine = parser.parse(options, args);
@@ -322,7 +329,7 @@ public abstract class CliBase
usage(null);
}
- // Load the specificaiton file, if given on the command line. Note that registration
+ // Load the specification file, if given on the command line. Note that registration
// bypasses the somewhat redundant --specification kw so we check two options.
String spec1 = UiOption.Specification.pname();
String val = null;
@@ -347,6 +354,7 @@ public abstract class CliBase
cli_props.clear();
}
+ // Even if no specification file provided, re-parse and check for required options
options = makeOptions(opts, true);
commandLine = parser.parse(options, args);
enhanceProperties(commandLine, false);
@@ -558,9 +566,9 @@ public abstract class CliBase
sb.append(' ');
}
sb.append(e[i]);
- consoleCb.duccout(null, null, sb.toString());
+ consoleCb.duccout(sb.toString());
} else {
- consoleCb.duccout(null, null, e[0]);
+ consoleCb.duccout(e[0]);
}
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ConsoleListener.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ConsoleListener.java?rev=1465982&r1=1465981&r2=1465982&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ConsoleListener.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ConsoleListener.java Tue Apr 9 12:09:14 2013
@@ -188,7 +188,6 @@ class ConsoleListener
boolean shutdown = false;
ConsoleListener cl;
String remote_host;
- String logfile = "N/A";
static final String console_tag = "1002 CONSOLE_REDIRECT ";
int tag_len = 0;
@@ -201,6 +200,7 @@ class ConsoleListener
InetAddress ia = sock.getInetAddress();
remote_host = ia.getHostName();
+ consoleCb.host(remote_host);
tag_len = console_tag.length();
if ( debug ) System.out.println("===== Listener starting: " + remote_host + ":" + sock.getPort());
@@ -220,14 +220,15 @@ class ConsoleListener
void doWrite(String line)
{
if ( line.startsWith(console_tag) ) {
- logfile = line.substring(tag_len);
+ String logfile = line.substring(tag_len);
+ consoleCb.logfile(logfile);
return; // don't echo this
}
if ( do_console_out ) {
- consoleCb.consout(remote_host, (logfile == "N/A" ? null : logfile), line);
+ consoleCb.consout(line);
} else {
- consoleCb.duccout(remote_host, (logfile == "N/A" ? null : logfile), line);
+ consoleCb.duccout(line);
}
if ( line.startsWith("1001 Command launching...")) {
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DefaultCallback.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DefaultCallback.java?rev=1465982&r1=1465981&r2=1465982&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DefaultCallback.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DefaultCallback.java Tue Apr 9 12:09:14 2013
@@ -19,10 +19,10 @@
package org.apache.uima.ducc.cli;
-public class DefaultCallback
- implements IDuccCallback
-{
- public void duccout(String host, String logfile, String s)
+public class DefaultCallback implements IDuccCallback {
+ private String host;
+
+ public void duccout(String s)
{
if ( host == null ) {
System.out.println( s);
@@ -31,10 +31,19 @@ public class DefaultCallback
}
}
- public void consout(String host, String logfile, String s)
+ public void consout(String s)
{
System.out.println("[" + host + "] " + s);
}
+
+ @Override
+ public void host(String name) {
+ host = name;
+ }
+
+ @Override
+ public void logfile(String name) {
+ }
}
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=1465982&r1=1465981&r2=1465982&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 Apr 9 12:09:14 2013
@@ -85,7 +85,7 @@ public class DuccJobMonitor extends Ducc
boolean retVal = jobCancel.execute();
debug("cancel rc:"+retVal);
} catch (Exception e) {
- messageProcessor.duccout(null, null, e.toString());
+ messageProcessor.duccout(e.toString());
}
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationMonitor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationMonitor.java?rev=1465982&r1=1465981&r2=1465982&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationMonitor.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationMonitor.java Tue Apr 9 12:09:14 2013
@@ -74,7 +74,7 @@ public class DuccManagedReservationMonit
boolean retVal = managedReservationCancel.execute();
debug("cancel rc:"+retVal);
} catch (Exception e) {
- messageProcessor.duccout(null, null, e.toString());
+ messageProcessor.duccout(e.toString());
}
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccMonitor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccMonitor.java?rev=1465982&r1=1465981&r2=1465982&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccMonitor.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccMonitor.java Tue Apr 9 12:09:14 2013
@@ -212,31 +212,31 @@ public abstract class DuccMonitor {
protected void trace(String message) {
if(flag_trace.get()) {
- messageProcessor.duccout(null, null, timestamp(message));
+ messageProcessor.duccout(timestamp(message));
}
}
protected void debug(String message) {
if(flag_debug.get()) {
- messageProcessor.duccout(null, null, timestamp(message));
+ messageProcessor.duccout(timestamp(message));
}
}
protected void debug(Exception e) {
if(flag_debug.get()) {
- messageProcessor.duccout(null, null, e.toString());
+ messageProcessor.duccout(e.toString());
}
}
private void info(String message) {
if(flag_info.get()) {
- messageProcessor.duccout(null, null, timestamp(message));
+ messageProcessor.duccout(timestamp(message));
}
}
private void error(String message) {
if(flag_error.get()) {
- messageProcessor.duccout(null, null, timestamp(message));
+ messageProcessor.duccout(timestamp(message));
}
}
@@ -287,7 +287,7 @@ public abstract class DuccMonitor {
// DUCC_HOME
String ducc_home = Utils.findDuccHome();
if(ducc_home == null) {
- messageProcessor.duccout(null, null, "Missing required environment variable: DUCC_HOME");
+ messageProcessor.duccout("Missing required environment variable: DUCC_HOME");
return RC_FAILURE;
}
// Ingest ducc.properties
@@ -532,7 +532,7 @@ public abstract class DuccMonitor {
code = runInternal(args);
}
catch (Exception e) {
- messageProcessor.duccout(null, null, e.toString());
+ messageProcessor.duccout(e.toString());
}
debug("rc="+code);
return code;
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IDuccCallback.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IDuccCallback.java?rev=1465982&r1=1465981&r2=1465982&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IDuccCallback.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IDuccCallback.java Tue Apr 9 12:09:14 2013
@@ -3,32 +3,36 @@ package org.apache.uima.ducc.cli;
public interface IDuccCallback
{
/**
- * This method is called by relevent parts of the API with messages generated by DUCC,
+ * This method is called by relevant parts of the API with messages generated by DUCC,
* including console messages generated by ducc_ling, prior to it exec-ing into
* it's process.
*
- * @param host If not null, the name of the host that generated the message. This may
- * be null, indicating the host isn't known or is not relevent.
- *
- * @param filename If not null, the name of the log where this message would have been
- * logged if the console were not redirected to the API.
- *
* @param msg This is the logged message.
*/
- public void duccout(String host, String filename, String msg);
+ public void duccout(String msg);
/**
- * This method is called by relevent parts of the API with messages redirected
+ * This method is called by relevant parts of the API with messages redirected
* from the remote process.
*
- * @param host If not null, the name of the host that generated the message. This may
- * be null, indicating the host isn't known or is not relevent.
+ * @param msg This is the logged message.
+ */
+ public void consout(String msg);
+
+ /**
+ * This method is called when the name of the host generating the messages is known.
*
- * @param filename If not null, the name of the log where this message would have been
- * logged if the console were not redirected to the API.
+ * @param name The name of the host that generated the message.
+ */
+ public void host(String name);
+
+ /**
+ * This method is called with the name of the logfile that would have been written
+ * if the console had not been redirected to the consout method.
+ * It is not called if the console is not redirected.
*
- * @param msg This is the logged message.
+ * @param name The name of the logfile that would have been created.
*/
- public void consout(String host, String filename, String msg);
+ public void logfile(String name);
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-spawn/src/ducc_ling.c
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-spawn/src/ducc_ling.c?rev=1465982&r1=1465981&r2=1465982&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-spawn/src/ducc_ling.c (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-spawn/src/ducc_ling.c Tue Apr 9 12:09:14 2013
@@ -395,8 +395,6 @@ void redirect_to_file(char *filepath)
perror(buf);
exit(1);
}
-
- version(); // this gets echoed into the redirected log
}
/**
@@ -485,8 +483,6 @@ void redirect_to_socket(char *sockloc)
int rc0 = dup2(sock, 0);
int rc1 = dup2(sock, 1);
int rc2 = dup2(sock, 2);
-
- version(); // this gets echoed into the redirected log
}
/**
@@ -700,6 +696,8 @@ int main(int argc, char **argv, char **e
} else {
redirect_to_file(filepath);
}
+
+ version(); // this gets echoed into the redirected log
}
fprintf(stdout, "1001 Command launching...\n");