Author: cwiklik
Date: Mon Sep 17 16:46:02 2018
New Revision: 1841090

URL: http://svn.apache.org/viewvc?rev=1841090&view=rev
Log:
UIMA-5868 modified to handle admin stop event by ducc daemons

Modified:
    
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/AbstractDuccComponent.java

Modified: 
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/AbstractDuccComponent.java
URL: 
http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/AbstractDuccComponent.java?rev=1841090&r1=1841089&r2=1841090&view=diff
==============================================================================
--- 
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/AbstractDuccComponent.java
 (original)
+++ 
uima/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/component/AbstractDuccComponent.java
 Mon Sep 17 16:46:02 2018
@@ -49,6 +49,7 @@ import org.apache.camel.model.RouteDefin
 import org.apache.uima.ducc.common.admin.event.DuccAdminEvent;
 import org.apache.uima.ducc.common.admin.event.DuccAdminEventKill;
 import org.apache.uima.ducc.common.admin.event.DuccAdminEventQuiesceAndStop;
+import org.apache.uima.ducc.common.admin.event.DuccAdminEventStop;
 import org.apache.uima.ducc.common.crypto.Crypto;
 import 
org.apache.uima.ducc.common.exception.DuccComponentInitializationException;
 import org.apache.uima.ducc.common.exception.DuccConfigurationException;
@@ -632,18 +633,22 @@ public abstract class AbstractDuccCompon
       this.delegate = delegate;
     }
 
+    private boolean killOrStopEvent(Object event) {
+       return event instanceof DuccAdminEventKill ||
+                  event instanceof DuccAdminEventStop;
+    }
     public void process(final Exchange exchange) throws Exception {
         logger.info("AdminEventProcessor.process()", null, "Received Admin 
Message of Type:"
                     + exchange.getIn().getBody().getClass().getName());
         if ( !"agent".equals(System.getProperty("ducc.deploy.components"))) {
-            if (exchange.getIn().getBody() instanceof DuccAdminEventKill) {
+            if (killOrStopEvent(exchange.getIn().getBody() ) ) { 
                 // start a new thread to process the admin kill event. Need to 
do this
                 // so that Camel thread associated with admin channel can go 
back to
                 // its pool. Otherwise, we will not be able to stop the admin 
channel.
                 Thread th = new Thread(new Runnable() {
                    public void run() {
                       try {
-                        delegate.onDuccAdminKillEvent((DuccAdminEventKill) 
exchange.getIn().getBody());
+                        delegate.onDuccAdminKillEvent((DuccAdminEvent) 
exchange.getIn().getBody());
                       } catch (Exception e) {
 
                       }
@@ -655,31 +660,8 @@ public abstract class AbstractDuccCompon
             }          
         } else {
                // agent
-//             String targets = "agent@bluejws65,agent@bluejbb";
-//             DuccAdminEvent e =(DuccAdminEvent) exchange.getIn().getBody();
-//             DuccAdminEventQuiesceAndStop event = 
-//                             new 
DuccAdminEventQuiesceAndStop(targets,e.getUser(), e.getAuthBlock());
             handleAdminEvent((DuccAdminEvent) exchange.getIn().getBody());
         }
-        /*
-        if (exchange.getIn().getBody() instanceof DuccAdminEventKill) {
-            // start a new thread to process the admin kill event. Need to do 
this
-        // so that Camel thread associated with admin channel can go back to
-        // its pool. Otherwise, we will not be able to stop the admin channel.
-        Thread th = new Thread(new Runnable() {
-          public void run() {
-            try {
-              delegate.onDuccAdminKillEvent((DuccAdminEventKill) 
exchange.getIn().getBody());
-            } catch (Exception e) {
-
-            }
-          }
-        });
-        th.start();
-      } else {
-        handleAdminEvent((DuccAdminEvent) exchange.getIn().getBody());
-      }
-      */
     }
   }
 


Reply via email to