You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ea...@apache.org on 2008/06/30 00:14:04 UTC

svn commit: r672680 - in /incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main: java/org/apache/uima/aae/ java/org/apache/uima/aae/controller/ java/org/apache/uima/aae/handler/ java/org/apache/uima/aae/handler/input/ java/org/apache/u...

Author: eae
Date: Sun Jun 29 15:14:04 2008
New Revision: 672680

URL: http://svn.apache.org/viewvc?rev=672680&view=rev
Log:
UIMA-1091 Commit JC patch for idle time fix

Modified:
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/InputChannel.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AnalysisEngineController.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AnalysisEngineInstancePoolWithThreadAffinity.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/ControllerCallbackListener.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/PrimitiveAnalysisEngineController_impl.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/HandlerBase.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/ServicePerformance.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/ServicePerformanceMBean.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/resources/uimaee_messages.properties

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/InputChannel.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/InputChannel.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/InputChannel.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/InputChannel.java Sun Jun 29 15:14:04 2008
@@ -30,7 +30,7 @@
 	public void setServerUri(String aServerUri);
 	public String getInputQueueName();
 	public ServiceInfo getServiceInfo();
-//	public void stop() throws Exception;
+	public void checkpoint();
 	public boolean isStopped();
     
 }

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java Sun Jun 29 15:14:04 2008
@@ -131,6 +131,13 @@
 
 	private boolean requestForMetaSentToRemotes = false;
 
+	private Object mux = new Object();
+	
+	private boolean isIdle = true;
+	
+	private long lastUpdate = System.nanoTime();
+	
+	private long totalIdleTime = 0;
 
 	private ConcurrentHashMap<String, Object[]> delegateStatMap = 
 		new ConcurrentHashMap();
@@ -424,6 +431,27 @@
 		getOutputChannel().sendReply(AsynchAEMessage.CollectionProcessComplete, getClientEndpoint());
 		clientEndpoint = null;
 		clearStats();
