Author: cwiklik
Date: Fri Feb  5 18:52:19 2016
New Revision: 1728727

URL: http://svn.apache.org/viewvc?rev=1728727&view=rev
Log:
UIMA-4787 Use same code to start Camel route for JP and AP processes

Modified:
    
uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/launcher/CommandExecutor.java

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/launcher/CommandExecutor.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/launcher/CommandExecutor.java?rev=1728727&r1=1728726&r2=1728727&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/launcher/CommandExecutor.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/launcher/CommandExecutor.java
 Fri Feb  5 18:52:19 2016
@@ -22,6 +22,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.Callable;
 
+import org.apache.camel.Route;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.uima.ducc.agent.NodeAgent;
 import org.apache.uima.ducc.common.utils.DuccLogger;
@@ -61,10 +62,59 @@ public abstract class CommandExecutor im
         */
        protected void postExecStep(java.lang.Process process, DuccLogger 
logger,
                        boolean isKillCmd) {
+           String methodName="postExecStep";
+
                if (!isKillCmd) {
                        int pid = Utils.getPID(process);
                        if (pid != -1) {
                                ((ManagedProcess) 
managedProcess).setPid(String.valueOf(pid));
+
+
+                                       if (!((ManagedProcess) 
managedProcess).getDuccProcess()
+                                                       
.getProcessState().equals(ProcessState.Stopped)) {
+                                               ((ManagedProcess) 
managedProcess).getDuccProcess()
+                                                               
.setProcessState(ProcessState.Running);
+                                       }
+                                       
+                                       try {
+                                           synchronized(this) {
+                                               // wait for 5 seconds before 
starting the camel route
+                                               // responsible for collecting 
process related stats. Allow
+                                               // enough time for the process 
to start.
+                                               wait(5000); 
+                         
+                                           }
+                                           RouteBuilder rb = agent.new 
ProcessMemoryUsageRoute(agent, 
+                                                                       
((ManagedProcess) managedProcess).getDuccProcess(),
+                                           (ManagedProcess) managedProcess);
+                                           agent.getContext().addRoutes(rb);
+                                           
+                                           
agent.getContext().startRoute(String.valueOf(pid));
+                                           logger.info(
+                                                       methodName,
+                                                       null,
+                                                       "Started Process Metric 
Gathering Thread For PID:"+String.valueOf(pid));
+
+
+                                           StringBuffer sb = new 
StringBuffer();
+                                           for ( Route route : 
agent.getContext().getRoutes() ) {
+                                               sb.append("Camel Context - 
RouteId:"+route.getId()+"\n");
+                                           }
+                                           logger.info(
+                                                       methodName,
+                                                       null,
+                                                       sb.toString());
+            
+                                           logger.info(
+                                                       methodName,
+                                                       null,
+                                                       "Started Process Metric 
Gathering Thread For PID:"+String.valueOf(pid));
+
+
+                                       } catch( Exception e) {
+                                           logger.error("postExecStep", null, 
e);
+                                       }
+                               /*
                                if (!((ManagedProcess) 
managedProcess).getDuccProcess()
                                                .getProcessType()
                                                
.equals(ProcessType.Job_Uima_AS_Process)) {
@@ -76,23 +126,24 @@ public abstract class CommandExecutor im
                                                                
.setProcessState(ProcessState.Running);
                                        }
                                        
-          try {
-                 synchronized(this) {
-                         // wait for 5 seconds before starting the camel route
-                         // responsible for collecting process related stats. 
Allow
-                         // enough time for the process to start.
-                         wait(5000); 
+                                       try {
+                                           synchronized(this) {
+                                               // wait for 5 seconds before 
starting the camel route
+                                               // responsible for collecting 
process related stats. Allow
+                                               // enough time for the process 
to start.
+                                               wait(5000); 
                          
-                 }
-            RouteBuilder rb = agent.new ProcessMemoryUsageRoute(agent, 
-                    ((ManagedProcess) managedProcess).getDuccProcess(),
-                    (ManagedProcess) managedProcess);
-            agent.getContext().addRoutes(rb);
+                                           }
+                                           RouteBuilder rb = agent.new 
ProcessMemoryUsageRoute(agent, 
+                                                                       
((ManagedProcess) managedProcess).getDuccProcess(),
+                                           (ManagedProcess) managedProcess);
+                                           agent.getContext().addRoutes(rb);
           
-          } catch( Exception e) {
-            logger.error("postExecStep", null, e);
-          }
+                                       } catch( Exception e) {
+                                           logger.error("postExecStep", null, 
e);
+                                       }
                                }
+                               */
                        }
                }
 


Reply via email to