You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2018/01/02 15:39:47 UTC

svn commit: r1819850 - in /uima/uima-ducc/trunk: uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/ uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/ uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/ev...

Author: degenaro
Date: Tue Jan  2 15:39:47 2018
New Revision: 1819850

URL: http://svn.apache.org/viewvc?rev=1819850&view=rev
Log:
UIMA-5688 DUCC Orchestrator (OR) system logger should track launching and termination of distributed processes

Added:
    uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/AgentProcessLifecycleReportDuccEvent.java   (with props)
Modified:
    uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java
    uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/Orchestrator.java
    uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java
    uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/event/OrchestratorEventListener.java
    uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/SystemEventsLogger.java
    uima/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/event/ResourceManagerEventListener.java
    uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/DuccEvent.java

Modified: uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java?rev=1819850&r1=1819849&r2=1819850&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-agent/src/main/java/org/apache/uima/ducc/agent/NodeAgent.java Tue Jan  2 15:39:47 2018
@@ -74,6 +74,8 @@ import org.apache.uima.ducc.transport.ag
 import org.apache.uima.ducc.transport.cmdline.ICommandLine;
 import org.apache.uima.ducc.transport.cmdline.NonJavaCommandLine;
 import org.apache.uima.ducc.transport.dispatcher.DuccEventDispatcher;
+import org.apache.uima.ducc.transport.event.AgentProcessLifecycleReportDuccEvent;
+import org.apache.uima.ducc.transport.event.AgentProcessLifecycleReportDuccEvent.LifecycleEvent;
 import org.apache.uima.ducc.transport.event.DuccEvent;
 import org.apache.uima.ducc.transport.event.NodeInventoryUpdateDuccEvent;
 import org.apache.uima.ducc.transport.event.ProcessStateUpdateDuccEvent;
@@ -95,7 +97,7 @@ import org.apache.uima.ducc.transport.ev
 
 public class NodeAgent extends AbstractDuccComponent implements Agent, ProcessLifecycleObserver {
   public static DuccLogger logger = DuccLogger.getLogger(NodeAgent.class, COMPONENT_NAME);
-
+  private static DuccId jobid = null;
   //  Replaced by duplicate in org.apache.uima.ducc.transport.agent.ProcessStateUpdate
   //public static final String ProcessStateUpdatePort = "ducc.agent.process.state.update.port";
 
@@ -220,6 +222,82 @@ public class NodeAgent extends AbstractD
 	  return retVal;
   }
 