+		
+		Map delegates = ((AggregateAnalysisEngineController)this).getDestinations();
+		Set set = delegates.entrySet();
+		for( Iterator it = set.iterator(); it.hasNext();)
+		{
+			Map.Entry entry = (Map.Entry)it.next();
+			Endpoint endpoint = (Endpoint)entry.getValue();
+			if ( endpoint != null )
+			{
+				//	Fetch stats for the delegate
+				ServicePerformance delegatePerformanceStats =
+					((AggregateAnalysisEngineController)this).
+						getDelegateServicePerformance((String)entry.getKey());
+				if ( delegatePerformanceStats != null )
+				{
+					delegatePerformanceStats.reset();
+				}
+			}
+		}
+		getServicePerformance().reset();
+		
 	}
 	/**
 	 * 
@@ -928,7 +956,9 @@
 							+super.jmxContext+",r"+remoteIndex+"="+key+" [Remote Uima EE Service],name="+key+"_"+serviceInfo.getLabel());
 
 					ServicePerformance servicePerformance = new ServicePerformance();
-					
+					servicePerformance.setIdleTime(System.nanoTime());
+					servicePerformance.setRemoteDelegate();
+
 					registerWithAgent(servicePerformance, super.getManagementInterface().getJmxDomain()+super.jmxContext+",r"+remoteIndex+"="+key+" [Remote Uima EE Service],name="+key+"_"+servicePerformance.getLabel());
 
 					ServiceErrors serviceErrors = new ServiceErrors();
@@ -1791,7 +1821,10 @@
 				pServiceInfo.setAnalysisEngineInstanceCount(1);
 
 				ServicePerformance servicePerformance = new ServicePerformance();
-
+				if ( anEndpoint.isRemote() )
+				{
+					servicePerformance.setRemoteDelegate();
+				}
 				ServiceErrors serviceErrors = new ServiceErrors();
 
 				serviceErrorMap.put(key, serviceErrors);
@@ -2020,4 +2053,36 @@
 	{
 		return childControllerList;
 	}
+	
+	//	This is called every time a request comes
+	public void beginProcess(int msgType)
+	{
+		synchronized( mux )
+		{
+			isIdle = false;
+			lastUpdate = System.nanoTime();
+		}
+	}
+	//	This is called every time a request is completed
+	public void endProcess(int msgType)
+	{
+		synchronized( mux )
+		{
+			isIdle = true;
+			lastUpdate = System.nanoTime();
+		}
+	}
+	public long getTotalIdleTime()
+	{
+		synchronized( mux )
+		{
+			long now = System.nanoTime();
+			if ( isIdle )
+			{
+				totalIdleTime += ( now - lastUpdate);
+			}
+		}
+		return totalIdleTime;
+	}
+
 }

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AnalysisEngineController.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AnalysisEngineController.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AnalysisEngineController.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AnalysisEngineController.java Sun Jun 29 15:14:04 2008
@@ -142,6 +142,8 @@
 	public void addTimeSnapshot( long snapshot, String aKey );
 	
 	public ServicePerformance getServicePerformance();
+
+	public ServiceInfo getServiceInfo();
 	
 	public long getTimeSnapshot( String aKey );
 
@@ -167,4 +169,12 @@
 
 	public void releaseNextCas(String aCasReferenceId);
 
+	public long getTotalIdleTime();
+	
+	//	This is called every time a request comes
+	public void beginProcess(int msgType);
+
+	//	This is called every time a request is completed
+	public void endProcess(int msgType);
+	
 }

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AnalysisEngineInstancePoolWithThreadAffinity.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AnalysisEngineInstancePoolWithThreadAffinity.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AnalysisEngineInstancePoolWithThreadAffinity.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AnalysisEngineInstancePoolWithThreadAffinity.java Sun Jun 29 15:14:04 2008
@@ -61,7 +61,7 @@
 	 */
 	public void checkin(AnalysisEngine anAnalysisEngine) throws Exception
 	{
-		// 
+		aeInstanceMap.put(Thread.currentThread().getName(), anAnalysisEngine);
 	}
 
 	/**
@@ -95,13 +95,24 @@
 			}
 		}
 		//	ae may have been assigned above already, no need to fetch it again
+		
+		/*
 		if ( ae == null )
 		{
 			//	Fetch ae instance from the map using thread name as key. This mechanism assures that a thread
 			//	uses the same ae instance every time.
 			ae = (AnalysisEngine)aeInstanceMap.get(Thread.currentThread().getName()) ;
 		}
+		
 		return ae;
+		*/
+		
+		if ( aeInstanceMap.containsKey(Thread.currentThread().getName()) )
+		{
+			return (AnalysisEngine)aeInstanceMap.remove(Thread.currentThread().getName()) ;
+		}
+		else
+			return null;
 	}
 
 	/* (non-Javadoc)

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java Sun Jun 29 15:14:04 2008
@@ -155,7 +155,7 @@
 	//	Map holding outstanding CASes produced by Cas Multiplier that have to be acked
 	protected ConcurrentHashMap cmOutstandingCASes = new ConcurrentHashMap();
 	
-
+	
 	public BaseAnalysisEngineController(AnalysisEngineController aParentController, int aComponentCasPoolSize, String anEndpointName, String aDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache) throws Exception
 	{
 		this(aParentController, aComponentCasPoolSize, 0, anEndpointName, aDescriptor, aCasManager, anInProcessCache, null, null);
@@ -456,12 +456,12 @@
 		
 		String name = "";
 		int index = getIndex(); 
-		servicePerformance = new ServicePerformance();
+		servicePerformance = new ServicePerformance(this);
 		name = jmxManagement.getJmxDomain()+key_value_list+",name="+thisComponentName+"_"+servicePerformance.getLabel();
 		
-		
 		registerWithAgent(servicePerformance, name );
-
+		servicePerformance.setIdleTime(System.nanoTime());
+		
 		ServiceInfo serviceInfo = getInputChannel().getServiceInfo();
 		ServiceInfo pServiceInfo = null;
 
@@ -1069,7 +1069,7 @@
 		}
 		else
 		{
-			casStats = new ServicePerformance();
+			casStats = new ServicePerformance(this);
 			perCasStatistics.put( aCasReferenceId, casStats);
 		}
 		return casStats;
@@ -1117,6 +1117,9 @@
 		}
 		//	Clear CAS statistics
 		perCasStatistics.clear();
+		
+		
+	
 	}
 	/**
 	 * Returns a copy of the controller statistics.
@@ -1646,12 +1649,12 @@
         if ( e != null )
         {
           ((ControllerCallbackListener)controllerListeners.get(i)).
-              notifyOnInitializationFailure(e);
+              notifyOnInitializationFailure(this, e);
         }
         else
         {
           ((ControllerCallbackListener)controllerListeners.get(i)).
-              notifyOnInitializationSuccess();
+              notifyOnInitializationSuccess(this);
         }
       }
 	  }
@@ -1740,5 +1743,5 @@
 				}
 			}
 		}
-	  
+		//	Called by ServicePerformance MBean on separate thread 
 }

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/ControllerCallbackListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/ControllerCallbackListener.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/ControllerCallbackListener.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/ControllerCallbackListener.java Sun Jun 29 15:14:04 2008
@@ -22,6 +22,8 @@
 public interface ControllerCallbackListener
 {
 	public void notifyOnTermination( String aMessage );
+	public void notifyOnInitializationFailure(AnalysisEngineController aController, Exception e);
+	public void notifyOnInitializationSuccess(AnalysisEngineController aController);
 	public void notifyOnInitializationFailure( Exception e);
 	public void notifyOnInitializationSuccess();
 

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/PrimitiveAnalysisEngineController_impl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/PrimitiveAnalysisEngineController_impl.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/PrimitiveAnalysisEngineController_impl.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/PrimitiveAnalysisEngineController_impl.java Sun Jun 29 15:14:04 2008
@@ -20,8 +20,10 @@
 package org.apache.uima.aae.controller;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.management.ObjectName;
 
@@ -55,6 +57,8 @@
 import org.apache.uima.resource.metadata.impl.ConfigurationParameter_impl;
 import org.apache.uima.util.Level;
 
+import sun.management.snmp.jvminstr.JvmThreadInstanceEntryImpl.ThreadStateMap;
+
 public class PrimitiveAnalysisEngineController_impl 
 extends BaseAnalysisEngineController implements PrimitiveAnalysisEngineController
 {
@@ -84,6 +88,14 @@
 	
 	private String abortedCASReferenceId = null;
 	
+	private Object mux = new Object();
+	
+	
+	private long totalIdleTime = 0;
+	
+	private Map<Long, AnalysisThreadState> threadStateMap =
+		new HashMap<Long,AnalysisThreadState>();
+	
 	public PrimitiveAnalysisEngineController_impl(String anEndpointName, String anAnalysisEngineDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache, int aWorkQueueSize, int anAnalysisEnginePoolSize) throws Exception
 	{
 		this(null, anEndpointName, anAnalysisEngineDescriptor, aCasManager, anInProcessCache, aWorkQueueSize, anAnalysisEnginePoolSize, 0);
@@ -222,6 +234,8 @@
 			getServicePerformance().incrementAnalysisTime(System.nanoTime()-start);
 			getOutputChannel().sendReply(AsynchAEMessage.CollectionProcessComplete, anEndpoint);
 			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, getClass().getName(), "collectionProcessComplete", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_cpc_completed__FINE", new Object[] { getComponentName()});
+			getServicePerformance().reset();
+	
 		}
 		catch ( Exception e)
 		{
@@ -339,6 +353,15 @@
 				timeToProcessCAS = (System.nanoTime()-hasNextTime);
 				getNextTime = System.nanoTime();
 				CAS casProduced = casIterator.next();
+				
+				
+				
+				/* !!!!!!!!!!!!!!!!!!!!!! */
+				getServicePerformance().incrementTimeSpentInCMGetNext(System.nanoTime() - getNextTime);
+				/* !!!!!!!!!!!!!!!!!!!!!! */
+
+				
+				
 				//	Add how long it took to call next()
 				timeToProcessCAS += (System.nanoTime()- getNextTime);
                 //	Add time to call hasNext() and next() to the running total
