You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2014/04/02 21:25:04 UTC
svn commit: r1584139 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent:
NodeAgent.java config/AgentConfiguration.java
Author: cwiklik
Date: Wed Apr 2 19:25:03 2014
New Revision: 1584139
URL: http://svn.apache.org/r1584139
Log:
UIMA-3718 Modified to remove Camel route for a process that exits
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java
uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/AgentConfiguration.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java?rev=1584139&r1=1584138&r2=1584139&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java Wed Apr 2 19:25:03 2014
@@ -42,6 +42,7 @@ import org.apache.camel.CamelContext;
import org.apache.camel.Processor;
import org.apache.camel.Route;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
import org.apache.commons.lang.SerializationUtils;
import org.apache.uima.ducc.agent.config.AgentConfiguration;
import org.apache.uima.ducc.agent.event.ProcessLifecycleObserver;
@@ -959,6 +960,16 @@ public class NodeAgent extends AbstractD
RouteBuilder rb = new ProcessMemoryUsageRoute(this, processEntry.getValue(),
deployedProcess);
super.getContext().addRoutes(rb);
+ StringBuffer sb = new StringBuffer();
+
+ for ( Route route : super.getContext().getRoutes() ) {
+ sb.append("Camel Context - RouteId:"+route.getId()+"\n");
+ }
+ logger.info(
+ methodName,
+ null,
+ sb.toString());
+
logger.info(
methodName,
null,
@@ -968,6 +979,24 @@ public class NodeAgent extends AbstractD
|| duccEvent.getState().equals(ProcessState.Failed)
|| duccEvent.getState().equals(ProcessState.Killed)) {
super.getContext().stopRoute(duccEvent.getPid());
+
+ // remove route from context, otherwise the routes accumulate over time causing memory leak
+ super.getContext().removeRoute(duccEvent.getPid());
+ StringBuffer sb = new StringBuffer();
+ logger.info(
+ methodName,
+ null,
+ "Removed Camel Route from Context for PID:"+duccEvent.getPid());
+
+ for ( Route route : super.getContext().getRoutes() ) {
+ sb.append("Camel Context - RouteId:"+route.getId()+"\n");
+ }
+ logger.info(
+ methodName,
+ null,
+ sb.toString());
+
+
if ( deployedProcess.getMetricsProcessor() != null ) {
deployedProcess.getMetricsProcessor().close(); // close open fds (stat and statm files)
}
@@ -1180,14 +1209,26 @@ public class NodeAgent extends AbstractD
ProcessStateUpdate processStateUpdate = new ProcessStateUpdate(process.getProcessState(),
process.getPID(), process.getDuccId().getUnique());
ProcessStateUpdateDuccEvent event = new ProcessStateUpdateDuccEvent(processStateUpdate);
- /*
- if (process != null) {
- ITimeWindow tw = process.getTimeWindowInit();
- if (tw.getEnd() == null) {
- tw.setEnd(TimeStamp.getCurrentMillis());
- }
+ // cleanup Camel route associated with a process that just stopped
+ if ( process.getPID() != null && super.getContext().getRoute(process.getPID()) != null ) {
+ super.getContext().stopRoute(process.getPID());
+
+ // remove route from context, otherwise the routes accumulate over time causing memory leak
+ super.getContext().removeRoute(process.getPID());
+ StringBuffer sb = new StringBuffer("\n");
+ logger.info(
+ methodName,
+ null,
+ "Removed Camel Route from Context for PID:"+process.getPID());
+
+ for ( Route route : super.getContext().getRoutes() ) {
+ sb.append("Camel Context - RouteId:"+route.getId()+"\n");
+ }
+ logger.info(
+ methodName,
+ null,
+ sb.toString());
}
-*/
updateProcessStatus(event);
} catch (Exception e) {
logger.error(methodName, null, e);
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/AgentConfiguration.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/AgentConfiguration.java?rev=1584139&r1=1584138&r2=1584139&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/AgentConfiguration.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/config/AgentConfiguration.java Wed Apr 2 19:25:03 2014
@@ -457,6 +457,7 @@ public class AgentConfiguration {
RoutesDefinition rsd = metricsRouteBuilder.getRouteCollection();
for (RouteDefinition rd : rsd.getRoutes()) {
camelContext.stopRoute(rd.getId());
+ camelContext.removeRoute(rd.getId());
logger.error(methodName, null, ">>>> Agent Stopped Metrics Publishing");
}