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/07/07 23:41:22 UTC

svn commit: r674655 - in /incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae: handler/input/ jmx/monitor/

Author: eae
Date: Mon Jul  7 14:41:22 2008
New Revision: 674655

URL: http://svn.apache.org/viewvc?rev=674655&view=rev
Log:
UIMA-1104 commit JC patches

Added:
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/BasicUimaJmxMonitorListener.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/JmxMonitorListener.java
    incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/ServiceMetrics.java
Modified:
    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/handler/input/ProcessResponseHandler.java

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=674655&r1=674654&r2=674655&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 Mon Jul  7 14:41:22 2008
@@ -428,7 +428,7 @@
 					getController().getInProcessCache().setCasProducer(casReferenceId, casMultiplierEndpoint.getEndpoint());
 					newCASProducedBy = ((AggregateAnalysisEngineController)getController()).lookUpDelegateKey(casMultiplierEndpoint.getEndpoint());
 					casMultiplierEndpoint.setIsCasMultiplier(true);
-					((AggregateAnalysisEngineController)getController()).getServicePerformance(newCASProducedBy).incrementNumberOfCASesProcessed();
+//					((AggregateAnalysisEngineController)getController()).getServicePerformance(newCASProducedBy).incrementNumberOfCASesProcessed();
 					CacheEntry subordinateCasCacheEntry = getController().getInProcessCache().getCacheEntryForCAS(casReferenceId);
 					CacheEntry inputCasCacheEntry = getController().getInProcessCache().getCacheEntryForCAS(subordinateCasCacheEntry.getInputCasReferenceId());
 					if ( inputCasCacheEntry != null )
@@ -677,9 +677,9 @@
 
 				getController().getControllerLatch().waitUntilInitialized();
 
-				// If a Process Request, increment number of docs processed
+				// If a Process Request, increment number of CASes processed
 				if (messageContext.getMessageIntProperty(AsynchAEMessage.MessageType) == AsynchAEMessage.Request
-						&& command == AsynchAEMessage.Process) {
+						&& command == AsynchAEMessage.Process &&!messageContext.propertyExists(AsynchAEMessage.CasSequence)) {
 					// Increment number of CASes processed by this service
 					getController().getServicePerformance().incrementNumberOfCASesProcessed();
 				}

Modified: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessResponseHandler.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/ProcessResponseHandler.java?rev=674655&r1=674654&r2=674655&view=diff
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessResponseHandler.java (original)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessResponseHandler.java Mon Jul  7 14:41:22 2008
@@ -316,11 +316,12 @@
 			ServicePerformance delegateServicePerformance = 
 				((AggregateAnalysisEngineController)getController()).
 					getServicePerformance(delegateKey);
+			/*
 			if ( delegateServicePerformance != null )
 			{
 				delegateServicePerformance.incrementNumberOfCASesProcessed();
 			}
-
+*/
 			//CAS cas = getController().getInProcessCache().getCasByReference(casReferenceId);
 			if (cas != null)
 			{

Added: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/BasicUimaJmxMonitorListener.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/monitor/BasicUimaJmxMonitorListener.java?rev=674655&view=auto
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/BasicUimaJmxMonitorListener.java (added)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/BasicUimaJmxMonitorListener.java Mon Jul  7 14:41:22 2008
@@ -0,0 +1,107 @@
+/*
+ * 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.aae.jmx.monitor;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.aae.UIMAEE_Constants;
+import org.apache.uima.util.Level;
+
+/**
+ * This class implements {@link JmxMonitorListener} interface. It provides basic formatting
+ * for UIMA-AS service metrics. All metrics are formatted and logged into a uima log if 
+ * one is defined. Otherwise, the output is dumped to stdout.
+ * 
+ *
+ */
+public class BasicUimaJmxMonitorListener implements JmxMonitorListener {
+
+	private static final Class CLASS_NAME = JmxMonitorListener.class;
+	private int maxNameLength=0;
+
+	/**
+	 * Constructor 
+	 * 
+	 * @param aMaxNameLength - the longest name of the UIMA-AS service. This is use to 
+	 * pad other names so that the output is easier to read.
+	 * 
+	 */
+	public BasicUimaJmxMonitorListener( int aMaxNameLength )
+	{
+		maxNameLength = aMaxNameLength;
+	}
+	
+	/**
+	 * Callback method called by the JmxMonitor after each checkpoint. 
+	 * 
+	 * @param sampleTime - last checkpoint time
+	 * @param metrics - an array of ServiceMetrics objects, each holding metrics for a specific
+	 * UIMA AS service.
+	 */
+	public void onNewMetrics(long sampleTime, ServiceMetrics[] metrics) {
+		
+		for( ServiceMetrics serviceMetrics: metrics )
+		{
+			//	Log metrics including shadow CAS pool metric for remote CAS multiplier. Filter out the top level service
+			if ( serviceMetrics.isCasMultiplier() && serviceMetrics.isServiceRemote() && !serviceMetrics.isTopLevelService() )
+			{
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "run", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_service_idle_time_shadow_cas_pool_INFO", new Object[] { format(sampleTime/1000000),padName(serviceMetrics.getServiceName()),format(serviceMetrics.getIdleTime()),  serviceMetrics.getProcessCount(), serviceMetrics.getQueueDepth(), format(serviceMetrics.getShadowCasPoolWaitTime()) , format(serviceMetrics.getTimeInCMGetNext())});
+			}
+			else
+			{
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "run", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_service_idle_time_shadow_cas_pool_INFO", new Object[] { format(sampleTime/1000000),padName(serviceMetrics.getServiceName()),format(serviceMetrics.getIdleTime()),  serviceMetrics.getProcessCount(), serviceMetrics.getQueueDepth(), format(serviceMetrics.getCasPoolWaitTime()) , format(serviceMetrics.getTimeInCMGetNext())});
+			}
+		}
+		//	Log group delimiter to make it easier to see metrics for this interval 
+		onNewSamplingInterval();
+	}
+
+	public void onNewSamplingInterval() 	{
+		UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "run", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_marker_INFO", new Object[] { });
+	}
+	private String format( double value)
+	{
+		NumberFormat formatter = new DecimalFormat();
+		formatter.setMinimumFractionDigits(0);
+		formatter.setMaximumFractionDigits(0);
+
+		return formatter.format(value);
+	}
+	private String format2( double value)
+	{
+		NumberFormat formatter = new DecimalFormat("0.00");
+
+		return formatter.format(value);
+	}
+	private String padName( String aName )
+	{
+		StringBuffer name = new StringBuffer(aName);
+		if ( aName.length() < maxNameLength )
+		{
+			for( int i=aName.length(); i < maxNameLength; i++ )
+			{
+				name.append(' ');
+			}
+		}
+		return name.toString();
+	}
+
+}

Added: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/JmxMonitorListener.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/monitor/JmxMonitorListener.java?rev=674655&view=auto
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/JmxMonitorListener.java (added)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/JmxMonitorListener.java Mon Jul  7 14:41:22 2008
@@ -0,0 +1,34 @@
+/*
+ * 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.aae.jmx.monitor;
+
+import org.apache.uima.aae.jmx.monitor.ServiceMetrics;
+
+public interface JmxMonitorListener {
+	/**
+	 * Provides metrics for all UIMA AS services collected during a checkpoint. This
+	 * method is called by the {@link JmxMonitor} after each checkpoint with the latest
+	 * metrics. The metrics are deltas except for queue depth attribute.
+	 * 
+	 * @param sampleTime - last checkpoint time
+	 * @param metrics - an array of ServiceMetrics objects, each holding metrics for a specific
+	 * UIMA AS service.
+	 */
+	public void onNewMetrics(long sampleTime, ServiceMetrics[] metrics);
+}