+  /*
+   * Report process lifecycle events on same channel that inventory is reported
+   */
+  public DuccEventDispatcher getProcessLifecycleReportDispatcher() {
+	  return inventoryDispatcher;
+  }
+  
+  /*
+   * Send process lifecycle event to interested listeners
+   */
+  private void sendProcessLifecycleEventReport(IDuccProcess process, LifecycleEvent lifecycleEvent) {
+	  String location = "sendProcessLifecycleEventReport";
+	  try {
+		  NodeIdentity nodeIdentity = getIdentity();
+		  AgentProcessLifecycleReportDuccEvent duccEvent = new AgentProcessLifecycleReportDuccEvent(process, nodeIdentity, lifecycleEvent);
+		  DuccEventDispatcher dispatcher = getProcessLifecycleReportDispatcher();
+		  dispatcher.dispatch(duccEvent);
+		  StringBuffer sb = new StringBuffer();
+		  sb.append("id:"+process.getDuccId().toString()+" ");
+		  sb.append("lifecycleEvent:"+lifecycleEvent.name()+" ");
+		  String args = sb.toString().trim();
+		  logger.info(location, jobid, args);
+	  }
+	  catch(Exception e) {
+		  logger.error(location, jobid, e);
+	  }
+  }
+  
+  /*
+   * Add ManagedProcess to map and send lifecycle event
+   */
+  private void processDeploy(ManagedProcess mp) {
+	  String location = "processDeploy";
+	  if(mp != null) {
+		  if(deployedProcesses.contains(mp)) {
+			  String args = "mp:"+mp.getProcessId();
+			  logger.error(location, jobid, args);
+		  }
+		  else {
+			  String args = "mp:"+mp.getProcessId();
+			  logger.debug(location, jobid, args);
+			  deployedProcesses.add(mp);
+			  IDuccProcess process = mp.getDuccProcess();
+			  sendProcessLifecycleEventReport(process,LifecycleEvent.Launch);
+		  }
+	  }
+	  else {
+		  String args = "mp:"+mp;
+		  logger.error(location, jobid, args);
+	  }
+  }
+  
+  /*
+   * Remove ManagedProcess from map and send lifecycle event
+   */
+  private void processUndeploy(ManagedProcess mp) {
+	  String location = "processUndeploy";
+	  if(mp != null) {
+		  if(!deployedProcesses.contains(mp)) {
+			  String args = "mp:"+mp.getProcessId();
+			  logger.error(location, jobid, args);
+		  }
+		  else {
+			  String args = "mp:"+mp.getProcessId();
+			  logger.debug(location, jobid, args);
+			  deployedProcesses.remove(mp);
+			  IDuccProcess process = mp.getDuccProcess();
+			  sendProcessLifecycleEventReport(process,LifecycleEvent.Terminate);
+		  }
+	  }
+	  else {
+		  String args = "mp:"+mp;
+		  logger.error(location, jobid, args);
+	  }
+  }
+  
   /**
    * C'tor for dependecy injection
    *
@@ -1000,7 +1078,7 @@ public class NodeAgent extends AbstractD
       // Find ManagedProcess instance the DuccProcess instance is
       // associated with
       if (deployedProcess.getDuccProcess().getDuccId().equals(process.getDuccId())) {
-        deployedProcesses.remove(deployedProcess);
+    	processUndeploy(deployedProcess);
         break;
       }
     }
@@ -1326,9 +1404,9 @@ public class NodeAgent extends AbstractD
           // used to correlate message
           // exchanges
           // between the agent and launched process
-          deployedProcesses.add(launcher.launchProcess(this, getIdentity(), process, commandLine,
-                  this, managedProcess));
-
+          
+          ManagedProcess deployedProcess = launcher.launchProcess(this, getIdentity(), process, commandLine, this, managedProcess);
+          processDeploy(deployedProcess);
         } catch (Exception e) {
           logger.error(methodName, null, e);
         }
@@ -1565,8 +1643,8 @@ public class NodeAgent extends AbstractD
                 + " Not in Agent's inventory. Adding to the inventory with state=Stopped");
         process.setProcessState(ProcessState.Stopped);
         inventory.put(process.getDuccId(), process);
-        deployedProcesses.add(new ManagedProcess(process, null, this, logger,
-                new ProcessMemoryAssignment()));
+        ManagedProcess deployedProcess = new ManagedProcess(process, null, this, logger, new ProcessMemoryAssignment());
+        processDeploy(deployedProcess);
       }
     }
   }
@@ -1637,7 +1715,7 @@ public class NodeAgent extends AbstractD
           if (deployedProcessRef != null) {
             logger.debug(methodName, null,
                     "----------------- Removing Stopped Process from Deployed List");
-            deployedProcesses.remove(deployedProcessRef);
+            processUndeploy(deployedProcessRef);
             logger.debug(methodName, null,
                     "----------------- Deployed Process List Size After Remove:"
                             + deployedProcesses.size());

Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/Orchestrator.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/Orchestrator.java?rev=1819850&r1=1819849&r2=1819850&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/Orchestrator.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/Orchestrator.java Tue Jan  2 15:39:47 2018
@@ -18,6 +18,7 @@
 */
 package org.apache.uima.ducc.orchestrator;
 
