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 2014/06/12 22:21:47 UTC

svn commit: r1602284 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli: CliBase.java DuccServiceApi.java DuccUiUtilities.java

Author: burn
Date: Thu Jun 12 20:21:47 2014
New Revision: 1602284

URL: http://svn.apache.org/r1602284
Log:
UIMA-3872 Warn but ignore any broker URL decorations on UIMA-AS service IDs

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/DuccServiceApi.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccUiUtilities.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=1602284&r1=1602283&r2=1602284&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 Thu Jun 12 20:21:47 2014
@@ -178,12 +178,16 @@ public abstract class CliBase
 
     /*
      * Check the syntax & if a service refers to itself -- place-holders already resolved
+     * Strip any broker URL decorations
      */
     boolean check_service_dependencies(String endpoint)
     {
         String deps = cli_props.getProperty(UiOption.ServiceDependency.pname());
         try {
-            DuccUiUtilities.check_service_dependencies(endpoint, deps);                
+            String dependencies = DuccUiUtilities.check_service_dependencies(endpoint, deps);
+            if (dependencies != null) {
+                cli_props.setProperty(UiOption.ServiceDependency.pname(), dependencies);
+            }
             return true;
         } catch ( Throwable t ) {
             message("ERROR:", t.toString());

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=1602284&r1=1602283&r2=1602284&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 Thu Jun 12 20:21:47 2014
@@ -299,7 +299,7 @@ public class DuccServiceApi 
         String working_dir = cli_props.getStringProperty(UiOption.WorkingDirectory.pname());
         endpoint = DuccUiUtilities.getEndpoint(working_dir, dd, jvmargs);
         if ( debug ) {
-            System.out.println("Service endpoint resolves to " + endpoint);
+            System.out.println("DD service endpoint resolves to " + endpoint);
         }
         return endpoint;
     }
@@ -352,15 +352,19 @@ public class DuccServiceApi 
             // Given ep must match inferred ep. Use case: an application is wrapping DuccServiceApi and has to construct
             // the endpoint as well.  The app passes it in and we insure that the constructed endpoint matches the one
             // we extract from the DD - the job will fail otherwise, so we catch this early.
-            //
             String jvmarg_string = cli_props.getProperty(UiOption.ProcessJvmArgs.pname());
             String inferred_endpoint = extractEndpoint(jvmarg_string);
             if (endpoint == null) {
                 endpoint = inferred_endpoint;
-            } else if ( !inferred_endpoint.equals(endpoint) ) {
-                throw new IllegalArgumentException("Specified endpoint does not match endpoint extracted from UIMA DD" 
-                                                   + "\n --service_request_endpoint: " + endpoint 
-                                                   + "\n                  extracted: " + inferred_endpoint );
+            } else {
+                // Check & strip any broker URL decorations on the endpoint
+                endpoint = DuccUiUtilities.check_service_dependencies(null, endpoint);
+                cli_props.setProperty(UiOption.ServiceRequestEndpoint.pname(), endpoint);    // SM uses both endpoint definitions !!!
+                if ( !inferred_endpoint.equals(endpoint) ) {
+                    throw new IllegalArgumentException("Specified endpoint does not match endpoint extracted from UIMA DD" 
+                                                     + "\n --service_request_endpoint: " + endpoint 
+                                                     + "\n                  extracted: " + inferred_endpoint );
+                }
             }
 
             enrichPropertiesForDebug(UiOption.Register);

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=1602284&r1=1602283&r2=1602284&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 Thu Jun 12 20:21:47 2014
@@ -188,24 +188,20 @@ public class DuccUiUtilities {
      *
      * @param endpoint This is the endpoint of the caller itself, for resolution ( to make sure it can resolve.).  For
      *                 jobs this must be null.
-     * @param dependency_string This is the comma-delimited string of service ids "I" am dependent upon.
+     * @param dependency_string This is the whitespace-delimited string of service ids "I" am dependent upon.
+     * 
+     * @return (possibly) corrected list of dependencies
      */
-    public static void check_service_dependencies(String endpoint, String dependency_string) 
+    public static String check_service_dependencies(String endpoint, String dependency_string) 
     {
         if ( dependency_string == null ) {         // no dependencies to worry about
-            return;
+            return null;
         }
 
+        StringBuilder deps = new StringBuilder();
         for (String d : dependency_string.split("\\s+")) {
-            if (d.equals(endpoint)) {
-                throw new IllegalArgumentException("A service cannot depend on itself: " + d);
-            }
             String[] parts = d.split(":", 3);
             String type = parts[0];
-            if (!type.equals(ServiceType.UimaAs.decode()) && !type.equals(ServiceType.Custom.decode())) {
-                throw new IllegalArgumentException(
-                                "Ill-formed or unsupported service type in dependency: '" + d + "'");
-            }
 
             if (type.equals(ServiceType.UimaAs.decode())) {
                 // MUST have 2 ":" in it, and the broker must be a valid url
@@ -224,10 +220,26 @@ public class DuccUiUtilities {
                 try {
                     url = new URL(null, broker, new TcpStreamHandler());
                 } catch (MalformedURLException e) {
-                    throw new IllegalArgumentException("Invalid broker URL in service ID: " + broker);
+                    throw new IllegalArgumentException("Invalid broker URL '" + broker + "' in service ID '" + d + "'");
                 }
+                // Finally strip the decorations as they are not part of a service name
+                // (Could check with url.getQuery() but cannot easily rebuild without it)
+                int ix = broker.indexOf('?');
+                if ( ix > 0) {
+                    System.out.println("WARNING: Ignoring URL decorations on service ID " + d);
+                    d = parts[0] + ":" + parts[1] + ":" + broker.substring(0, ix); 
+                }
+            }  else if (!type.equals(ServiceType.Custom.decode())) {
+                throw new IllegalArgumentException(
+                        "Ill-formed or unsupported service type in dependency: '" + d + "'");
+            }
+            
+            if (d.equals(endpoint)) {
+                throw new IllegalArgumentException("A service cannot depend on itself: " + d);
             }
+            deps.append(d).append(" ");
         }
+        return deps.substring(0, deps.length()-1);
     }
 
     /*