Added: incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/ServiceMetrics.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/monitor/ServiceMetrics.java?rev=674655&view=auto
==============================================================================
--- incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/ServiceMetrics.java (added)
+++ incubator/uima/sandbox/branches/uima-as-post1st/uimaj-as-core/src/main/java/org/apache/uima/aae/jmx/monitor/ServiceMetrics.java Mon Jul  7 14:41:22 2008
@@ -0,0 +1,110 @@
+/*
+ * 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.aae.jmx.monitor;
+
+public class ServiceMetrics {
+
+	private double timestamp;
+	private String serviceName;
+	private double idleTime;
+	private long processCount;
+	private double casPoolWaitTime;
+	private double shadowCasPoolWaitTime;
+	private double timeInCMGetNext;
+	private int samplingInterval;
+	private boolean isServiceRemote;
+	private boolean isCasMultiplier;
+	private boolean topLevelService;
+	private long queueDepth;
+	
+	public boolean isTopLevelService() {
+		return topLevelService;
+	}
+	public void setTopLevelService(boolean topLevelService) {
+		this.topLevelService = topLevelService;
+	}
+	public double getTimestamp() {
+		return timestamp;
+	}
+	public void setTimestamp(double timestamp) {
+		this.timestamp = timestamp;
+	}
+	public String getServiceName() {
+		return serviceName;
+	}
+	public void setServiceName(String serviceName) {
+		this.serviceName = serviceName;
+	}
+	public double getIdleTime() {
+		return idleTime;
+	}
+	public void setIdleTime(double idleTime) {
+		this.idleTime = idleTime;
+	}
+	public long getProcessCount() {
+		return processCount;
+	}
+	public void setProcessCount(long processCount) {
+		this.processCount = processCount;
+	}
+	public double getCasPoolWaitTime() {
+		return casPoolWaitTime;
+	}
+	public void setCasPoolWaitTime(double casPoolWaitTime) {
+		this.casPoolWaitTime = casPoolWaitTime;
+	}
+	public double getShadowCasPoolWaitTime() {
+		return shadowCasPoolWaitTime;
+	}
+	public void setShadowCasPoolWaitTime(double shadowCasPoolWaitTime) {
+		this.shadowCasPoolWaitTime = shadowCasPoolWaitTime;
+	}
+	public double getTimeInCMGetNext() {
+		return timeInCMGetNext;
+	}
+	public void setTimeInCMGetNext(double timeInCMGetNext) {
+		this.timeInCMGetNext = timeInCMGetNext;
+	}
+	public int getSamplingInterval() {
+		return samplingInterval;
+	}
+	public void setSamplingInterval(int samplingInterval) {
+		this.samplingInterval = samplingInterval;
+	}
+	public boolean isServiceRemote() {
+		return isServiceRemote;
+	}
+	public void setServiceRemote(boolean isServiceRemote) {
+		this.isServiceRemote = isServiceRemote;
+	}
+	public boolean isCasMultiplier() {
+		return isCasMultiplier;
+	}
+	public void setCasMultiplier(boolean isCasMultiplier) {
+		this.isCasMultiplier = isCasMultiplier;
+	}
+	public long getQueueDepth() {
+		return queueDepth;
+	}
+	public void setQueueDepth(long queueDepth) {
+		this.queueDepth = queueDepth;
+	}
+	
+	
+}