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/09 18:54:05 UTC

svn commit: r1466121 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm: ServiceHandler.java ServiceSet.java

Author: challngr
Date: Tue Apr  9 16:54:04 2013
New Revision: 1466121

URL: http://svn.apache.org/r1466121
Log:
UIMA-2805
Resurrect submitted services.

Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceHandler.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceSet.java

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceHandler.java?rev=1466121&r1=1466120&r2=1466121&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceHandler.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-sm/src/main/java/org/apache/uima/ducc/sm/ServiceHandler.java Tue Apr  9 16:54:04 2013
@@ -447,10 +447,10 @@ public class ServiceHandler
         for ( DuccId id : work.keySet() ) {
             DuccWorkJob w = (DuccWorkJob) work.get(id);
 
+            //
             // On restart we sometimes get stale stuff that we just ignore.
             // What else? Is the the right thing to do?
             //  
-            // TODO: For registered services we probably have to call some sort of recovery code
             if ( !w.isActive() ) {
                 logger.info(methodName, id, "Bypassing inactive service, state=", w.getStateObject());
                 continue;
@@ -473,9 +473,10 @@ public class ServiceHandler
             if ( sset == null ) {
                 // submitted, we just track but not much else
                 try {
-                    sset = new ServiceSet(id, endpoint, deps);             // creates a "submitted" service
+                    sset = new ServiceSet(serviceManager.newId(), id, endpoint, deps);             // creates a "submitted" service
+                    sset.addImplementor(id, w.getJobState());
                     serviceStateHandler.putServiceByName(endpoint, sset);
-                } catch ( IllegalArgumentException e ) {
+                } catch ( Exception e ) {
                     s.addMessage(endpoint, e.getMessage());
                     s.setState(ServiceState.NotAvailable);
                     continue;
@@ -1396,7 +1397,7 @@ public class ServiceHandler
             String key = "UIMA-AS:" + svc + ":tcp://foo:123";
             ServiceSet dep = serviceStateHandler.getServiceByName(key);
             if ( dep == null ) {
-                dep = new ServiceSet(new DuccId(friendly++), key, null);
+                dep = new ServiceSet(new DuccId(friendly++), new DuccId(0), key, null);
                 serviceStateHandler.putServiceByName(key, dep);
                 allServices[ndx++] = dep;
             }
@@ -1411,7 +1412,7 @@ public class ServiceHandler
                 String subkey = "UIMA-AS:" + subsvc + ":tcp://foo:123";
                 ServiceSet subdep = serviceStateHandler.getServiceByName(subkey);
                 if ( subdep == null ) {
-                    subdep = new ServiceSet(new DuccId(friendly++), subkey, null);
+                    subdep = new ServiceSet(new DuccId(friendly++), new DuccId(0), subkey, null);
                     serviceStateHandler.putServiceByName(subkey, subdep);
                     allServices[ndx++] = subdep;
                 }

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=1466121&r1=1466120&r2=1466121&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 Tue Apr  9 16:54:04 2013
@@ -181,19 +181,45 @@ public class ServiceSet
 
     //
     // Constructor for a submitted service
-    // @deprecated
-    public ServiceSet(DuccId id, String key, String[] independentServices)
+    //
+    public ServiceSet(DuccId id, DuccId first_implementor, String key, String[] independentServices)
     {
-        // deprecating for now
-        throw new IllegalStateException("Submitted services not supported");
-        /**
         this.key = key;
-        this.implementors.put(id, JobState.Undefined);
+        this.id = id;
+        this.friendly_ids.put(first_implementor.getFriendly(), null);
+
         this.independentServices = independentServices;
         this.service_class = ServiceClass.Submitted;        
 
         parseEndpoint(key);
-        */
+
+        String state_dir = System.getProperty("DUCC_HOME") + "/state";
+
+        job_props = new DuccProperties();
+        job_props.put("service_ping_class", ServiceManagerComponent.default_ping_class);
+        job_props.put("service_ping_classpath", System.getProperty("java.class.path"));
+        job_props.put("service_ping_dolog", "false");
+        job_props.put("service_ping_timeout", ""+ServiceManagerComponent.meta_ping_timeout);
+        job_props.put("working_directory", System.getProperty("user.dir")); // whatever my current dir is
+        job_props.put("log_directory", System.getProperty("user.dir") + "/../logs");
+        //job_props.put("service_ping_jvm_args", "-Xmx50M");
+        props_filename = state_dir + "/services/" + id.toString() + ".svc";
+        saveServiceProperties();
+
+        meta_props = new DuccProperties();
+        meta_props.put("user", System.getProperty("user.name"));
+        meta_props.put("endpoint", key);
+        meta_props.put("service-class", ""+service_class.decode());
+        meta_props.put("service-type", ""+service_type.decode());
+        meta_props.put("stopped", ""+stopped);
+        meta_props.put("service-state", ""+getServiceState());
+        meta_props.put("ping-active", "false");
+        meta_props.put("service-alive",      "false");
+        meta_props.put("service-healthy",    "false");
+        meta_props.put("service-statistics", "N/A");
+        meta_props.put("implementors", ""+id.getFriendly());
+        meta_filename = state_dir + "/services/" + id.toString() + ".meta";
+        saveMetaProperties();
     }
 
     //
@@ -443,7 +469,11 @@ public class ServiceSet
      */
     public void addImplementor(DuccId id, JobState js)
     {
+        if ( isSubmitted() ) {
+            friendly_ids.put(id.getFriendly(), id);
+        }
         implementors.put(id, js);
+        persistImplementors();
     }
 
     void promote()
@@ -487,6 +517,11 @@ public class ServiceSet
         return (service_class == ServiceClass.Implicit);
     }
 
+    boolean isSubmitted()
+    {
+        return (service_class == ServiceClass.Submitted);
+    }
+
     boolean isRegistered()
     {
         return (service_class == ServiceClass.Registered) && (!deregistered);
@@ -625,7 +660,7 @@ public class ServiceSet
 
     synchronized void persistImplementors()
     {
-        if ( ! isRegistered() ) return;
+        if ( isImplicit() ) return;
 
         if ( friendly_ids.size() == 0 ) {
             meta_props.remove("implementors");
@@ -1030,13 +1065,15 @@ public class ServiceSet
     synchronized void pingExited()
     {
         String methodName = "pingExited";
+
         if ( serviceMeta != null ) {
             logger.warn(methodName, id, "Pinger exited voluntarily, setting state to Undefined. Endpoint", endpoint);
             setServiceState(ServiceState.Undefined);    // not really sure what state is. it will be
-                                                        // checked and updated next run through the
-                                                        // main state machine, and maybe ping restarted.
+            // checked and updated next run through the
+            // main state machine, and maybe ping restarted.
             serviceMeta = null;
         }
+
         if ( isImplicit() ) {
             deleteProperties();
         } else {
@@ -1052,7 +1089,8 @@ public class ServiceSet
             serviceMeta.stop();
             serviceMeta = null;
         }
-        if ( isImplicit() ) {
+
+        if ( !isRegistered() ) {
             deleteProperties();
         } else {
             saveMetaProperties();