You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ch...@apache.org on 2013/04/02 20:36:18 UTC
svn commit: r1463661 -
/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/
Author: challngr
Date: Tue Apr 2 18:36:18 2013
New Revision: 1463661
URL: http://svn.apache.org/r1463661
Log:
UIMA-2792
Consolidate and simplify API callbacks.
Added:
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/IDuccCallback.java
- copied, changed from r1462479, uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IConsoleCallback.java
Removed:
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccletSubmit.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IConsoleCallback.java
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/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/DuccManagedReservationCancel.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/DuccManagedReservationSubmit.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/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/DuccUiUtilities.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/MonitorListener.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=1463661&r1=1463660&r2=1463661&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 2 18:36:18 2013
@@ -64,7 +64,7 @@ public abstract class CliBase
protected Map<String, UiOption> reverseOptions = new HashMap<String, UiOption>(); // for lookup by string-name
protected long friendlyId = -1;
- protected int returnCode = -1;
+ protected int returnCode = 1000;
protected DuccProperties cli_props;
protected ArrayList<String> errors = new ArrayList<String>();
@@ -78,7 +78,7 @@ public abstract class CliBase
protected ConsoleListener console_listener = null;
protected String host_address = "N/A";
protected boolean console_attach = false;
- protected IConsoleCallback consoleCb = null;
+ protected IDuccCallback consoleCb = null;
protected MonitorListener monitor_listener = null;
@@ -170,7 +170,7 @@ public abstract class CliBase
}
return true;
} catch ( Throwable t ) {
- addThrowable(t);
+ message("ERROR:", t.toString());
return false;
}
}
@@ -267,21 +267,22 @@ public abstract class CliBase
/**
* Use this init if you you need a console callback and use the default log location.
*/
- protected synchronized void init(String myClassName, UiOption[] opts, String[] args, DuccProperties cli_props, String host_s, String port_s, String servlet, IConsoleCallback consoleCb)
+ 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
{
this.init(myClassName, opts, args, cli_props, host_s, port_s, servlet, consoleCb, null);
}
- protected synchronized void init(String myClassName, UiOption[] opts, String[] args, DuccProperties cli_props, String host_s, String port_s, String servlet, IConsoleCallback consoleCb, String logExtension)
+ 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
{
if ( init_done ) return;
if ( consoleCb == null ) {
- consoleCb = new DefaultConsoleCallback();
+ this.consoleCb = new DefaultCallback();
+ } else {
+ this.consoleCb = consoleCb;
}
- this.consoleCb = consoleCb;
this.myClassName = myClassName;
ducc_home = Utils.findDuccHome();
@@ -411,7 +412,7 @@ public abstract class CliBase
Properties environment_properties = DuccUiUtilities.environmentMap(environment_string);
if (environment_properties.containsKey(source)) {
if (environment_properties.containsKey(target)) {
- addWarning(key + " environment conflict: " + target + " takes precedence over " + source);
+ message("WARN", key, " environment conflict:", target, "takes precedence over", source);
} else {
target += "="+environment_properties.getProperty(source);
environment_string += " "+target;
@@ -438,19 +439,19 @@ public abstract class CliBase
@SuppressWarnings("unchecked")
ArrayList<String> value_submit_warnings = (ArrayList<String>) properties.get(UiOption.SubmitWarnings.pname());
if(value_submit_warnings != null) {
- addMessage("Job"+" "+"warnings:");
+ message("Job warnings:");
Iterator<String> reasons = value_submit_warnings.iterator();
while(reasons.hasNext()) {
- addMessage(reasons.next());
+ message("WARN:", reasons.next());
}
}
@SuppressWarnings("unchecked")
ArrayList<String> value_submit_errors = (ArrayList<String>) properties.get(UiOption.SubmitErrors.pname());
if(value_submit_errors != null) {
- addError("Job"+" "+"errors:");
+ message("Job errors:");
Iterator<String> reasons = value_submit_errors.iterator();
while(reasons.hasNext()) {
- addError(reasons.next());
+ message("ERROR:", reasons.next());
}
rc = false;
}
@@ -527,56 +528,26 @@ public abstract class CliBase
return (String) cli_props.getProperty(key);
}
- synchronized void addWarning(String w)
- {
- this.warnings.add(w);
- }
-
-
- synchronized void addError(String e )
- {
- this.errors.add(e);
- }
-
- synchronized void addMessage(String m)
- {
- this.messages.add(m);
- }
-
- synchronized void addThrowable(Throwable t)
+ /**
+ * NOTE: We do NOT want to be intentionally throwing from the CLI. Pls pass e.getMessage() or
+ * e.toString() to this instead of throwing.
+ */
+ synchronized void message(String ... e )
{
- this.errors.add(t.toString());
- if ( debug ) {
- t.printStackTrace();
+ if ( e.length > 1 ) {
+ StringBuffer sb = new StringBuffer();
+ int i = 0;
+ for (i = 0; i < e.length - 1; i++) {
+ sb.append(e[i]);
+ sb.append(' ');
+ }
+ sb.append(e[i]);
+ consoleCb.duccout(null, null, sb.toString());
+ } else {
+ consoleCb.duccout(null, null, e[0]);
}
}
-
- synchronized void addErrors(ArrayList<String> e)
- {
- this.errors.addAll(e);
- }
-
- synchronized void addWarnings(ArrayList<String> w)
- {
- this.warnings.addAll(w);
- }
-
- synchronized public String[] getMessages()
- {
- return messages.toArray(new String[messages.size()]);
- }
-
- synchronized public String[] getWarnings()
- {
- return warnings.toArray(new String[warnings.size()]);
- }
-
- synchronized public String[] getErrors()
- {
- return errors.toArray(new String[errors.size()]);
- }
-
public int getReturnCode()
{
return returnCode;
@@ -616,8 +587,7 @@ public abstract class CliBase
(
cli_props.containsKey(UiOption.WaitForCompletion.pname()) ||
cli_props.containsKey(UiOption.CancelJobOnInterrupt.pname()) ||
- cli_props.containsKey(UiOption.CancelManagedReservationOnInterrupt.pname()) ||
- console_attach
+ cli_props.containsKey(UiOption.CancelManagedReservationOnInterrupt.pname())
);
if ( monitor_attach ) {
@@ -680,7 +650,7 @@ public abstract class CliBase
Thread t = new Thread(console_listener);
t.start();
} else {
- addWarning("Attermpt to start console but no console listener is defined.");
+ message("WARN: Attermpt to start console but no console listener is defined.");
}
}
@@ -701,7 +671,7 @@ public abstract class CliBase
{
if ( key != null ) {
if ( console_listener == null ) {
- addWarning("Attempt to set console port but listener is not running.");
+ message("WARN: Attempt to set console port but listener is not running.");
return;
}
@@ -747,43 +717,4 @@ public abstract class CliBase
return false;
}
- class DefaultConsoleCallback
- implements IConsoleCallback
- {
-
-// try {
-// if ((logfile == null) && line.startsWith(console_tag)) {
-// filename = line.substring(tag_len);
-// logfile = new BufferedOutputStream(new FileOutputStream(filename));
-
-// if ( debug ) System.out.println("Create logfile " + filename);
-// }
-// if (logfile != null) {
-// logfile.write(leader.getBytes());
-// logfile.write(' ');
-// logfile.write(line.getBytes());
-// logfile.write('\n');
-// logfile.flush();
-// } else {
-// if ( debug ) System.out.println("Bypass logfile");
-// }
-// } catch (Exception e) {
-// if ( first_error ) {
-// submit.addError("Cannot create or write log file[" + filename + "]: " + e.getMessage());
-// }
-// first_error = false;
-// }
-// consoleCb(leader + line);
-
- public void stdout(String host, String logfile, String s)
- {
- //System.out.println("[" + host + "." + logfile + "] " + s);
- System.out.println("[" + host + "] " + s);
- }
- public void stderr(String host, String logfile, String s)
- {
- System.out.println("[" + host + "." + logfile + "] " + s);
- }
- }
-
}
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=1463661&r1=1463660&r2=1463661&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 2 18:36:18 2013
@@ -46,11 +46,11 @@ class ConsoleListener
private boolean in_shutdown = false;
private boolean start_stdin = false;
- private IConsoleCallback consoleCb;
+ private IDuccCallback consoleCb;
// private int callers; // number of remote processes we expect to listen for
boolean debug = false;
- ConsoleListener(CliBase submit, IConsoleCallback consoleCb)
+ ConsoleListener(CliBase submit, IDuccCallback consoleCb)
throws Exception
{
this.submit = submit;
@@ -208,15 +208,23 @@ class ConsoleListener
cl.delete(sock.getPort());
}
+ boolean do_console_out = false;
void doWrite(String line)
{
if ( line.startsWith(console_tag) ) {
logfile = line.substring(tag_len);
return; // don't echo this
}
- if ( logfile.equals("N/A") ) return; // don't log until we get a log name
- if ( line.startsWith("1001 Command launching...") && ( !debug) ) return; // don't log duccling noise
- consoleCb.stdout(remote_host, logfile, line);
+
+ if ( do_console_out ) {
+ consoleCb.consout(remote_host, (logfile == "N/A" ? null : logfile), line);
+ } else {
+ consoleCb.duccout(remote_host, (logfile == "N/A" ? null : logfile), line);
+ }
+
+ if ( line.startsWith("1001 Command launching...")) {
+ do_console_out = true;
+ }
}
/**
Added: 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=1463661&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DefaultCallback.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DefaultCallback.java Tue Apr 2 18:36:18 2013
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.cli;
+
+
+public class DefaultCallback
+ implements IDuccCallback
+{
+ public void duccout(String host, String logfile, String s)
+ {
+ if ( host == null ) {
+ System.out.println( s);
+ } else {
+ System.out.println("[" + host + "] " + s);
+ }
+ }
+
+ public void consout(String host, String logfile, String s)
+ {
+ System.out.println("[" + host + "] " + s);
+ }
+}
+
+
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=1463661&r1=1463660&r2=1463661&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 Apr 2 18:36:18 2013
@@ -93,7 +93,7 @@ public class DuccJobCancel
try {
cancelJobReplyDuccEvent = (CancelJobReplyDuccEvent) dispatcher.dispatchAndWaitForDuccReply(cancelJobDuccEvent);
} catch (Exception e) {
- addError("Job not submitted: " + e.getMessage());
+ message("Job not submitted:", e.getMessage());
return false;
} finally {
dispatcher.close();
@@ -123,29 +123,6 @@ public class DuccJobCancel
DuccJobCancel djc = new DuccJobCancel(args);
boolean rc = djc.execute();
- // Fetch messages if any. null means none
- String [] messages = djc.getMessages();
- String [] warnings = djc.getWarnings();
- String [] errors = djc.getErrors();
-
- if ( messages != null ) {
- for (String s : messages ) {
- System.out.println(s);
- }
- }
-
- if ( warnings != null ) {
- for (String s : warnings ) {
- System.out.println("WARN: " + s);
- }
- }
-
- if ( errors != null ) {
- for (String s : errors ) {
- System.out.println("ERROR: " + s);
- }
- }
-
long id = djc.getDuccId();
String msg = djc.getResponseMessage();
long dpid = djc .getCanceledPid();
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=1463661&r1=1463660&r2=1463661&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 2 18:36:18 2013
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
-import org.apache.uima.ducc.api.IDuccMessageProcessor;
import org.apache.uima.ducc.cli.IUiOptions.UiOption;
import org.apache.uima.ducc.transport.event.IDuccContext.DuccContext;
@@ -34,7 +33,7 @@ public class DuccJobMonitor extends Ducc
super(DuccContext.Job, true);
}
- public DuccJobMonitor(IDuccMessageProcessor messageProcessor) {
+ public DuccJobMonitor(IDuccCallback messageProcessor) {
super(DuccContext.Job, true, messageProcessor);
}
@@ -44,7 +43,7 @@ public class DuccJobMonitor extends Ducc
}
@Deprecated
- public DuccJobMonitor(IDuccMessageProcessor messageProcessor, boolean quiet) {
+ public DuccJobMonitor(IDuccCallback messageProcessor, boolean quiet) {
super(DuccContext.Job, true, messageProcessor);
}
@@ -86,7 +85,7 @@ public class DuccJobMonitor extends Ducc
boolean retVal = jobCancel.execute();
debug("cancel rc:"+retVal);
} catch (Exception e) {
- messageProcessor.exception(e);
+q messageProcessor.duccout(null, null, e.toString());
}
}
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=1463661&r1=1463660&r2=1463661&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 Apr 2 18:36:18 2013
@@ -112,20 +112,20 @@ public class DuccJobSubmit
this(props, null);
}
- public DuccJobSubmit(ArrayList<String> args, IConsoleCallback consoleCb)
+ public DuccJobSubmit(ArrayList<String> args, IDuccCallback consoleCb)
throws Exception
{
String[] arg_array = args.toArray(new String[args.size()]);
init(this.getClass().getName(), opts, arg_array, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
}
- public DuccJobSubmit(String[] args, IConsoleCallback consoleCb)
+ public DuccJobSubmit(String[] args, IDuccCallback consoleCb)
throws Exception
{
init(this.getClass().getName(), opts, args, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
}
- public DuccJobSubmit(Properties props, IConsoleCallback consoleCb)
+ public DuccJobSubmit(Properties props, IDuccCallback consoleCb)
throws Exception
{
for ( Object k : props.keySet() ) {
@@ -197,7 +197,7 @@ public class DuccJobSubmit
}
}
catch(Throwable t) {
- addThrowable(t);
+ message(t.toString());
}
return limit;
}
@@ -220,7 +220,7 @@ public class DuccJobSubmit
long procs = limit / threads;
p_procs = "unlimited";
String a_procs = ""+procs;
- addMessage(UiOption.ProcessDeploymentsMax.pname() + ": requested[" + p_procs + "] adjusted to[" + a_procs + "]");
+ message(UiOption.ProcessDeploymentsMax.pname(), ": requested[" + p_procs + "] adjusted to[" + a_procs + "]");
properties.setProperty(UiOption.ProcessDeploymentsMax.pname(), a_procs);
retVal = true;
}
@@ -229,14 +229,14 @@ public class DuccJobSubmit
if( (procs * threads) > limit ) {
procs = limit / threads;
String a_procs = ""+procs;
- addMessage(UiOption.ProcessDeploymentsMax.pname()+": requested["+p_procs+"] adjusted to["+a_procs + "]");
+ message(UiOption.ProcessDeploymentsMax.pname(), ": requested["+p_procs+"] adjusted to["+a_procs + "]");
properties.setProperty(UiOption.ProcessDeploymentsMax.pname(), a_procs);
retVal = true;
}
}
}
catch(Throwable t) {
- addThrowable(t);
+ message(t.toString());
}
return retVal;
}
@@ -252,7 +252,7 @@ public class DuccJobSubmit
}
}
catch(Throwable t) {
- addThrowable(t);
+ message(t.toString());
}
return propertyValue;
}
@@ -287,7 +287,7 @@ public class DuccJobSubmit
try {
enrich_parameters_for_debug(jobRequestProperties);
} catch (Exception e1) {
- addThrowable(e1);
+ message(e1.toString());
return false;
}
@@ -366,7 +366,7 @@ public class DuccJobSubmit
try {
submitJobReplyDuccEvent = (SubmitJobReplyDuccEvent) dispatcher.dispatchAndWaitForDuccReply(submitJobDuccEvent);
} catch (Exception e) {
- addError("Job not submitted: " + e.getMessage());
+ message("Job not submitted: " + e.getMessage());
stopListeners();
return false;
} finally {
@@ -390,30 +390,7 @@ public class DuccJobSubmit
try {
DuccJobSubmit ds = new DuccJobSubmit(args, null);
boolean rc = ds.execute();
-
- // Fetch messages if any. null means none
- String [] messages = ds.getMessages();
- String [] warnings = ds.getWarnings();
- String [] errors = ds.getErrors();
-
- if ( messages != null ) {
- for (String s : messages ) {
- System.out.println(s);
- }
- }
-
- if ( warnings != null ) {
- for (String s : warnings ) {
- System.out.println("WARN: " + s);
- }
- }
-
- if ( errors != null ) {
- for (String s : errors ) {
- System.out.println("ERROR: " + s);
- }
- }
-
+
// If the return is 'true' then as best the API can tell, the submit worked
if ( rc ) {
// Fetch the Ducc ID
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationCancel.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationCancel.java?rev=1463661&r1=1463660&r2=1463661&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationCancel.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccManagedReservationCancel.java Tue Apr 2 18:36:18 2013
@@ -81,7 +81,7 @@ public class DuccManagedReservationCance
try {
cancelServiceReplyDuccEvent = (CancelServiceReplyDuccEvent) dispatcher.dispatchAndWaitForDuccReply(cancelServiceDuccEvent);
} catch (Exception e) {
- addError("Cancel not submitted: " + e.getMessage());
+ message("Cancel not submitted:", e.getMessage());
return false;
} finally {
dispatcher.close();
@@ -101,29 +101,6 @@ public class DuccManagedReservationCance
DuccManagedReservationCancel dsc = new DuccManagedReservationCancel(args);
boolean rc = dsc.execute();
- // Fetch messages if any. null means none
- String [] messages = dsc.getMessages();
- String [] warnings = dsc.getWarnings();
- String [] errors = dsc.getErrors();
-
- if ( messages != null ) {
- for (String s : messages ) {
- System.out.println(s);
- }
- }
-
- if ( warnings != null ) {
- for (String s : warnings ) {
- System.out.println("WARN: " + s);
- }
- }
-
- if ( errors != null ) {
- for (String s : errors ) {
- System.out.println("ERROR: " + s);
- }
- }
-
long id = dsc.getDuccId();
String msg = dsc.getResponseMessage();
String dtype = "Managed Reservation";
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=1463661&r1=1463660&r2=1463661&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 2 18:36:18 2013
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
-import org.apache.uima.ducc.api.IDuccMessageProcessor;
import org.apache.uima.ducc.cli.IUiOptions.UiOption;
import org.apache.uima.ducc.transport.event.IDuccContext.DuccContext;
@@ -34,7 +33,7 @@ public class DuccManagedReservationMonit
super(DuccContext.ManagedReservation, true);
}
- protected DuccManagedReservationMonitor(IDuccMessageProcessor messageProcessor) {
+ protected DuccManagedReservationMonitor(IDuccCallback messageProcessor) {
super(DuccContext.ManagedReservation, true, messageProcessor);
}
@@ -75,7 +74,7 @@ public class DuccManagedReservationMonit
boolean retVal = managedReservationCancel.execute();
debug("cancel rc:"+retVal);
} catch (Exception e) {
- messageProcessor.exception(e);
+ messageProcessor.duccout(null, null, e.toString());
}
}
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=1463661&r1=1463660&r2=1463661&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 Tue Apr 2 18:36:18 2013
@@ -78,14 +78,14 @@ public class DuccManagedReservationSubmi
this(props, null);
}
- public DuccManagedReservationSubmit(String[] args, IConsoleCallback consoleCb)
+ public DuccManagedReservationSubmit(String[] args, IDuccCallback consoleCb)
throws Exception
{
serviceRequestProperties = new ServiceRequestProperties();
init(this.getClass().getName(), opts, args, serviceRequestProperties, or_host, or_port, "or", consoleCb);
}
- public DuccManagedReservationSubmit(ArrayList<String> args, IConsoleCallback consoleCb)
+ public DuccManagedReservationSubmit(ArrayList<String> args, IDuccCallback consoleCb)
throws Exception
{
String[] arg_array = args.toArray(new String[args.size()]);
@@ -93,7 +93,7 @@ public class DuccManagedReservationSubmi
init(this.getClass().getName(), opts, arg_array, serviceRequestProperties, or_host, or_port, "or", consoleCb);
}
- public DuccManagedReservationSubmit(Properties props, IConsoleCallback consoleCb)
+ public DuccManagedReservationSubmit(Properties props, IDuccCallback consoleCb)
throws Exception
{
serviceRequestProperties = new ServiceRequestProperties();
@@ -127,7 +127,7 @@ public class DuccManagedReservationSubmi
try {
reply = (SubmitServiceReplyDuccEvent) dispatcher.dispatchAndWaitForDuccReply(ev);
} catch (Exception e) {
- addError(dt+" not submitted: " + e.getMessage());
+ message("ERROR:", dt, "not submitted:", e.toString());
return false;
} finally {
dispatcher.close();
@@ -141,13 +141,17 @@ public class DuccManagedReservationSubmi
@SuppressWarnings("unchecked")
ArrayList<String> or_warnings = (ArrayList<String>) properties.get(UiOption.SubmitWarnings.pname());
if (or_warnings != null) {
- addWarnings(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) {
- addErrors(or_errors);
+ for ( String s : or_errors ) {
+ message("ERROR:", s);
+ }
retval = false;
}
@@ -179,29 +183,6 @@ public class DuccManagedReservationSubmi
// started but this call does NOT block on it.
boolean rc = ds.execute();
- // Fetch messages if any. null means none
- String [] messages = ds.getMessages();
- String [] warnings = ds.getWarnings();
- String [] errors = ds.getErrors();
-
- if ( messages != null ) {
- for (String s : messages ) {
- System.out.println(s);
- }
- }
-
- if ( warnings != null ) {
- for (String s : warnings ) {
- System.out.println("WARN: " + s);
- }
- }
-
- if ( errors != null ) {
- for (String s : errors ) {
- System.out.println("ERROR: " + s);
- }
- }
-
// If the return is 'true' then as best the API can tell, the submit worked
if ( rc ) {
// Fetch the Ducc ID
@@ -210,7 +191,11 @@ public class DuccManagedReservationSubmi
if(ds.waitForCompletion()) {
code = ds.getReturnCode();
}
- System.out.println(dt+" return code: "+code);
+ 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);
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=1463661&r1=1463660&r2=1463661&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 2 18:36:18 2013
@@ -36,8 +36,6 @@ import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
-import org.apache.uima.ducc.api.DuccMessage;
-import org.apache.uima.ducc.api.IDuccMessageProcessor;
import org.apache.uima.ducc.cli.IUiOptions.UiOption;
import org.apache.uima.ducc.common.json.MonitorInfo;
import org.apache.uima.ducc.common.utils.DuccPropertiesResolver;
@@ -58,8 +56,6 @@ public abstract class DuccMonitor {
protected static final String StateCompleting = "Completing";
protected static final String StateCompleted = "Completed";
- protected IDuccMessageProcessor messageProcessor = new DuccMessage();
-
private Options options = new Options();
private UiOption[] opts = new UiOption[0];
@@ -84,6 +80,7 @@ public abstract class DuccMonitor {
private DuccPropertiesResolver duccPropertiesResolver = null;
private DuccContext context = null;
+ IDuccCallback messageProcessor = null;
private SynchronizedSimpleDateFormat sdf = new SynchronizedSimpleDateFormat("dd/MM/yyyy HH:mm:ss");
@@ -126,10 +123,10 @@ public abstract class DuccMonitor {
};
protected DuccMonitor(DuccContext context, boolean submit) {
- initialize(context, submit, null);
+ initialize(context, submit, new DefaultCallback());
}
- protected DuccMonitor(DuccContext context, boolean submit, IDuccMessageProcessor messageProcessor) {
+ protected DuccMonitor(DuccContext context, boolean submit, IDuccCallback messageProcessor) {
initialize(context, submit, messageProcessor);
}
@@ -154,7 +151,7 @@ public abstract class DuccMonitor {
return id;
}
- private void initialize(DuccContext context, boolean submit, IDuccMessageProcessor messageProcessor) {
+ private void initialize(DuccContext context, boolean submit, IDuccCallback messageProcessor) {
// context
this.context = context;
// submit
@@ -215,31 +212,31 @@ public abstract class DuccMonitor {
protected void trace(String message) {
if(flag_trace.get()) {
- messageProcessor.out(timestamp(message));
+ messageProcessor.duccout(null, null, timestamp(message));
}
}
protected void debug(String message) {
if(flag_debug.get()) {
- messageProcessor.out(timestamp(message));
+ messageProcessor.duccout(null, null, timestamp(message));
}
}
protected void debug(Exception e) {
if(flag_debug.get()) {
- messageProcessor.exception(e);
+ messageProcessor.duccout(null, null, e.toString());
}
}
private void info(String message) {
if(flag_info.get()) {
- messageProcessor.out(timestamp(message));
+ messageProcessor.duccout(null, null, timestamp(message));
}
}
private void error(String message) {
if(flag_error.get()) {
- messageProcessor.out(timestamp(message));
+ messageProcessor.duccout(null, null, timestamp(message));
}
}
@@ -290,7 +287,7 @@ public abstract class DuccMonitor {
// DUCC_HOME
String ducc_home = Utils.findDuccHome();
if(ducc_home == null) {
- messageProcessor.err("missing required environment variable: DUCC_HOME");
+ messageProcessor.duccout(null, null, "Missing required environment variable: DUCC_HOME");
return RC_FAILURE;
}
// Ingest ducc.properties
@@ -512,7 +509,7 @@ public abstract class DuccMonitor {
code = runInternal(args);
}
catch (Exception e) {
- messageProcessor.exception(e);
+ messageProcessor.duccout(null, null, e.toString());
}
debug("rc="+code);
return code;
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=1463661&r1=1463660&r2=1463661&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 Apr 2 18:36:18 2013
@@ -87,7 +87,7 @@ public class DuccReservationCancel
try {
cancelReservationReplyDuccEvent = (CancelReservationReplyDuccEvent) dispatcher.dispatchAndWaitForDuccReply(cancelReservationDuccEvent);
} catch (Exception e) {
- addError("Job not submitted: " + e.getMessage());
+ message("Job not submitted:", e.getMessage());
return false;
} finally {
dispatcher.close();
@@ -104,30 +104,7 @@ public class DuccReservationCancel
public static void main(String[] args) {
try {
DuccReservationCancel dsc = new DuccReservationCancel(args);
- boolean rc = dsc.execute();
-
- // Fetch messages if any. null means none
- String [] messages = dsc.getMessages();
- String [] warnings = dsc.getWarnings();
- String [] errors = dsc.getErrors();
-
- if ( messages != null ) {
- for (String s : messages ) {
- System.out.println(s);
- }
- }
-
- if ( warnings != null ) {
- for (String s : warnings ) {
- System.out.println("WARN: " + s);
- }
- }
-
- if ( errors != null ) {
- for (String s : errors ) {
- System.out.println("ERROR: " + s);
- }
- }
+ boolean rc = dsc.execute();
long id = dsc.getDuccId();
String msg = dsc.getResponseMessage();
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=1463661&r1=1463660&r2=1463661&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 Apr 2 18:36:18 2013
@@ -113,7 +113,7 @@ public class DuccReservationSubmit
try {
reply = (SubmitReservationReplyDuccEvent) dispatcher.dispatchAndWaitForDuccReply(ev);
} catch (Exception e) {
- addError("Reservation not submitted: " + e.getMessage());
+ message("Reservation not submitted:", e.getMessage());
return false;
} finally {
dispatcher.close();
@@ -151,29 +151,6 @@ public class DuccReservationSubmit
// started but this call does NOT block on it.
boolean rc = ds.execute();
- // Fetch messages if any. null means none
- String [] messages = ds.getMessages();
- String [] warnings = ds.getWarnings();
- String [] errors = ds.getErrors();
-
- if ( messages != null ) {
- for (String s : messages ) {
- System.out.println(s);
- }
- }
-
- if ( warnings != null ) {
- for (String s : warnings ) {
- System.out.println("WARN: " + s);
- }
- }
-
- if ( errors != null ) {
- for (String s : errors ) {
- System.out.println("ERROR: " + s);
- }
- }
-
// If the return is 'true' then as best the API can tell, the submit worked
if ( rc ) {
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=1463661&r1=1463660&r2=1463661&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 Apr 2 18:36:18 2013
@@ -48,6 +48,7 @@ public class DuccServiceApi
String sm_port = "ducc.sm.http.port";
String sm_host = "ducc.sm.http.node";
String endpoint = null;
+ IDuccCallback callback = null;
UiOption[] registration_options = {
UiOption.Help,
@@ -117,8 +118,9 @@ public class DuccServiceApi
UiOption.Query,
};
- public DuccServiceApi()
+ public DuccServiceApi(IDuccCallback cb)
{
+ this.callback = cb;
}
private Pair<Integer, String> getId(UiOption opt)
@@ -225,7 +227,7 @@ public class DuccServiceApi
throws Exception
{
DuccProperties dp = new DuccProperties();
- init(this.getClass().getName(), registration_options, args, dp, sm_host, sm_port, "sm", null, "services");
+ init(this.getClass().getName(), registration_options, args, dp, sm_host, sm_port, "sm", callback, "services");
//
// Now: get jvm args and resolve placeholders, in particular, the broker url
@@ -303,7 +305,7 @@ public class DuccServiceApi
throws Exception
{
DuccProperties dp = new DuccProperties();
- init(this.getClass().getName(), unregister_options, args, dp, sm_host, sm_port, "sm", null, "services");
+ init(this.getClass().getName(), unregister_options, args, dp, sm_host, sm_port, "sm", callback, "services");
Pair<Integer, String> id = getId(UiOption.Unregister);
String user = dp.getProperty(UiOption.User.pname());
@@ -327,7 +329,7 @@ public class DuccServiceApi
throws Exception
{
DuccProperties dp = new DuccProperties();
- init(this.getClass().getName(), start_options, args, dp, sm_host, sm_port, "sm", null, "services");
+ init(this.getClass().getName(), start_options, args, dp, sm_host, sm_port, "sm", callback, "services");
Pair<Integer, String> id = getId(UiOption.Start);
String user = dp.getProperty(UiOption.User.pname());
@@ -357,7 +359,7 @@ public class DuccServiceApi
throws Exception
{
DuccProperties dp = new DuccProperties();
- init(this.getClass().getName(), stop_options, args, dp, sm_host, sm_port, "sm", null, "services");
+ init(this.getClass().getName(), stop_options, args, dp, sm_host, sm_port, "sm", callback, "services");
Pair<Integer, String> id = getId(UiOption.Stop);
String user = dp.getProperty(UiOption.User.pname());
@@ -385,7 +387,7 @@ public class DuccServiceApi
throws Exception
{
DuccProperties dp = new DuccProperties();
- init(this.getClass().getName(), modify_options, args, dp, sm_host, sm_port, "sm", null, "services");
+ init(this.getClass().getName(), modify_options, args, dp, sm_host, sm_port, "sm", callback, "services");
Pair<Integer, String> id = getId(UiOption.Modify);
String user = dp.getProperty(UiOption.User.pname());
@@ -415,7 +417,7 @@ public class DuccServiceApi
throws Exception
{
DuccProperties dp = new DuccProperties();
- init(this.getClass().getName(), query_options, args, dp, sm_host, sm_port, "sm", null, "services");
+ init(this.getClass().getName(), query_options, args, dp, sm_host, sm_port, "sm", callback, "services");
Pair<Integer, String> id = null;
String sid = cli_props.getProperty(UiOption.Query.pname()).trim();
@@ -498,7 +500,7 @@ public class DuccServiceApi
static boolean Register(String[] args)
throws Exception
{
- DuccServiceApi api = new DuccServiceApi();
+ DuccServiceApi api = new DuccServiceApi(null);
IServiceReply reply = api.register(args);
return format_reply(UiOption.Register, reply);
}
@@ -506,7 +508,7 @@ public class DuccServiceApi
static boolean Unregister(String[] args)
throws Exception
{
- DuccServiceApi api = new DuccServiceApi();
+ DuccServiceApi api = new DuccServiceApi(null);
IServiceReply reply = api.unregister(args);
return format_reply(UiOption.Unregister, reply);
}
@@ -514,7 +516,7 @@ public class DuccServiceApi
static boolean Start(String[] args)
throws Exception
{
- DuccServiceApi api = new DuccServiceApi();
+ DuccServiceApi api = new DuccServiceApi(null);
IServiceReply reply = api.start(args);
return format_reply(UiOption.Start, reply);
}
@@ -522,7 +524,7 @@ public class DuccServiceApi
static boolean Stop(String[] args)
throws Exception
{
- DuccServiceApi api = new DuccServiceApi();
+ DuccServiceApi api = new DuccServiceApi(null);
IServiceReply reply = api.stop(args);
return format_reply(UiOption.Stop, reply);
}
@@ -530,7 +532,7 @@ public class DuccServiceApi
static boolean Modify(String[] args)
throws Exception
{
- DuccServiceApi api = new DuccServiceApi();
+ DuccServiceApi api = new DuccServiceApi(null);
IServiceReply reply = api.modify(args);
return format_reply(UiOption.Modify, reply);
}
@@ -538,14 +540,14 @@ public class DuccServiceApi
static boolean Query(String[] args)
throws Exception
{
- DuccServiceApi api = new DuccServiceApi();
+ DuccServiceApi api = new DuccServiceApi(null);
IServiceReply reply = api.query(args);
return format_reply(UiOption.Query, reply);
}
static void Help()
{
- DuccServiceApi api = new DuccServiceApi();
+ DuccServiceApi api = new DuccServiceApi(null);
api.help();
System.exit(1);
}
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=1463661&r1=1463660&r2=1463661&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 Apr 2 18:36:18 2013
@@ -97,7 +97,7 @@ public class DuccServiceCancel
try {
cancelServiceReplyDuccEvent = (CancelServiceReplyDuccEvent) dispatcher.dispatchAndWaitForDuccReply(cancelServiceDuccEvent);
} catch (Exception e) {
- addError("Job not submitted: " + e.getMessage());
+ message("Job not submitted:", e.getMessage());
return false;
} finally {
dispatcher.close();
@@ -121,29 +121,6 @@ public class DuccServiceCancel
DuccServiceCancel dsc = new DuccServiceCancel(args);
boolean rc = dsc.execute();
- // Fetch messages if any. null means none
- String [] messages = dsc.getMessages();
- String [] warnings = dsc.getWarnings();
- String [] errors = dsc.getErrors();
-
- if ( messages != null ) {
- for (String s : messages ) {
- System.out.println(s);
- }
- }
-
- if ( warnings != null ) {
- for (String s : warnings ) {
- System.out.println("WARN: " + s);
- }
- }
-
- if ( errors != null ) {
- for (String s : errors ) {
- System.out.println("ERROR: " + s);
- }
- }
-
long id = dsc.getDuccId();
String msg = dsc.getResponseMessage();
String dtype = dsc.isService() ? "Service " : "Process ";
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=1463661&r1=1463660&r2=1463661&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 Apr 2 18:36:18 2013
@@ -134,7 +134,7 @@ public class DuccServiceSubmit
try {
deploymentType = getServiceType(requestProperties);
} catch ( Throwable t ) {
- addError(t.getMessage());
+ message(t.toString());
return false;
}
@@ -161,7 +161,7 @@ public class DuccServiceSubmit
System.out.println("service_endpoint:"+" "+service_endpoint);
}
} catch ( IllegalArgumentException e ) {
- addError("Cannot read/process DD descriptor for endpoint: " + e.getMessage());
+ message("ERROR: Cannot read/process DD descriptor for endpoint:", e.getMessage());
return false;
}
} else {
@@ -172,7 +172,7 @@ public class DuccServiceSubmit
case custom:
requestProperties.put(UiOption.ServiceTypeCustom.pname(), "");
if ( service_endpoint == null ) {
- addError("Missing endpoint for CUSTOM service.");
+ message("ERROR: Missing endpoint for CUSTOM service.");
return false;
} else {
requestProperties.put(UiOption.ServiceRequestEndpoint.pname(), service_endpoint);
@@ -205,7 +205,7 @@ public class DuccServiceSubmit
try {
reply = (SubmitServiceReplyDuccEvent) dispatcher.dispatchAndWaitForDuccReply(ev);
} catch (Exception e) {
- addError("Process not submitted: " + e.getMessage());
+ message("Process not submitted:", e.getMessage());
return false;
} finally {
dispatcher.close();
@@ -232,29 +232,6 @@ public class DuccServiceSubmit
// started but this call does NOT block on it.
boolean rc = ds.execute();
- // Fetch messages if any. null means none
- String [] messages = ds.getMessages();
- String [] warnings = ds.getWarnings();
- String [] errors = ds.getErrors();
-
- if ( messages != null ) {
- for (String s : messages ) {
- System.out.println(s);
- }
- }
-
- if ( warnings != null ) {
- for (String s : warnings ) {
- System.out.println("WARN: " + s);
- }
- }
-
- if ( errors != null ) {
- for (String s : errors ) {
- System.out.println("ERROR: " + s);
- }
- }
-
// If the return is 'true' then as best the API can tell, the submit worked
if ( rc ) {
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccUiUtilities.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccUiUtilities.java?rev=1463661&r1=1463660&r2=1463661&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccUiUtilities.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccUiUtilities.java Tue Apr 2 18:36:18 2013
@@ -140,7 +140,7 @@ public class DuccUiUtilities {
Properties environment_properties = environmentMap(environment_string);
if(environment_properties.containsKey(source)) {
if(environment_properties.containsKey(target)) {
- base.addError(key+" "+"environment conflict: "+target+" takes precedence over "+source);
+ base.message("ERROR:", key, "environment conflict:", target, "takes precedence over", source);
}
else {
target += "="+environment_properties.getProperty(source);
Copied: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IDuccCallback.java (from r1462479, uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IConsoleCallback.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?p2=uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IDuccCallback.java&p1=uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IConsoleCallback.java&r1=1462479&r2=1463661&rev=1463661&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IConsoleCallback.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IDuccCallback.java Tue Apr 2 18:36:18 2013
@@ -1,7 +1,34 @@
package org.apache.uima.ducc.cli;
-public interface IConsoleCallback
+public interface IDuccCallback
{
- public void stdout(String host, String filename, String msg);
- public void stderr(String host, String filename, String msg);
+ /**
+ * This method is called by relevent 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);
+
+
+ /**
+ * This method is called by relevent 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 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 consout(String host, String filename, String msg);
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/MonitorListener.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/MonitorListener.java?rev=1463661&r1=1463660&r2=1463661&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/MonitorListener.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/MonitorListener.java Tue Apr 2 18:36:18 2013
@@ -83,7 +83,7 @@ class MonitorListener
}
retVal = monitor.run(argList);
} catch (Exception e) {
- base.addMessage(e.getMessage());
+ base.message(e.toString());
retVal = DuccUiConstants.ERROR;
}
base.monitorExits(retVal);