@@ -640,4 +663,85 @@
 			aeList = null;
 		}
 	}
+	
+	//	This is called every time a request comes
+	public void beginProcess(int msgType )
+	{
+		if ( AsynchAEMessage.Process == msgType )
+		{
+			synchronized( mux )
+			{
+				AnalysisThreadState threadState = null;
+				if ( threadStateMap.containsKey(Thread.currentThread().getId()))
+				{
+					threadState = threadStateMap.get(Thread.currentThread().getId());
+					threadState.setLastUpdate(System.nanoTime());
+					threadState.setIdle(false);
+				}
+				else
+				{
+					threadStateMap.put(Thread.currentThread().getId(), new AnalysisThreadState());
+				}
+			}
+		}
+	}
+	//	This is called every time a request is completed
+	public void endProcess( int msgType )
+	{
+		if ( AsynchAEMessage.Process == msgType )
+		{
+			synchronized( mux )
+			{
+				AnalysisThreadState threadState = threadStateMap.get(Thread.currentThread().getId());
+				threadState.setLastUpdate(System.nanoTime());
+				threadState.setIdle(true);
+			}
+			
+		}
+	}
+	public long getTotalIdleTime()
+	{
+		int howManyThreads = 0;
+		synchronized( mux )
+		{
+			long now = System.nanoTime();
+			Set<Long> set = threadStateMap.keySet();
+			for(Long key: set )
+			{	
+				 AnalysisThreadState threadState = threadStateMap.get(key);
+				 if ( threadState.isIdle())
+				 {
+					totalIdleTime += ( now - threadState.getLastUpdate() );
+				 }
+			}
+			howManyThreads = threadStateMap.size();
+		}
+		if ( howManyThreads == 0)
+		{
+			return totalIdleTime;
+		}
+		else
+		{
+			return totalIdleTime/howManyThreads;
+		}
+	}
+	private class AnalysisThreadState
+	{
+		private boolean isIdle = false;
+		private long lastUpdate = System.nanoTime();
+	
+		public boolean isIdle() {
+			return isIdle;
+		}
+		public void setIdle(boolean isIdle) {
+			this.isIdle = isIdle;
+		}
+		public long getLastUpdate() {
+			return lastUpdate;
+		}
+		public void setLastUpdate(long lastUpdate) {
+			this.lastUpdate = lastUpdate;
+		}
+		
+	}
 }

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java Sun Jun 29 15:14:04 2008
@@ -205,7 +205,7 @@
       {
         //  If there is an exception, notify listener with failure
         if ( e != null ) {
-          (this.listeners.get(i)).notifyOnInitializationFailure(e);
+          (this.listeners.get(i)).notifyOnInitializationFailure( e);
         }
         // else, Success!
         else {

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/HandlerBase.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/HandlerBase.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/HandlerBase.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/HandlerBase.java Sun Jun 29 15:14:04 2008
@@ -24,6 +24,7 @@
 import org.apache.uima.aae.InProcessCache.CacheEntry;
 import org.apache.uima.aae.controller.AggregateAnalysisEngineController;
 import org.apache.uima.aae.controller.AnalysisEngineController;
+import org.apache.uima.aae.controller.Endpoint;
 import org.apache.uima.aae.controller.PrimitiveAnalysisEngineController;
 import org.apache.uima.aae.error.AsynchAEException;
 import org.apache.uima.aae.error.ErrorContext;
@@ -291,8 +292,16 @@
 				long idleTime = ((Long) aMessageContext.getMessageLongProperty(AsynchAEMessage.IdleTime)).longValue();
 				if ( idleTime > 0 )
 				{
-//					casStats.incrementIdleTime(idleTime);
-					if ( delegateServicePerformance != null )
+					Endpoint endp = aMessageContext.getEndpoint();
+					if ( endp != null && endp.isRemote() )
+					{
+						if ( delegateServicePerformance != null )
+						{
+							delegateServicePerformance.setIdleTime(idleTime);
+						}
+					}
+					//					casStats.incrementIdleTime(idleTime);
+					else if ( delegateServicePerformance != null )
 					{
 						delegateServicePerformance.
 							incrementIdleTime(idleTime);

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java Sun Jun 29 15:14:04 2008
@@ -131,6 +131,7 @@
 		//	fetch the CAS from a shadow CAS pool. Otherwise, fetch the CAS
 		//	from the service CAS Pool.
 		// ************************************************************************* 
+
 		CAS cas = getCAS(aMessageContext.propertyExists(AsynchAEMessage.CasSequence), shadowCasPoolKey, aMessageContext.getEndpoint().getEndpoint());
 		long timeWaitingForCAS = System.nanoTime() - t1;
 		//	Check if we are still running
@@ -167,6 +168,19 @@
 		if ( getController().isTopLevelComponent() )
 		{
 			getController().getServicePerformance().incrementCasDeserializationTime(timeToDeserializeCAS);
+			if ( aMessageContext.propertyExists(AsynchAEMessage.CasSequence) )
+			{
+				//	Fetch stats for the delegate
+				ServicePerformance delegatePerformanceStats =
+					((AggregateAnalysisEngineController)getController()).getDelegateServicePerformance(shadowCasPoolKey);
+				delegatePerformanceStats.incrementShadowCasPoolWaitTime(timeWaitingForCAS);
+			}
+			else
+			{
+				//	How long we waited for a CAS from the pool
+				getController().getServicePerformance().incrementCasPoolWaitTime(timeWaitingForCAS);
+			}
+			
 		}
 		getController().saveTime(inTime, casReferenceId,  getController().getName());
 		

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/ServicePerformance.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/ServicePerformance.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/ServicePerformance.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/ServicePerformance.java Sun Jun 29 15:14:04 2008
@@ -23,6 +23,8 @@
 import java.text.FieldPosition;
 import java.util.Formatter;
 
+import org.apache.uima.aae.controller.AnalysisEngineController;
+
 
 public class ServicePerformance implements ServicePerformanceMBean
 {
@@ -36,9 +38,26 @@
 	private long maxSerializationTime=0;
 	private long maxDeserializationTime=0;
 	private long maxAnalysisTime=0;
-	
+	private long casPoolWaitTime=0;
+	private long shadowCasPoolWaitTime=0;
+	private long timeSpentInCMGetNext = 0;
 	private Object sem = new Object();
+	private AnalysisEngineController controller;
+	private boolean isRemoteDelegate = false;
+	
+	public ServicePerformance()
+	{
+	}
 
+	public ServicePerformance(AnalysisEngineController aController)
+	{
+		controller = aController;
+	}
+	
+	public void setRemoteDelegate()
+	{
+		isRemoteDelegate = true;
+	}
 	public String getLabel()
 	{
 		return label;
@@ -50,17 +69,49 @@
 		numberOfCASesProcessed=0;
 		casDeserializationTime=0;
 		casSerializationTime=0;
+		casPoolWaitTime = 0;
+		shadowCasPoolWaitTime=0;
 		analysisTime=0;
+		maxSerializationTime=0;
+		maxDeserializationTime=0;
+		maxAnalysisTime=0;
+		timeSpentInCMGetNext = 0;
+
+	}
+	
+	
+	public void setIdleTime( long anIdleTime )
+	{
+		accumulatedIdleTime = anIdleTime;
 	}
 	public double getIdleTime()
 	{
+		
+		if ( controller != null )
+		{
+			//	Force update of the idle time
+			double time = ((double)controller.getTotalIdleTime()/(double) 1000000);
+			return time;
+		}
+		else if ( accumulatedIdleTime != 0)
+		{
+			synchronized( sem )
+			{
+				return((double)accumulatedIdleTime/(double) 1000000);
+			}
+		}
+		
+			/*
+		 * 
 		if ( accumulatedIdleTime != 0)
+		{
 			synchronized( sem )
 			{
 				return((double)accumulatedIdleTime/(double) 1000000);
 			}
-		else
-			return 0;
+		}
+*/		
+		return 0;
 	}
 
 	public long getRawIdleTime()
@@ -157,4 +208,33 @@
 	{
 		return (double)maxAnalysisTime / (double)1000000;
 	}
+	public void incrementCasPoolWaitTime(long aCasPoolsWaitTime )
+	{
+		synchronized (sem ) 
+		{
+			casPoolWaitTime += aCasPoolsWaitTime;
+		}
+	}
+	public double getCasPoolWaitTime()
+	{
+		return (double)casPoolWaitTime/(double)1000000;
+	}
+	public void incrementShadowCasPoolWaitTime(long aShadowCasPoolWaitTime)
+	{
+		shadowCasPoolWaitTime += aShadowCasPoolWaitTime;
+	}
+	public double getShadowCasPoolWaitTime()
+	{
+		return (double)shadowCasPoolWaitTime/(double)1000000;
+	}
+	
+	public void incrementTimeSpentInCMGetNext(long aTimeSpentInCMGetNext )
+	{
+		timeSpentInCMGetNext += aTimeSpentInCMGetNext;
+	}
+	public double getTimeSpentInCMGetNext()
+	{
+		return (double)timeSpentInCMGetNext/(double)1000000;
+	}
+
 }

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/ServicePerformanceMBean.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/ServicePerformanceMBean.java?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/ServicePerformanceMBean.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/ServicePerformanceMBean.java Sun Jun 29 15:14:04 2008
@@ -32,5 +32,7 @@
 	public double getCasDeserializationTime();
 	public double getCasSerializationTime();
 	public double getAnalysisTime();
-	
+	public double getCasPoolWaitTime();
+	public double getShadowCasPoolWaitTime();
+	public double getTimeSpentInCMGetNext();
 }

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/resources/uimaee_messages.properties
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/resources/uimaee_messages.properties?rev=672680&r1=672679&r2=672680&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/resources/uimaee_messages.properties (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/resources/uimaee_messages.properties Sun Jun 29 15:14:04 2008
@@ -153,4 +153,5 @@
 UIMAEE_remove_cache_entry__INFO = Controller: {0} Releasing CASes Produced From Input CAS: {1}
 UIMAEE_dump_msg_origin__FINE = Controller: {0} Origin Map Dump {1}
 UIMAEE_show_abbrev_cache_stats___FINE = Controller: {0} Number of CASes In the Cache: {1} Number of CASes in Final State: {2}  
-UIMAEE_service_idle_time_INFO = Uima Service: {0} Idle Time Delta: {1}=======
+UIMAEE_service_idle_time_INFO = Uima Service: {0} Total Idle Time: {1} Idle Time Delta: {2} CASes Processed: {3} Service Input Queue Depth: {4} Cas Pool Wait Time: {5} Shadow Cas Pool Wait Time: {6} Time Spent In CM getNext(): {7}
+UIMAEE_marker_INFO = ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++