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/03/01 12:45:49 UTC

svn commit: r1451567 - in /uima/sandbox/uima-ducc/trunk: uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/ uima-ducc-common/src/main/java/org/apache/uima/ducc/common/ uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/

Author: challngr
Date: Fri Mar  1 11:45:49 2013
New Revision: 1451567

URL: http://svn.apache.org/r1451567
Log:
UIMA-2665
Copy full dependency-string formatting into CLI for fast-fail on submit.
Check in ServiceSet for attempt to implicitly start a CUSTOM service and refuse it.
This update moves the TcpStreamHandler into common so both SM and CLI can use it to verify URIs.

Added:
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/TcpStreamHandler.java
Modified:
    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-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java

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=1451567&r1=1451566&r2=1451567&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 Fri Mar  1 11:45:49 2013
@@ -21,6 +21,8 @@ package org.apache.uima.ducc.cli;
 import java.io.IOException;
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -33,6 +35,7 @@ import javax.xml.parsers.DocumentBuilder
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
 import org.apache.uima.ducc.api.IDuccMessageProcessor;
+import org.apache.uima.ducc.common.TcpStreamHandler;
 import org.apache.uima.ducc.common.uima.UimaUtils;
 import org.apache.uima.ducc.common.utils.DuccPropertiesResolver;
 import org.apache.uima.ducc.common.utils.Utils;
@@ -327,11 +330,44 @@ public class DuccUiUtilities {
 
         for ( String d : deplist ) {
             d = d.trim();
-            if ( d.startsWith(ServiceType.UimaAs.decode()) || d.startsWith(ServiceType.Custom.decode()) ) {
+            if ( d.startsWith(ServiceType.UimaAs.decode() + ":") || d.startsWith(ServiceType.Custom.decode() + ":") ) {
                 String nextdep = Utils.resolvePlaceholders(d, jvmargs);                
                 if ( resolved.containsKey(nextdep) ) {
                     throw new IllegalArgumentException("Circular dependencies with " + nextdep);
                 }
+        
+                if ( d.startsWith(ServiceType.UimaAs.decode()) ) {
+                    // hard to know if this is a good EP or not but se do know that it MUST have 2 ":" in it, and the broker must be a valid url
+                    // UIMA-AS : queuename : broker
+                    // This code comes from SM:ServiceSet.parseEndpoint.  How best to generalize these?
+                    ndx = d.indexOf(":");
+                    if ( ndx <= 0 ) {
+                        throw new IllegalArgumentException("Invalid UIMA-AS service id: " + d);                        
+                    }
+
+                    d = d.substring(ndx+1);
+                    ndx = d.indexOf(":");
+                    if ( ndx <= 0 ) {
+                        throw new IllegalArgumentException("Invalid UIMA-AS service id (missing or invalid broker URL): " + d);
+                    }
+                    String qname    = d.substring(0, ndx).trim();
+                    String broker   = d.substring(ndx+1).trim();
+                    
+                    @SuppressWarnings("unused")
+                    // this IS unused, it is here only to insure the string is parsed as a URL
+					URL url = null;
+                    try {                
+                        url = new URL(null, broker, new TcpStreamHandler());
+                    } catch (MalformedURLException e) {
+                        throw new IllegalArgumentException("Invalid broker URL in service ID: " + broker);
+                    }
+                    
+                    if ( qname.equals("") || broker.equals("") ) {
+                        throw new IllegalArgumentException("The endpoint cannot be parsed.  Expecting UIMA-AS:Endpoint:Broker, received " + d);
+                    }
+                    
+                }
+                                            
                 resolved.put(nextdep, nextdep);
             } else {
                 throw new IllegalArgumentException("Ill-formed or unsuported service type in dependency: " + d);

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/TcpStreamHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/TcpStreamHandler.java?rev=1451567&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/TcpStreamHandler.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/TcpStreamHandler.java Fri Mar  1 11:45:49 2013
@@ -0,0 +1,18 @@
+package org.apache.uima.ducc.common;
+
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+
+public class TcpStreamHandler
+    extends URLStreamHandler
+{
+    public TcpStreamHandler() {}
+    
+    public URLConnection openConnection(URL u)
+    {
+        //throw new Exception("This protocol handler isn't expected to actually work.");
+        return null;
+    }
+}

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java?rev=1451567&r1=1451566&r2=1451567&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java Fri Mar  1 11:45:49 2013
@@ -39,6 +39,7 @@ import org.apache.uima.aae.client.UimaAs
 import org.apache.uima.adapter.jms.client.BaseUIMAAsynchronousEngine_impl;
 import org.apache.uima.ducc.cli.IServiceApi.RegistrationOption;
 import org.apache.uima.ducc.common.ServiceStatistics;
+import org.apache.uima.ducc.common.TcpStreamHandler;
 import org.apache.uima.ducc.common.utils.DuccLogger;
 import org.apache.uima.ducc.common.utils.DuccProperties;
 import org.apache.uima.ducc.common.utils.id.DuccId;
@@ -131,6 +132,10 @@ public class ServiceSet
         this.id = id;
         parseEndpoint(key);
 
+        if ( this.service_type == ServiceType.Custom ) {
+            throw new IllegalStateException("Custom services may not be referenced as Implicit services.");
+        }
+
         this.service_type = ServiceType.UimaAs;
         this.service_class = ServiceClass.Implicit;
 
@@ -270,16 +275,16 @@ public class ServiceSet
 			} catch (MalformedURLException e) {
                 throw new IllegalArgumentException("Invalid broker URL: " + broker);
 			}
-            broker_host = url.getHost();
-            broker_port = url.getPort();
+            this.broker_host = url.getHost();
+            this.broker_port = url.getPort();
 
-            if ( endpoint.equals("") || broker.equals("") ) {
+            if ( this.endpoint.equals("") || this.broker.equals("") ) {
                 throw new IllegalArgumentException("The endpoint cannot be parsed.  Expecting UIMA-AS:Endpoint:Broker, received " + key);
             }
         } else {
             this.service_type = ServiceType.Custom;
             int ndx = ep.indexOf(":");
-            endpoint = ep.substring(ndx+1);
+            this.endpoint = ep.substring(ndx+1);
         }
 
     }

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java?rev=1451567&r1=1451566&r2=1451567&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/UimaAsPing.java Fri Mar  1 11:45:49 2013
@@ -10,6 +10,7 @@ import org.apache.uima.aae.client.UimaAs
 import org.apache.uima.adapter.jms.client.BaseUIMAAsynchronousEngine_impl;
 import org.apache.uima.ducc.common.AServicePing;
 import org.apache.uima.ducc.common.ServiceStatistics;
+import org.apache.uima.ducc.common.TcpStreamHandler;
 import org.apache.uima.ducc.common.UimaAsServiceMonitor;
 import org.apache.uima.ducc.common.utils.SystemPropertyResolver;
 import org.apache.uima.resource.ResourceInitializationException;