+import org.apache.uima.ducc.transport.event.AgentProcessLifecycleReportDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelJobDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelReservationDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelServiceDuccEvent;
@@ -39,6 +40,7 @@ public interface Orchestrator {
 	public void reconcileSmHeartbeat(SmHeartbeatDuccEvent duccEvent);
 	public void reconcileJdState(JdRequestEvent duccEvent);
 	public void reconcileNodeInventory(NodeInventoryUpdateDuccEvent duccEvent);
+	public void reconcileAgentProcessLifecycleReport(AgentProcessLifecycleReportDuccEvent duccEvent);
 	public OrchestratorStateDuccEvent getState();
 	public void startJob(SubmitJobDuccEvent duccEvent);
 	public void stopJob(CancelJobDuccEvent duccEvent);

Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java?rev=1819850&r1=1819849&r2=1819850&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/OrchestratorComponent.java Tue Jan  2 15:39:47 2018
@@ -60,6 +60,8 @@ import org.apache.uima.ducc.orchestrator
 import org.apache.uima.ducc.orchestrator.maintenance.NodeAccounting;
 import org.apache.uima.ducc.orchestrator.system.events.log.SystemEventsLogger;
 import org.apache.uima.ducc.orchestrator.utilities.TrackSync;
+import org.apache.uima.ducc.transport.event.AgentProcessLifecycleReportDuccEvent;
+import org.apache.uima.ducc.transport.event.AgentProcessLifecycleReportDuccEvent.LifecycleEvent;
 import org.apache.uima.ducc.transport.event.CancelJobDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelReservationDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelServiceDuccEvent;
@@ -90,6 +92,7 @@ import org.apache.uima.ducc.transport.ev
 import org.apache.uima.ducc.transport.event.common.IDuccProcess;
 import org.apache.uima.ducc.transport.event.common.IDuccProcess.ReasonForStoppingProcess;
 import org.apache.uima.ducc.transport.event.common.IDuccProcessMap;
+import org.apache.uima.ducc.transport.event.common.IDuccProcessType.ProcessType;
 import org.apache.uima.ducc.transport.event.common.IDuccReservation;
 import org.apache.uima.ducc.transport.event.common.IDuccReservationMap;
 import org.apache.uima.ducc.transport.event.common.IDuccState.JobState;
@@ -501,6 +504,124 @@ implements Orchestrator {
 		OrchestratorState.getInstance().setNextSequenceNumberStateIfGreater(nodeIdentity, seqNo);
 	}
 	
+	/*
+	 * Safely obtain Node from the arriving event
+	 */
+	private String getNode(AgentProcessLifecycleReportDuccEvent duccEvent) {
+		String node = "?";
+		NodeIdentity nodeIdentity = duccEvent.getNodeIdentity();
+		if(nodeIdentity != null) {
+			node = nodeIdentity.getName();
+		}
+		return node;
+	}
+	
+	/*
+	 * Safely obtain LifecycleEvent from the arriving event
+	 */
+	private LifecycleEvent getLifecycleEvent(AgentProcessLifecycleReportDuccEvent duccEvent) {
+		LifecycleEvent lifecycleEvent = duccEvent.getLifecycleEvent();
+		if(lifecycleEvent == null) {
+			lifecycleEvent = LifecycleEvent.Undefined;
+		}
+		return lifecycleEvent;
+	}
+	
+	/*
+	 * Safely obtain DuccId from the arriving event
+	 */
+	private DuccId getProcessDuccId(AgentProcessLifecycleReportDuccEvent duccEvent) {
+		DuccId duccid = null;
+		IDuccProcess process = duccEvent.getProcess();
+		if(process != null) {
+			duccid = process.getDuccId();
+		}
+		return duccid;
+	}
+	
+	/*
+	 * Safely obtain ProcessId from the arriving event
+	 */
+	private String getProcessId(AgentProcessLifecycleReportDuccEvent duccEvent) {
+		String id = null;
+		DuccId duccid = getProcessDuccId(duccEvent);
+		if(duccid != null) {
+			id = duccid.toString();
+		}
+		return id;
+	}
+	
+	/*
+	 * Safely obtain ProcessType from the arriving event
+	 */
+	private ProcessType getProcessType(AgentProcessLifecycleReportDuccEvent duccEvent) {
+		ProcessType processType = null;
+		IDuccProcess process = duccEvent.getProcess();
+		if(process != null) {
+			processType = process.getProcessType();
+		}
+		return processType;
+	}
+	
+	/*
+	 * Validate arriving agent's process lifecycle event and record to system events log
+	 */
+	@Override
+	public void reconcileAgentProcessLifecycleReport(AgentProcessLifecycleReportDuccEvent duccEvent) {
+		String location = "reconcileAgentProcessLifecycleReport";
+		StringBuffer sb = new StringBuffer();
+		String id = getProcessId(duccEvent);
+		String node = getNode(duccEvent);
+		LifecycleEvent lifecycleEvent = getLifecycleEvent(duccEvent);
+		ProcessType processType = getProcessType(duccEvent);
+		IDuccProcess process = duccEvent.getProcess();
+		DuccId processDuccId = getProcessDuccId(duccEvent);
+		if(process == null) {
+			sb.append("process:"+process+" ");
+			sb.append("node:"+node+" ");
+			sb.append("lifefcycleEvent:"+lifecycleEvent.name()+" ");
+			logger.error(location, jobid, sb.toString());
+		}
+		else if(id == null) {
+			sb.append("id:"+id+" ");
+			sb.append("node:"+node+" ");
+			sb.append("lifefcycleEvent:"+lifecycleEvent.name()+" ");
+			logger.error(location, jobid, sb.toString());
+		}
+		else if(node == null) {
+			sb.append("id:"+id+" ");
+			sb.append("node:"+node+" ");
+			sb.append("lifefcycleEvent:"+lifecycleEvent.name()+" ");
+			logger.error(location, jobid, sb.toString());
+		}
+		else if(lifecycleEvent == LifecycleEvent.Undefined) {
+			sb.append("id:"+id+" ");
+			sb.append("node:"+node+" ");
+			sb.append("lifefcycleEvent:"+lifecycleEvent.name()+" ");
+			logger.error(location, jobid, sb.toString());
+		}
+		else if(processType == null) {
+			sb.append("id:"+id+" ");
+			sb.append("node:"+node+" ");
+			sb.append("lifefcycleEvent:"+lifecycleEvent.name()+" ");
+			sb.append("processType:"+processType+" ");
+			logger.error(location, jobid, sb.toString());
+		}
+		else {
+			DuccId dwId = OrchestratorCommonArea.getInstance().getProcessAccounting().getJobId(processDuccId);
+			IDuccWork dw = workMap.findDuccWork(dwId);
+			DuccType dwType = dw.getDuccType();
+			sb.append("dwId:"+dwId+" ");
+			sb.append("dwType:"+dwType+" ");
+			sb.append("id:"+id+" ");
+			sb.append("node:"+node+" ");
+			sb.append("lifefcycleEvent:"+lifecycleEvent.name()+" ");
+			sb.append("processType:"+processType.name()+" ");
+			logger.debug(location, jobid, sb.toString());
+			SystemEventsLogger.info(dw, process, node, lifecycleEvent, processType);
+		}
+	}
+	
 	/**
 	 * Publish Orchestrator State
 	 */

Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/event/OrchestratorEventListener.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/event/OrchestratorEventListener.java?rev=1819850&r1=1819849&r2=1819850&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/event/OrchestratorEventListener.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/event/OrchestratorEventListener.java Tue Jan  2 15:39:47 2018
@@ -29,6 +29,7 @@ import org.apache.uima.ducc.orchestrator
 import org.apache.uima.ducc.orchestrator.system.events.log.SystemEventsLogger;
 import org.apache.uima.ducc.transport.dispatcher.DuccEventDispatcher;
 import org.apache.uima.ducc.transport.event.AServiceRequest;
+import org.apache.uima.ducc.transport.event.AgentProcessLifecycleReportDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelJobDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelReservationDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelServiceDuccEvent;
@@ -203,7 +204,17 @@ public class OrchestratorEventListener i
 		}
 		logger.trace(methodName, null, messages.fetch("exit"));
 	}
-	
+	public void onAgentProcessLifecycleReportDuccEvent(@Body AgentProcessLifecycleReportDuccEvent duccEvent) throws Exception {
+		String methodName = "onAgentProcessLifecycleReportDuccEvent";
+		logger.trace(methodName, null, messages.fetch("enter"));
+		try {
+			orchestrator.reconcileAgentProcessLifecycleReport(duccEvent);
+		}
+		catch(Throwable t) {
+			logger.error(methodName, null, t);
+		}
+		logger.trace(methodName, null, messages.fetch("exit"));
+	}
 	private SmChannel smChannel = null;
 	
 	public void initSmChannel(CamelContext context, String endpoint) {

Modified: uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/SystemEventsLogger.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/SystemEventsLogger.java?rev=1819850&r1=1819849&r2=1819850&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/SystemEventsLogger.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-orchestrator/src/main/java/org/apache/uima/ducc/orchestrator/system/events/log/SystemEventsLogger.java Tue Jan  2 15:39:47 2018
@@ -26,8 +26,10 @@ import java.util.Properties;
 
 import org.apache.uima.ducc.common.admin.event.DuccAdminEvent;
 import org.apache.uima.ducc.common.admin.event.RmAdminReply;
+import org.apache.uima.ducc.common.utils.IDuccLoggerComponents.Daemon;
 import org.apache.uima.ducc.common.utils.id.DuccId;
 import org.apache.uima.ducc.transport.event.AServiceRequest;
+import org.apache.uima.ducc.transport.event.AgentProcessLifecycleReportDuccEvent.LifecycleEvent;
 import org.apache.uima.ducc.transport.event.CancelJobDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelJobReplyDuccEvent;
 import org.apache.uima.ducc.transport.event.CancelReservationDuccEvent;
@@ -50,19 +52,52 @@ import org.apache.uima.ducc.transport.ev
 import org.apache.uima.ducc.transport.event.cli.ReservationRequestProperties;
 import org.apache.uima.ducc.transport.event.cli.ServiceReplyProperties;
 import org.apache.uima.ducc.transport.event.cli.ServiceRequestProperties;
+import org.apache.uima.ducc.transport.event.common.IDuccProcess;
+import org.apache.uima.ducc.transport.event.common.IDuccProcessType.ProcessType;
 import org.apache.uima.ducc.transport.event.common.IDuccTypes.DuccType;
 import org.apache.uima.ducc.transport.event.common.IDuccWork;
 import org.apache.uima.ducc.transport.event.common.IDuccWorkJob;
 import org.apache.uima.ducc.transport.event.common.IDuccWorkReservation;
 import org.apache.uima.ducc.transport.event.common.IDuccWorkService;
-import org.apache.uima.ducc.transport.event.common.IRationale;
 import org.apache.uima.ducc.transport.event.common.IDuccWorkService.ServiceDeploymentType;
+import org.apache.uima.ducc.transport.event.common.IRationale;
 
 public class SystemEventsLogger {
 
 	private static DuccLogger duccLogger = getEventLogger(SystemEventsLogger.class.getName());
 	private static DuccId jobid = null;
 	
+	/*
+	 * For consistent labeling
+	 */
+	private enum Labels {
+		JOB_ID("jid"),
+		RESERVATION_ID("rid"),
+		SERVICE_ID("sid"),
+		INSTANCE_ID("iid"),
+		MANAGED_RESERVATION_ID("mid"),
+		OTHER_ID("oid"),
+		//
+		CLASS("class"),
+		CONTEXT("context"),
+		EVENT("event"),
+		NAME("name"),
+		NODE("node"),
+		RC("rc"),
+		RESPONSE("response"),
+		SIZE("size"),
+		TOD("tod"),
+		TYPE("type"),
+		;
+		public String abbrv = null;
+		private Labels(String abbreviation) {
+			abbrv = abbreviation+": ";
+		}
+		public String toString() {
+			return abbrv;
+		}
+	}
+	
 	static public DuccLogger makeLogger(String claz, String componentId) {
         return DuccLogger.getLogger(claz, componentId);
 	}
@@ -177,10 +212,10 @@ public class SystemEventsLogger {
 	private static String getType(SubmitServiceDuccEvent request) {
 		String location = "getType.SubmitServiceDuccEvent";
 		String type = request.getEventType().name();
-		duccLogger.debug(location, jobid, "type:"+type);
+		duccLogger.debug(location, jobid, Labels.TYPE+type);
 		DuccContext context = request.getContext();
 		if(context != null) {
-			duccLogger.debug(location, jobid, "context:"+context.toString());
+			duccLogger.debug(location, jobid, Labels.CONTEXT+""+context);
 			switch(context) {
 			case ManagedReservation:
 				type = DuccEvent.EventType.SUBMIT_MANAGED_RESERVATION.toString();
@@ -255,7 +290,7 @@ public class SystemEventsLogger {
 		String size = getProperty(qprops, JobRequestProperties.key_process_memory_size);
 		Properties rprops = response.getProperties();
 		String message = getProperty(rprops, JobReplyProperties.key_message, "");
-		Object[] event = { "id:"+id, "class:"+sclass, "size:"+size, message };
+		Object[] event = { Labels.JOB_ID+id, Labels.CLASS+sclass, Labels.SIZE+size, message };
 		duccLogger.event_info(daemon, user, type, event);
 	}
 	
@@ -269,7 +304,7 @@ public class SystemEventsLogger {
 		String id = getProperty(qprops, JobRequestProperties.key_id);
 		Properties rprops = response.getProperties();
 		String message = getProperty(rprops, JobReplyProperties.key_message);
-		Object[] event = { "id:"+id, message };
+		Object[] event = { Labels.JOB_ID+id, message };
 		duccLogger.event_info(daemon, user, type, event);
 	}
 	
@@ -286,7 +321,7 @@ public class SystemEventsLogger {
 		if(completionRationale != null) {
 			rationale = completionRationale.getText();
 		}
-		Object[] event = { "id:"+id,reason,rationale };
+		Object[] event = { Labels.JOB_ID+id,reason,rationale };
 		duccLogger.event_info(daemon, user, type, event);
 	}
 	
@@ -302,7 +337,7 @@ public class SystemEventsLogger {
 		String size = getProperty(qprops, ReservationRequestProperties.key_memory_size);
 		Properties rprops = response.getProperties();
 		String message = getProperty(rprops, ReservationReplyProperties.key_message, "");
-		Object[] event = { "id:"+id, "class:"+sclass, "size:"+size, message };
+		Object[] event = { Labels.RESERVATION_ID+id, Labels.CLASS+sclass, Labels.SIZE+size, message };
 		duccLogger.event_info(daemon, user, type, event);
 	}
 	
@@ -316,7 +351,7 @@ public class SystemEventsLogger {
 		String id = getProperty(qprops, ReservationRequestProperties.key_id);
 		Properties rprops = response.getProperties();
 		String message = getProperty(rprops, ReservationReplyProperties.key_message);
-		Object[] event = { "id:"+id, message };
+		Object[] event = { Labels.RESERVATION_ID+id, message };
 		duccLogger.event_info(daemon, user, type, event);
 	}
 	
@@ -333,7 +368,7 @@ public class SystemEventsLogger {
 		if(completionRationale != null) {
 			rationale = completionRationale.getText();
 		}
-		Object[] event = { "id:"+id,reason,rationale };
+		Object[] event = { Labels.RESERVATION_ID+id,reason,rationale };
 		duccLogger.event_info(daemon, user, type, event);
 	}
 	
@@ -351,14 +386,14 @@ public class SystemEventsLogger {
 		String type = getType(request);
 		if(isTypeManagedReservation(type)) {
 			String id = getProperty(properties, ServiceRequestProperties.key_id);
-			Object[] event = { "id:"+id, "class:"+sclass, "size:"+size, message };
+			Object[] event = { Labels.MANAGED_RESERVATION_ID+id, Labels.CLASS+sclass, Labels.SIZE+size, message };
 			duccLogger.event_info(daemon, user, type, event);
 		}
 		else {
 			String id = getProperty(properties, ServiceRequestProperties.key_service_id);
 			String instance = getProperty(properties, ServiceRequestProperties.key_id);
 			String name = getProperty(properties, ServiceRequestProperties.key_service_request_endpoint);
-			Object[] event = { "id:"+id, "instance:"+instance, "name:"+name, "class:"+sclass, "size:"+size, message };
+			Object[] event = { Labels.SERVICE_ID+id, Labels.INSTANCE_ID+instance, Labels.NAME+name, Labels.CLASS+sclass, Labels.SIZE+size, message };
 			duccLogger.event_info(daemon, user, type, event);
 		}
 	}
@@ -375,14 +410,14 @@ public class SystemEventsLogger {
 		String type = getType(request);
 		if(isTypeManagedReservation(type)) {
 			String id = properties.getProperty(ServiceRequestProperties.key_id);
-			Object[] event = { "id:"+id, message };
+			Object[] event = { Labels.MANAGED_RESERVATION_ID+id, message };
 			duccLogger.event_info(daemon, user, type, event);
 		}
 		else {
 			String id = getProperty(properties, ServiceRequestProperties.key_service_id);
 			String instance = properties.getProperty(ServiceRequestProperties.key_id);
 			String name = getProperty(properties, ServiceRequestProperties.key_service_request_endpoint);
-			Object[] event = { "id:"+id, "instance:"+instance, "name:"+name, message };
+			Object[] event = { Labels.SERVICE_ID+id, Labels.INSTANCE_ID+instance, Labels.NAME+name, message };
 			duccLogger.event_info(daemon, user, type, event);
 		}
 	}
@@ -397,7 +432,7 @@ public class SystemEventsLogger {
 			String id = service.getId();
 			String reason = "";
 			String rationale = "";
-			Object[] event = { "id:"+id,reason,rationale };
+			Object[] event = { Labels.MANAGED_RESERVATION_ID+id,reason,rationale };
 			duccLogger.event_info(daemon, user, type, event);
 		}
 		else {
@@ -411,7 +446,7 @@ public class SystemEventsLogger {
 			//if(completionRationale != null) {
 			//	rationale = completionRationale.getText();
 			//}
-			Object[] event = { "id:"+id,"instance:"+instance,"name:"+name,reason,rationale };
+			Object[] event = { Labels.SERVICE_ID+id,Labels.INSTANCE_ID+instance,Labels.NAME+name,reason,rationale };
 			duccLogger.event_info(daemon, user, type, event);
 		}
 	}
@@ -433,10 +468,10 @@ public class SystemEventsLogger {
 	public static void info(String daemon, AServiceRequest request, ServiceReplyEvent response) {
 		String user = request.getUser();
 		String type = request.getEventType().name();
-		long id = response.getId();
+		String id = ""+response.getId();
 		boolean rc = response.getReturnCode();
 		String message = response.getMessage();
-		Object[] event = { "id:"+id, "rc:"+rc, message };
+		Object[] event = { Labels.SERVICE_ID+id, Labels.RC+""+rc, message };
 		duccLogger.event_info(daemon, user, type, event);
 	}
 	
@@ -458,7 +493,7 @@ public class SystemEventsLogger {
 		String user = request.getUser();
 		String type = request.getClass().getSimpleName();
 		String message = normalize(response.getMessage());
-		Object[] event = { "response: "+message };
+		Object[] event = { Labels.RESPONSE+message };
 		duccLogger.event_info(daemon, user, type, event);
 	}
 	
@@ -480,7 +515,101 @@ public class SystemEventsLogger {
 		String daemon = dde.getDaemon().getAbbrev();
 		String user = System.getProperty("user.name");
 		String type = dde.getEventType().name();
-		Object[] event = { "node: "+dde.getNodeIdentity().getName(), "tod: "+dde.getTod() };
+		Object[] event = { Labels.NODE+dde.getNodeIdentity().getName(), Labels.TOD+""+dde.getTod() };
 		duccLogger.event_info(daemon, user, type, event);
 	}
+	
+	/*
+	 * derived types
+	 */
+	public enum DerivedType {
+		JobDriver("JobDriver"), 
+		JobWorker("JobProcess"), 
+		ServiceWorker("ServiceInstance"), 
+		SingletonWorker("ManagedReservation"), 
+		Undefined("Undefined");
+		private String alias = null;
+		private DerivedType(String alias) {
+			setAlias(alias);
+		}
+		private void setAlias(String value) {
+			alias = value;
+		}
+		public String getAlias() {
+			return alias;
+		}
+	}
+	
+	/*
+	 * get derived type for given process
+	 */
+	private static DerivedType getDerivedType(DuccType dwType, ProcessType processType) {
+		DerivedType dt = DerivedType.Undefined;
+		if(dwType != null) {
+			if(processType != null) {
+				switch(dwType) {
+				case Job:
+					switch(processType) {
+					case Pop:
+						dt = DerivedType.JobDriver;
+						break;
+					default:
+						dt = DerivedType.JobWorker;
+						break;
+					}
+					break;
+				case Service:
+					switch(processType) {
+					case Pop:
+						dt = DerivedType.SingletonWorker;
+						break;
+					default:
+						dt = DerivedType.ServiceWorker;
+						break;
+					}
+					break;
+				default:
+					break;
+				}
+			}
+		}
+		return dt;
+	}
+	
+	/*
+	 * log an agent process lifecycle event
+	 */
+	public static void info(IDuccWork dw, IDuccProcess process, String node, LifecycleEvent lifecycleEvent, ProcessType processType) {
+		String daemon = Daemon.Agent.getAbbrev();
+		String user = dw.getStandardInfo().getUser();
+		DuccType dwType = dw.getDuccType();
+		DerivedType dt = getDerivedType(dwType, processType);
+		String type = dt.getAlias();
+		String dwid = dw.getDuccId().toString();
+		String id = process.getDuccId().toString();
+		switch(dt) {
+		case JobDriver:
+		case JobWorker:
+			Object[] eventA = { Labels.JOB_ID+dwid, Labels.INSTANCE_ID+id, Labels.NODE+node, Labels.EVENT+lifecycleEvent.toString() };
+			duccLogger.event_info(daemon, user, type, eventA);
+			break;
+		case SingletonWorker:
+			Object[] eventB = { Labels.MANAGED_RESERVATION_ID+dwid, Labels.INSTANCE_ID+id, Labels.NODE+node, Labels.EVENT+lifecycleEvent.toString() };
+			duccLogger.event_info(daemon, user, type, eventB);
+			break;
+		case ServiceWorker:
+			IDuccWorkService service = (IDuccWorkService) dw;
+			id = service.getServiceId();
+			String instance = service.getId();
+			String name = service.getServiceEndpoint();
+			Object[] eventC = { Labels.SERVICE_ID+id, Labels.INSTANCE_ID+instance, Labels.NAME+name, Labels.NODE+node, Labels.EVENT+lifecycleEvent.toString() };
+			duccLogger.event_info(daemon, user, type, eventC);
+			break;
+		default:
+			// huh?
+			Object[] eventD = { Labels.OTHER_ID+dwid, Labels.INSTANCE_ID+id, Labels.NODE+node, Labels.EVENT+lifecycleEvent.toString() };
+			duccLogger.event_info(daemon, user, type, eventD);
+			break;
+		}
+	}
 }

Modified: uima/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/event/ResourceManagerEventListener.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/event/ResourceManagerEventListener.java?rev=1819850&r1=1819849&r2=1819850&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/event/ResourceManagerEventListener.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-rm/src/main/java/org/apache/uima/ducc/rm/event/ResourceManagerEventListener.java Tue Jan  2 15:39:47 2018
@@ -20,13 +20,18 @@ package org.apache.uima.ducc.rm.event;
 
 import org.apache.camel.Body;
 import org.apache.uima.ducc.common.ANodeStability;
+import org.apache.uima.ducc.common.NodeIdentity;
 import org.apache.uima.ducc.common.utils.DuccLogger;
+import org.apache.uima.ducc.common.utils.id.DuccId;
 import org.apache.uima.ducc.rm.ResourceManager;
 import org.apache.uima.ducc.rm.scheduler.SchedConstants;
 import org.apache.uima.ducc.transport.dispatcher.DuccEventDispatcher;
+import org.apache.uima.ducc.transport.event.AgentProcessLifecycleReportDuccEvent;
+import org.apache.uima.ducc.transport.event.AgentProcessLifecycleReportDuccEvent.LifecycleEvent;
 import org.apache.uima.ducc.transport.event.NodeInventoryUpdateDuccEvent;
 import org.apache.uima.ducc.transport.event.NodeMetricsUpdateDuccEvent;
 import org.apache.uima.ducc.transport.event.OrchestratorStateDuccEvent;
+import org.apache.uima.ducc.transport.event.common.IDuccProcess;
 import org.apache.uima.ducc.transport.event.delegate.DuccEventDelegateListener;
 
 
@@ -92,6 +97,28 @@ public class ResourceManagerEventListene
     public void onNodeInventoryUpdateEvent(@Body NodeInventoryUpdateDuccEvent duccEvent) throws Exception {
     }
 
+    /*
+     * Ignore process lifecycle events
+     */
+    public void onAgentLifecycleManagement(@Body AgentProcessLifecycleReportDuccEvent duccEvent) throws Exception {
+    	String location = "onAgentLifecycleManagement";
+    	DuccId jobid = null;
+    	try {
+    		IDuccProcess process = duccEvent.getProcess();
+    		NodeIdentity ni = duccEvent.getNodeIdentity();
+    		LifecycleEvent lifecycleEvent = duccEvent.getLifecycleEvent();
+    		StringBuffer sb = new StringBuffer();
+    		sb.append("node:"+ni.getName()+" ");
+  		  	sb.append("id:"+process.getDuccId().toString()+" ");
+  		  	sb.append("lifecycleEvent:"+lifecycleEvent.name()+" ");
+  		  	String args = sb.toString().trim();
+  		  	logger.trace(location, jobid, args);
+    	}
+    	catch(Exception e) {
+    		logger.trace(location, jobid, e);
+    	}
+    }
+    
     /**
      * Receives {@code OrchestratorDuccEvent} events from transport.
      * 

Added: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/AgentProcessLifecycleReportDuccEvent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/AgentProcessLifecycleReportDuccEvent.java?rev=1819850&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/AgentProcessLifecycleReportDuccEvent.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/AgentProcessLifecycleReportDuccEvent.java Tue Jan  2 15:39:47 2018
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.uima.ducc.transport.event;
+
+import org.apache.uima.ducc.common.NodeIdentity;
+import org.apache.uima.ducc.transport.event.common.IDuccProcess;
+
+public class AgentProcessLifecycleReportDuccEvent extends AbstractDuccEvent {
+
+	private static final long serialVersionUID = 1L;
+
+	public enum LifecycleEvent {
+		Launch, Terminate, Undefined
+	}
+
+	private IDuccProcess process = null;
+	private NodeIdentity nodeIdentity = null;
+	private LifecycleEvent lifecycleEvent = LifecycleEvent.Undefined;
+
+	public AgentProcessLifecycleReportDuccEvent(IDuccProcess process, NodeIdentity nodeIdentity, LifecycleEvent lifecycleEvent) {
+		super(EventType.AGENT_PROCESS_LIFECYCLE_REPORT);
+		setProcess(process);
+		setNodeIdentity(nodeIdentity);
+		setLifecycleEvent(lifecycleEvent);
+	}
+	
+	private void setProcess(IDuccProcess value) {
+		this.process = value;
+	}
+
+	public IDuccProcess getProcess() {
+		return process;
+	}
+
+	private void setNodeIdentity(NodeIdentity value) {
+		this.nodeIdentity = value;
+	}
+
+	public NodeIdentity getNodeIdentity() {
+		return nodeIdentity;
+	}
+	
+	private void setLifecycleEvent(LifecycleEvent value) {
+		this.lifecycleEvent = value;
+	}
+
+	public LifecycleEvent getLifecycleEvent() {
+		return lifecycleEvent;
+	}
+	
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/AgentProcessLifecycleReportDuccEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/AgentProcessLifecycleReportDuccEvent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/DuccEvent.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/DuccEvent.java?rev=1819850&r1=1819849&r2=1819850&view=diff
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/DuccEvent.java (original)
+++ uima/uima-ducc/trunk/uima-ducc-transport/src/main/java/org/apache/uima/ducc/transport/event/DuccEvent.java Tue Jan  2 15:39:47 2018
@@ -65,6 +65,7 @@ public interface DuccEvent extends Seria
             SERVICE_STOP,
             SERVICE_QUERY,
             DUCCWORK,
+            AGENT_PROCESS_LIFECYCLE_REPORT,
             AGENT_PING
             };