You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2008/01/08 15:38:51 UTC

svn commit: r610003 [5/7] - in /incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src: ./ main/ main/java/ main/java/org/ main/java/org/apache/ main/java/org/apache/uima/ main/java/org/apache/uima/aae/ main/java/org/apache/uima/aae/client/ main/java/o...

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerChain.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerChain.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerChain.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerChain.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,92 @@
+package org.apache.uima.aae.error;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.uima.aae.controller.AnalysisEngineController;
+
+public class ErrorHandlerChain extends LinkedList
+{
+	public ErrorHandlerChain( List aChainofHandlers )
+	{
+		this.addAll(aChainofHandlers);
+	}
+	
+	public Map getThresholds()
+	{
+		Map thresholds = new HashMap();
+		Iterator iterator = this.iterator();
+		while( iterator.hasNext() )
+		{
+			ErrorHandler handler = ((ErrorHandler)iterator.next());
+			Map thresholdMap = handler.getEndpointThresholdMap();
+			//	merge
+			thresholds.putAll(thresholdMap);
+		}
+		return thresholds;
+	}
+	public void handle( Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController )
+	{
+		boolean errorHandled = false;
+		if ( size() > 0)
+		{
+			Throwable cause = t;
+			if ( t instanceof AsynchAEException && t.getCause() != null  )
+			{
+				cause = t.getCause();
+			}
+			Iterator iterator = this.iterator();
+			while( errorHandled == false && iterator.hasNext() )
+			{
+				ErrorHandler handler = ((ErrorHandler)iterator.next());
+				errorHandled = handler.handleError( cause, anErrorContext, aController );
+			}
+/*			
+			String casReferenceId = (String)anErrorContext.get( AsynchAEMessage.CasReference);
+			if ( casReferenceId != null && aController instanceof AggregateAnalysisEngineController )
+			{
+				Endpoint endpoint = (Endpoint)anErrorContext.get(AsynchAEMessage.Endpoint);
+				try
+				{
+					boolean continueOnError = false;
+					if ( endpoint != null && endpoint.getEndpoint() != null )
+					{
+						continueOnError = ((AggregateAnalysisEngineController)aController).
+							continueOnError(casReferenceId, endpoint.getEndpoint(), (Exception)cause);
+					}
+					CacheEntry entry = null;
+					try
+					{
+						entry = aController.getInProcessCache().getCacheEntryForCAS(casReferenceId);
+					}
+					catch( AsynchAEException e) {}
+                    CAS cas = null;
+					//	Make sure that the ErrorHandler did not drop the cache entry and the CAS
+					if ( continueOnError && entry != null && (( cas = entry.getCas()) != null ) )
+					{
+						((AggregateAnalysisEngineController)aController).process(cas, casReferenceId);
+					}
+					else
+					{
+						if ( entry != null )
+						{
+							aController.dropCAS(casReferenceId, true);
+						}
+					}
+				}
+				catch( Exception e)
+				{
+					//	Any Exception Occuring here will be handled by the default Error Handler which 
+					//	should be the last in the chain
+					((ErrorHandler)getLast()).handleError(e, anErrorContext, aController);
+				}
+			}
+*/			
+		}
+	}
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerListener.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerListener.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerListener.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerListener.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,10 @@
+package org.apache.uima.aae.error;
+
+import org.apache.uima.aae.controller.AnalysisEngineController;
+
+public interface ErrorHandlerListener
+{
+	public void onError( Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController );
+
+	static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerListenerBase.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerListenerBase.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerListenerBase.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorHandlerListenerBase.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,20 @@
+package org.apache.uima.aae.error;
+
+import org.apache.uima.aae.controller.AnalysisEngineController;
+
+public class ErrorHandlerListenerBase implements ErrorHandlerListener
+{
+	private ErrorHandlerChain handlerChain;
+	
+	public void setErrorHandlerChain( ErrorHandlerChain aChainOfErrorHandlers)
+	{
+		handlerChain = aChainOfErrorHandlers;
+	}
+	public void onError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		handlerChain.handle( t, anErrorContext, aController);
+	}
+
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResult.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResult.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResult.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResult.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,47 @@
+package org.apache.uima.aae.error;
+
+import java.io.Serializable;
+
+import org.apache.uima.aae.error.ErrorResultTDs.TD;
+
+public interface ErrorResult extends Serializable
+{
+	public void setRootCause( Throwable aRootCause );
+	
+	public void addComponentKeyPath( String aComponentKeyPath );
+	
+	public void addComponentKeyPath(String aComponentKeyPath, boolean terminated, boolean disabled);
+
+	public void setTerminated();
+	
+	public void setDisabled();
+
+	/**
+	 * Returns the underlying root cause first reported as an error
+	 * @return Throwable
+	 */
+	public Throwable getRootCause();
+	/**
+	 * Returns a path consisting of a list of component key names
+	 * @return
+	 */
+	public ErrorResultComponentPath getComponentKeyPath();
+	/**
+	 * Returns true is any termination occurred with this error
+	 * @return
+	 */
+	public boolean wasTerminated();
+	/**
+	 * Returns true if any disabling occured with this error
+	 * @return
+	 */
+	public boolean wasDisabled();
+	/**
+	 * Returns a collection of paths to the components that were terminated or disabled
+	 * 
+	 * @return
+	 */
+	public ErrorResultTDs getTDs();
+	
+	static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultBaseImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultBaseImpl.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultBaseImpl.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultBaseImpl.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,152 @@
+/**
+ * 
+ */
+package org.apache.uima.aae.error;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.uima.aae.error.ErrorResultTDs.TD;
+import org.apache.uima.aae.error.ErrorResultTDsImpl.TDImpl;
+
+public class ErrorResultBaseImpl implements ErrorResult
+{
+	private static final long serialVersionUID = -964940732231472225L;
+
+	private ErrorResultComponentPath resultPath = 
+		new ErrorResultComponentPathImpl();
+	private ErrorResultTDs resultTDs = 
+		new ErrorResultTDsImpl();
+	
+	private boolean wasTerminated = false;
+	private boolean wasDisabled = false;
+	private Throwable rootCause;
+
+	/* (non-Javadoc)
+	 * @see org.apache.uima.aae.error.ErrorResult#addComponentKeyPath(java.lang.String)
+	 */
+	public void addComponentKeyPath( String aComponentKeyPath )
+	{
+		addComponentKeyPath( aComponentKeyPath, false, false);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.uima.aae.error.ErrorResult#addComponentKeyPath(java.lang.String)
+	 */
+	public void addComponentKeyPath(String aComponentKeyPath, boolean terminated, boolean disabled)
+	{
+		resultPath.add(aComponentKeyPath, 0);
+		wasTerminated = terminated;
+		wasDisabled = disabled;
+		if ( wasTerminated || wasDisabled )
+		{
+			TD td = ((ErrorResultTDsImpl)resultTDs).new TDImpl(aComponentKeyPath, wasTerminated, wasDisabled );
+			resultTDs.add(td);
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.uima.aae.error.ErrorResult#getComponentKeyPath()
+	 */
+	public ErrorResultComponentPath getComponentKeyPath()
+	{
+		return resultPath;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.uima.aae.error.ErrorResult#getRootCause()
+	 */
+	public Throwable getRootCause()
+	{
+		return rootCause;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.uima.aae.error.ErrorResult#getTDs()
+	 */
+	public ErrorResultTDs getTDs()
+	{
+		return resultTDs;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.uima.aae.error.ErrorResult#setDisabled()
+	 */
+	public void setDisabled()
+	{
+		wasDisabled = true;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.uima.aae.error.ErrorResult#setRootCause(java.lang.Throwable)
+	 */
+	public void setRootCause(Throwable aThrowable)
+	{
+		Throwable t = aThrowable, prev = null;
+		while( (t = t.getCause()) != null )
+		{
+			prev = t;
+		}
+		rootCause = ( prev == null )? aThrowable : prev; 
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.uima.aae.error.ErrorResult#setTerminated()
+	 */
+	public void setTerminated()
+	{
+		wasTerminated = true;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.uima.aae.error.ErrorResult#wasDisabled()
+	 */
+	public boolean wasDisabled()
+	{
+		return wasDisabled;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.uima.aae.error.ErrorResult#wasTerminated()
+	 */
+	public boolean wasTerminated()
+	{
+		return wasTerminated;
+	}
+
+	public static void main( String[] args )
+	{
+		ErrorResultBaseImpl errorResult = new ErrorResultBaseImpl();
+
+		errorResult.setRootCause(new AsynchAEException(new NullPointerException()));
+		errorResult.addComponentKeyPath("InnerMostLevel");
+		errorResult.addComponentKeyPath("InnerLevel", true, false);
+		errorResult.addComponentKeyPath("TopLevel");
+		
+		System.out.println("Root Cause:"+errorResult.getRootCause());
+		ErrorResultComponentPath ercp = errorResult.getComponentKeyPath();
+		Iterator it = ercp.iterator();
+		int inx=1;
+		while( it.hasNext())
+		{
+			System.out.print((String)it.next());
+			System.out.println("");
+			
+			for( int i=0;i<inx; i++ )
+			{
+				System.out.print("\t");
+			}
+			inx++;
+		}
+		System.out.println("");
+		
+		ErrorResultTDs tds = errorResult.getTDs();
+		Iterator it2 = tds.iterator();
+		while( it2.hasNext())
+		{
+			System.out.println( ((TD)it2.next()).gatPath());
+		}
+	}
+	private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultComponentPath.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultComponentPath.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultComponentPath.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultComponentPath.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,14 @@
+package org.apache.uima.aae.error;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+public interface ErrorResultComponentPath extends Serializable
+{
+	public Iterator iterator();
+	public void add( String aPath );
+	public void add( String aPath, int anInsertPosition);
+	public String get( int aPosition );
+	
+	static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultComponentPathImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultComponentPathImpl.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultComponentPathImpl.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultComponentPathImpl.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,37 @@
+package org.apache.uima.aae.error;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class ErrorResultComponentPathImpl implements ErrorResultComponentPath
+{
+	private static final long serialVersionUID = 100262915217554060L;
+
+	private List pathList = new ArrayList();
+	
+	public void add(String aPath)
+	{
+		this.add(aPath, pathList.size());
+	}
+
+	public void add(String aPath, int anInsertPosition)
+	{
+		pathList.add(anInsertPosition, aPath);
+	}
+
+	public String get(int aPosition)
+	{
+		if ( aPosition >= 0 && aPosition <= pathList.size())
+		{
+			return (String)pathList.get(aPosition);
+		}
+		return null;
+	}
+
+	public Iterator iterator()
+	{
+		return pathList.iterator();
+	}
+	private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultTDs.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultTDs.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultTDs.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultTDs.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,23 @@
+package org.apache.uima.aae.error;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+public interface ErrorResultTDs extends Serializable
+{
+	public Iterator iterator();
+	public void add( TD aTD);
+	public void add( TD aTD, int anInsertPosition);
+	public TD get(int aPosition);
+	
+	public interface TD extends Serializable
+	{
+		public String gatPath();
+		public void setTerminated();
+		public void setDisabled();
+		public boolean wasTerminated();
+		public boolean wasDisabled();
+	}
+	
+	static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultTDsImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultTDsImpl.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultTDsImpl.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ErrorResultTDsImpl.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,77 @@
+package org.apache.uima.aae.error;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class ErrorResultTDsImpl implements ErrorResultTDs
+{
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -5385443370047862288L;
+
+	private List list = new ArrayList();
+	public void add(TD aTD)
+	{
+		this.add(aTD, 0);
+	}
+
+	public void add(TD aTD, int anInsertPosition)
+	{
+		list.add(anInsertPosition, aTD);
+	}
+
+	public TD get(int aPosition)
+	{
+		if ( aPosition >= 0 && aPosition <= list.size())
+		{
+			return (TD)list.get(aPosition);
+		}
+		return null;
+	}
+
+	public Iterator iterator()
+	{
+		return list.iterator();
+	}
+
+	public class TDImpl implements TD
+	{
+		/**
+		 * 
+		 */
+		private static final long serialVersionUID = 2160592875336611921L;
+		private String path;
+		private boolean wasTerminated;
+		private boolean wasDisabled;
+		
+		public TDImpl( String aPath, boolean terminated, boolean disabled )
+		{
+			path = aPath;
+			wasDisabled = disabled;
+			wasTerminated = terminated;
+		}
+		public String gatPath()
+		{
+			return path;
+		}
+		public void setTerminated()
+		{
+			wasTerminated = true;
+		}
+		public void setDisabled()
+		{
+			wasDisabled = true;
+		}
+		public boolean wasTerminated()
+		{
+			return wasTerminated;
+		}
+		public boolean wasDisabled()
+		{
+			return wasDisabled;
+		}
+	}
+	private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ExpiredMessageException.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ExpiredMessageException.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ExpiredMessageException.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ExpiredMessageException.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,27 @@
+package org.apache.uima.aae.error;
+
+public class ExpiredMessageException extends Exception
+{
+	public ExpiredMessageException()
+	{
+		super();
+	}
+
+	public ExpiredMessageException(String message)
+	{
+		super(message);
+	}
+
+	public ExpiredMessageException(Throwable cause)
+	{
+		super(cause);
+	}
+
+	public ExpiredMessageException(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/InvalidMessageException.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/InvalidMessageException.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/InvalidMessageException.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/InvalidMessageException.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,31 @@
+package org.apache.uima.aae.error;
+
+public class InvalidMessageException extends Exception
+{
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+	public InvalidMessageException()
+	{
+		super();
+	}
+
+	public InvalidMessageException(String message)
+	{
+		super(message);
+	}
+
+	public InvalidMessageException(Throwable cause)
+	{
+		super(cause);
+	}
+
+	public InvalidMessageException(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/MessageTimeoutException.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/MessageTimeoutException.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/MessageTimeoutException.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/MessageTimeoutException.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,27 @@
+package org.apache.uima.aae.error;
+
+public class MessageTimeoutException extends Exception
+{
+	public MessageTimeoutException()
+	{
+		super();
+	}
+
+	public MessageTimeoutException(String message)
+	{
+		super(message);
+	}
+
+	public MessageTimeoutException(Throwable cause)
+	{
+		super(cause);
+	}
+
+	public MessageTimeoutException(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ServiceShutdownException.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ServiceShutdownException.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ServiceShutdownException.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/ServiceShutdownException.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,7 @@
+package org.apache.uima.aae.error;
+
+public class ServiceShutdownException extends Exception
+{
+	private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/Threshold.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/Threshold.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/Threshold.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/Threshold.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,104 @@
+package org.apache.uima.aae.error;
+
+public class Threshold
+{
+	private long threshold;
+
+	private String action;
+
+	private long window;
+
+	private int maxRetries;
+
+	private boolean continueOnRetryFailure;
+
+	public Threshold() {}
+	
+	public Threshold(long aThreshold, long aWindow, String anAction)
+	{
+		this.threshold = aThreshold;
+		this.window = aWindow;
+		action = anAction;
+	}
+
+	public Threshold(long aThreshold, String anAction)
+	{
+		this.threshold = aThreshold;
+		this.window = 100;
+		action = anAction;
+	}
+
+	public long getWindow()
+	{
+		return window;
+	}
+
+	public void setWindow(long aWindow)
+	{
+		window = aWindow;
+	}
+
+	public long getThreshold()
+	{
+		return threshold;
+	}
+
+	public long getThresholdCount()
+	{
+		return threshold;
+	}
+	
+//	public void setThresholdCount( long aCount )
+	public void setThreshold( long aCount )
+	{
+		threshold = aCount;
+	}
+	public String getAction()
+	{
+		return action;
+	}
+
+	public boolean exceeded(long value)
+	{
+		if (threshold == 0) {
+		  return false;  
+    }
+    return (value >= threshold-1);
+	}
+	public boolean maxRetriesExceeded( long value )
+	{
+		return (value >= maxRetries);
+	}
+
+	public long getMax()
+	{
+		return threshold;
+	}
+
+	public int getMaxRetries()
+	{
+		return maxRetries;
+	}
+
+	public void setMaxRetries(int maxRetries)
+	{
+		this.maxRetries = maxRetries;
+	}
+
+	public boolean getContinueOnRetryFailure()
+	{
+		return continueOnRetryFailure;
+	}
+
+	public void setContinueOnRetryFailure(boolean continueOnRetryFailure)
+	{
+		this.continueOnRetryFailure = continueOnRetryFailure;
+	}
+
+
+	public void setAction(String action)
+	{
+		this.action = action;
+	}
+	private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEECollectionProcessCompleteTimeout.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEECollectionProcessCompleteTimeout.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEECollectionProcessCompleteTimeout.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEECollectionProcessCompleteTimeout.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,25 @@
+package org.apache.uima.aae.error;
+
+public class UimaEECollectionProcessCompleteTimeout extends Exception
+{
+	public UimaEECollectionProcessCompleteTimeout()
+	{
+	}
+
+	public UimaEECollectionProcessCompleteTimeout(String message)
+	{
+		super(message);
+	}
+
+	public UimaEECollectionProcessCompleteTimeout(Throwable cause)
+	{
+		super(cause);
+	}
+
+	public UimaEECollectionProcessCompleteTimeout(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEMetaRequestTimeout.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEMetaRequestTimeout.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEMetaRequestTimeout.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEMetaRequestTimeout.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,25 @@
+package org.apache.uima.aae.error;
+
+public class UimaEEMetaRequestTimeout extends Exception
+{
+	public UimaEEMetaRequestTimeout()
+	{
+	}
+
+	public UimaEEMetaRequestTimeout(String message)
+	{
+		super(message);
+	}
+
+	public UimaEEMetaRequestTimeout(Throwable cause)
+	{
+		super(cause);
+	}
+
+	public UimaEEMetaRequestTimeout(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEProcessCasTimeout.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEProcessCasTimeout.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEProcessCasTimeout.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEProcessCasTimeout.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,25 @@
+package org.apache.uima.aae.error;
+
+public class UimaEEProcessCasTimeout extends Exception
+{
+	public UimaEEProcessCasTimeout()
+	{
+	}
+
+	public UimaEEProcessCasTimeout(String message)
+	{
+		super(message);
+	}
+
+	public UimaEEProcessCasTimeout(Throwable cause)
+	{
+		super(cause);
+	}
+
+	public UimaEEProcessCasTimeout(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEServiceException.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEServiceException.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEServiceException.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEEServiceException.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,34 @@
+package org.apache.uima.aae.error;
+
+public class UimaEEServiceException extends Exception
+{
+	private static final long serialVersionUID = -8476335131285562566L;
+
+	/**
+	 * 
+	 */
+	public UimaEEServiceException()
+	{
+		// TODO Auto-generated constructor stub
+	}
+
+	public UimaEEServiceException(String message)
+	{
+		super(message);
+		// TODO Auto-generated constructor stub
+	}
+
+	public UimaEEServiceException(Throwable cause)
+	{
+		super(cause);
+		// TODO Auto-generated constructor stub
+	}
+
+	public UimaEEServiceException(String message, Throwable cause)
+	{
+		super(message, cause);
+		// TODO Auto-generated constructor stub
+	}
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEETimeoutException.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEETimeoutException.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEETimeoutException.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UimaEETimeoutException.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,25 @@
+package org.apache.uima.aae.error;
+
+public class UimaEETimeoutException extends Exception
+{
+	public UimaEETimeoutException()
+	{
+	}
+
+	public UimaEETimeoutException(String message)
+	{
+		super(message);
+	}
+
+	public UimaEETimeoutException(Throwable cause)
+	{
+		super(cause);
+	}
+
+	public UimaEETimeoutException(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UnknownDestinationException.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UnknownDestinationException.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UnknownDestinationException.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/UnknownDestinationException.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,27 @@
+package org.apache.uima.aae.error;
+
+public class UnknownDestinationException extends Exception
+{
+	public UnknownDestinationException()
+	{
+		super();
+	}
+
+	public UnknownDestinationException(String message)
+	{
+		super(message);
+	}
+
+	public UnknownDestinationException(Throwable cause)
+	{
+		super(cause);
+	}
+
+	public UnknownDestinationException(String message, Throwable cause)
+	{
+		super(message, cause);
+	}
+
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/AnalysisEngineProcessExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/AnalysisEngineProcessExceptionHandler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/AnalysisEngineProcessExceptionHandler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/AnalysisEngineProcessExceptionHandler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,65 @@
+package org.apache.uima.aae.error.handler;
+
+import java.util.Map;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.aae.UIMAEE_Constants;
+import org.apache.uima.aae.controller.AnalysisEngineController;
+import org.apache.uima.aae.controller.PrimitiveAnalysisEngineController;
+import org.apache.uima.aae.error.ErrorContext;
+import org.apache.uima.aae.error.ErrorHandler;
+import org.apache.uima.aae.error.ErrorHandlerBase;
+import org.apache.uima.aae.message.AsynchAEMessage;
+import org.apache.uima.aae.monitor.Monitor;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.util.Level;
+
+public class AnalysisEngineProcessExceptionHandler extends ErrorHandlerBase implements ErrorHandler
+{
+	private static final Class CLASS_NAME = AnalysisEngineProcessExceptionHandler.class;
+
+	public AnalysisEngineProcessExceptionHandler( Map anEndpointThreasholdMap )
+	{
+		super(anEndpointThreasholdMap);
+	}
+	public AnalysisEngineProcessExceptionHandler( )
+	{
+	}
+	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		if (t instanceof AnalysisEngineProcessException )
+		{
+			String casReferenceId=null;
+			if ( anErrorContext.containsKey(AsynchAEMessage.CasReference ) )
+			{
+				casReferenceId = (String)anErrorContext.get( AsynchAEMessage.CasReference);
+			}
+			String endpointName = getEndpointName(aController, anErrorContext);
+			t.printStackTrace();
+			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(),
+	                "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_process_exception__INFO",
+	                new Object[] { endpointName, casReferenceId, t.getLocalizedMessage()  });
+
+			
+			
+			if (!super.exceedsThreshold(Monitor.ProcessErrorCount, endpointName, aController))
+			{
+				//	This will drop the cas and clear the cache entry if the controller is Primitive and the service is not collocated with an Aggregate
+				if ( aController instanceof PrimitiveAnalysisEngineController && aController.isTopLevelComponent())
+				{
+					aController.takeAction( ErrorHandler.DROPCAS, endpointName, anErrorContext);
+				}
+			}
+			else
+			{
+				String action = getAction(Monitor.ProcessErrorCount, endpointName);
+				aController.takeAction( action, endpointName, anErrorContext);
+			}			
+			return true;
+		}
+		return false;
+	}
+
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/AsynchAEExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/AsynchAEExceptionHandler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/AsynchAEExceptionHandler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/AsynchAEExceptionHandler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,24 @@
+package org.apache.uima.aae.error.handler;
+
+import org.apache.uima.aae.controller.AnalysisEngineController;
+import org.apache.uima.aae.error.AsynchAEException;
+import org.apache.uima.aae.error.ErrorContext;
+import org.apache.uima.aae.error.ErrorHandler;
+import org.apache.uima.aae.error.ErrorHandlerBase;
+import org.apache.uima.aae.error.MessageTimeoutException;
+
+public class AsynchAEExceptionHandler extends ErrorHandlerBase implements ErrorHandler
+{
+	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		if (t instanceof AsynchAEException)
+		{
+			//System.out.println("AsynchAEException Stack::\n");
+			t.printStackTrace();
+			
+		}
+		return false;
+	}
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/CpcErrorHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/CpcErrorHandler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/CpcErrorHandler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/CpcErrorHandler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,98 @@
+package org.apache.uima.aae.error.handler;
+
+import java.util.Map;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.aae.UIMAEE_Constants;
+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.ErrorContext;
+import org.apache.uima.aae.error.ErrorHandler;
+import org.apache.uima.aae.error.ErrorHandlerBase;
+import org.apache.uima.aae.error.Threshold;
+import org.apache.uima.aae.message.AsynchAEMessage;
+import org.apache.uima.aae.monitor.Monitor;
+import org.apache.uima.util.Level;
+
+public class CpcErrorHandler  extends ErrorHandlerBase implements ErrorHandler
+{
+	private static final Class CLASS_NAME = CpcErrorHandler.class;
+
+	private Map delegateMap = null;
+	
+	public CpcErrorHandler( Map aDelegateMap )
+	{
+		delegateMap = aDelegateMap;
+	}
+	
+	public Map getEndpointThresholdMap()
+	{
+		return delegateMap;
+	}
+
+	
+	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		
+		if (  !isHandlerForError(anErrorContext, AsynchAEMessage.CollectionProcessComplete) )
+		{
+			return false;
+		}
+		UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+				UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", t);
+
+		Endpoint endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+		if ( endpoint != null )
+		{
+			Threshold threshold = null;
+			if ( aController instanceof PrimitiveAnalysisEngineController )
+			{
+				threshold = (Threshold)delegateMap.get("");
+			}
+			else
+			{
+				threshold = super.getThreshold(endpoint, delegateMap, aController);
+			}
+			try
+			{
+				if ( aController instanceof AggregateAnalysisEngineController )
+				{
+					endpoint = ((AggregateAnalysisEngineController)aController).getClientEndpoint();
+				}
+				aController.getOutputChannel().sendReply(t, null, endpoint, AsynchAEMessage.CollectionProcessComplete);
+			}
+			catch( Exception e)
+			{
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+						UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e);
+			}
+
+			if ( threshold != null && threshold.getAction().equalsIgnoreCase(ErrorHandler.TERMINATE ))
+	    	{
+				aController.takeAction(threshold.getAction(), endpoint.getEndpoint(), anErrorContext);
+	    	}
+	    	else if ( threshold == null )
+	    	{
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.CONFIG, getClass().getName(), "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_no_threshold_for_endpoint__CONFIG", new Object[] { aController.getName(), "Collection Processing Complete",  aController.getName() });
+	    	}
+		}
+		else
+		{
+			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(), "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_no_endpoint_for_getmeta_retry__INFO", new Object[] { aController.getName()});
+		}
+		return true;
+	}
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args)
+	{
+		// TODO Auto-generated method stub
+
+	}
+	private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultDelegateErrorHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultDelegateErrorHandler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultDelegateErrorHandler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultDelegateErrorHandler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,47 @@
+package org.apache.uima.aae.error.handler;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.aae.UIMAEE_Constants;
+import org.apache.uima.aae.controller.AnalysisEngineController;
+import org.apache.uima.aae.controller.Endpoint;
+import org.apache.uima.aae.error.ErrorContext;
+import org.apache.uima.aae.error.ErrorHandler;
+import org.apache.uima.aae.error.ErrorHandlerBase;
+import org.apache.uima.aae.error.UimaEEServiceException;
+import org.apache.uima.aae.message.AsynchAEMessage;
+import org.apache.uima.util.Level;
+
+public class DefaultDelegateErrorHandler extends ErrorHandlerBase implements ErrorHandler
+{
+	private static final Class CLASS_NAME = DefaultDelegateErrorHandler.class;
+
+	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		
+		if ( t instanceof UimaEEServiceException)
+		{
+			t.printStackTrace();
+			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+					UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", new Object[] { t });
+
+			if ( anErrorContext.containsKey(AsynchAEMessage.Endpoint) )
+			{
+				Endpoint endpoint = (Endpoint)anErrorContext.get(AsynchAEMessage.Endpoint);
+				String casReferenceId = (String)anErrorContext.get(AsynchAEMessage.CasReference);
+
+				try
+				{
+					aController.getOutputChannel().sendReply(t, casReferenceId, endpoint, AsynchAEMessage.Process );
+				}
+				catch( Throwable e)
+				{
+					e.printStackTrace();
+				}
+			}
+			return true;
+		}
+		return false;
+	}
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultExpiredMessageHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultExpiredMessageHandler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultExpiredMessageHandler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultExpiredMessageHandler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,71 @@
+package org.apache.uima.aae.error.handler;
+
+import java.util.Map;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.aae.UIMAEE_Constants;
+import org.apache.uima.aae.controller.AggregateAnalysisEngineController_impl;
+import org.apache.uima.aae.controller.AnalysisEngineController;
+import org.apache.uima.aae.controller.Endpoint;
+import org.apache.uima.aae.error.ErrorContext;
+import org.apache.uima.aae.error.ErrorHandler;
+import org.apache.uima.aae.error.ErrorHandlerBase;
+import org.apache.uima.aae.error.ExpiredMessageException;
+import org.apache.uima.aae.message.AsynchAEMessage;
+import org.apache.uima.util.Level;
+
+/**
+ * ErrorHandler that handles expired messages. These are reply messages that arrive after
+ * the request message times or a message that has already been processed.
+ * 
+ *
+ */
+public class DefaultExpiredMessageHandler extends ErrorHandlerBase implements ErrorHandler 
+{
+	
+	private static final Class CLASS_NAME = DefaultExpiredMessageHandler.class;
+
+	public DefaultExpiredMessageHandler( Map anEndpointThreasholdMap )
+	{
+		super(anEndpointThreasholdMap);
+	}
+	public DefaultExpiredMessageHandler( )
+	{
+	}
+	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		if (t instanceof ExpiredMessageException)
+		{
+			String endpointName=null;
+			String casReferenceId=null;
+			if ( anErrorContext.containsKey(AsynchAEMessage.Endpoint) )
+			{
+				endpointName = (String) anErrorContext.get(AsynchAEMessage.Endpoint);
+				try
+				{
+					if ( anErrorContext.containsKey(AsynchAEMessage.CasReference ) )
+					{
+						casReferenceId = (String)anErrorContext.get( AsynchAEMessage.CasReference);
+					}
+				}
+				catch ( Exception e)
+				{
+					//System.out.println(Thread.currentThread().getName() + " DefaultTimeoutHandler Exception while sending request for metadata to endpoint::" + endpointName);
+					e.printStackTrace();
+					// Log this Exception and return false. Let the Default
+					// Catch All
+					// Handler handle this situation
+				}
+			}
+			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(),
+	                "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_expired_message__INFO",
+	                new Object[] { endpointName, casReferenceId  });
+
+			return true;
+		}
+		return false;
+	}
+
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultHandler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultHandler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultHandler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,125 @@
+package org.apache.uima.aae.error.handler;
+
+import java.util.Map;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.aae.UIMAEE_Constants;
+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.error.ErrorContext;
+import org.apache.uima.aae.error.ErrorHandler;
+import org.apache.uima.aae.error.ErrorHandlerBase;
+import org.apache.uima.aae.message.AsynchAEMessage;
+import org.apache.uima.aae.monitor.Monitor;
+import org.apache.uima.util.Level;
+
+public class DefaultHandler extends ErrorHandlerBase implements ErrorHandler
+{
+	private static final Class CLASS_NAME = DefaultHandler.class;
+
+	public DefaultHandler()
+	{
+	}
+
+	public DefaultHandler( Map anEndpointThreasholdMap )
+	{
+		super(anEndpointThreasholdMap);
+	}
+    
+	private Endpoint getDestination( AnalysisEngineController aController, ErrorContext anErrorContext)
+	{
+		Endpoint endpoint = null;
+		String casReferenceId = (String)anErrorContext.get( AsynchAEMessage.CasReference);
+		if ( aController instanceof AggregateAnalysisEngineController )
+		{
+			endpoint = ((AggregateAnalysisEngineController)aController).getMessageOrigin(casReferenceId);
+
+			//	Remove the entry from the Message Origin Map since it is no longer needed. The CAS will be
+			//	dropped as soon as the exception is sent up to the client.
+			if (endpoint != null && aController.isTopLevelComponent())
+			{
+				((AggregateAnalysisEngineController)aController).removeMessageOrigin( casReferenceId);
+			}
+		}
+		else if ( anErrorContext.containsKey(AsynchAEMessage.Endpoint))
+		{
+			endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+		}
+		return endpoint;
+	}
+	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		String casReferenceId = null;
+		Endpoint endpoint = null;
+		String key = null;
+		try
+		{
+			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+					UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", t);
+			
+			endpoint = getDestination(aController, anErrorContext);
+			casReferenceId = (String)anErrorContext.get( AsynchAEMessage.CasReference);
+
+			//	Notify the parent of the exception
+			if ( endpoint != null && !endpoint.isCasMultiplier())
+			{
+				aController.getOutputChannel().sendReply(t, casReferenceId, endpoint, AsynchAEMessage.Process);
+
+				//	Lookup Delegate's key
+				key = super.getDelegateKey(endpoint, aController);
+				
+				if (super.exceedsThreshold(Monitor.ErrorCount, key, aController))
+				{
+					String action = getAction(Monitor.ErrorCount, key);
+					aController.takeAction( action, key, anErrorContext);
+				}
+			}
+			else if ( endpoint == null)
+			{
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(), "handleError", 
+						UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_no_endpoint__INFO", new Object[] { aController.getName() });
+			}
+		}
+		catch( Exception e)
+		{
+			e.printStackTrace();
+			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+					UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e);
+		}
+		finally
+		{
+			try
+			{
+				//	Only top level component can Drop the CAS. 
+				if ( aController.isTopLevelComponent() )
+				{
+					aController.takeAction( ErrorHandler.DROPCAS, key, anErrorContext);
+				}			
+				else if ( casReferenceId != null && aController instanceof AggregateAnalysisEngineController )
+				{
+					((AggregateAnalysisEngineController)aController).dropFlow(casReferenceId, true);
+					((AggregateAnalysisEngineController)aController).removeMessageOrigin(casReferenceId);
+
+				}
+
+				aController.dropStats(casReferenceId, aController.getName());
+				
+				endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+				if ( endpoint != null )
+				{
+					aController.dropStats(casReferenceId, endpoint.getEndpoint());
+				}
+			}
+			catch( Exception e)
+			{
+				e.printStackTrace();
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+						UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e);
+			}
+		}
+		return true;
+	}
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultTimeoutHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultTimeoutHandler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultTimeoutHandler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/DefaultTimeoutHandler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,129 @@
+package org.apache.uima.aae.error.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+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.error.ErrorContext;
+import org.apache.uima.aae.error.ErrorHandler;
+import org.apache.uima.aae.error.ErrorHandlerBase;
+import org.apache.uima.aae.error.MessageTimeoutException;
+import org.apache.uima.aae.message.AsynchAEMessage;
+import org.apache.uima.aae.monitor.Monitor;
+
+public class DefaultTimeoutHandler extends ErrorHandlerBase implements ErrorHandler 
+{
+	public DefaultTimeoutHandler( Map anEndpointThreasholdMap )
+	{
+		super(anEndpointThreasholdMap);
+	}
+	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		if (t instanceof MessageTimeoutException)
+		{
+			if (anErrorContext.containsKey(AsynchAEMessage.Command) && anErrorContext.containsKey(AsynchAEMessage.Endpoint))
+			{
+				Endpoint endpoint = null;
+				try
+				{
+					endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+					int command = ((Integer) anErrorContext.get(AsynchAEMessage.Command)).intValue();
+					if (AsynchAEMessage.Process == command)
+					{
+						if ( anErrorContext.containsKey(AsynchAEMessage.CasReference ) )
+						{
+							
+							if (!super.exceedsThreshold(Monitor.ProcessRequestTimeoutCount, endpoint.getEndpoint(), aController))
+							{
+								if ( endpoint.isRetryEnabled() && aController instanceof AggregateAnalysisEngineController )
+								{
+									String casReferenceId = (String)anErrorContext.get( AsynchAEMessage.CasReference);
+									//System.out.println(Thread.currentThread().getName() + " DefaultTimeoutHandler sending request to process CAS to endpoint::" + endpoint.getEndpoint()+" CasReferenceId::"+casReferenceId);
+									((AggregateAnalysisEngineController) aController).retryProcessCASRequest(casReferenceId, endpoint, false);
+									return true; // Handled the exception
+								}
+							}
+							else
+							{
+								String casReferenceId = (String)anErrorContext.get( AsynchAEMessage.CasReference);
+								String action = getAction(Monitor.MetadataRequestTimeoutCount, endpoint.getEndpoint());
+
+								if ( ErrorHandler.DISABLE.equalsIgnoreCase(action))
+								{
+									List list = new ArrayList();
+									list.add(endpoint.getEndpoint());
+									((AggregateAnalysisEngineController)aController).disableDelegates(list);
+									
+									//	The following should be done after consultation with the Flow
+									//((AggregateAnalysisEngineController)aController).dropCAS(casReferenceId, true);
+									
+									
+									
+									return true;
+								}
+								
+								
+								
+								
+								/*
+								CacheEntry cachedEntry =
+									((AggregateAnalysisEngineController) aController).getInProcessCache().getCacheEntryForCAS(casReferenceId);
+								if ( cachedEntry.getNumberOfParallelDelegates() > 1 )
+								{
+									if ( ErrorHandler.CONTINUE.equalsIgnoreCase(action) )
+									{
+									}
+								}
+								*/
+							}
+							
+						}
+						else
+						{
+							//	unhandled error. Missing CasReference Id in error context
+						}
+					}
+					else if (AsynchAEMessage.GetMeta == command)
+					{
+						String key = ((AggregateAnalysisEngineController) aController).lookUpDelegateKey(endpoint.getEndpoint());
+						//System.out.println(Thread.currentThread().getName() + " DefaultTimeoutHandler handles Timeout For GetMetadata ");
+						if (!exceedsThreshold(Monitor.MetadataRequestTimeoutCount, key, aController))
+						{
+							//System.out.println(Thread.currentThread().getName() + " DefaultTimeoutHandler sending request for metadata to endpoint::" + endpoint.getEndpoint());
+							if (aController instanceof AggregateAnalysisEngineController)
+							{
+								((AggregateAnalysisEngineController) aController).retryMetadataRequest(endpoint);
+								return true; // Handled the exception
+							}
+						}
+						else
+						{
+							String action = getAction(Monitor.MetadataRequestTimeoutCount, key); //endpoint.getEndpoint());
+							if ( action != null )
+							{
+//								System.out.println(Thread.currentThread().getName() + " DefaultTimeoutHandler Exceeded Threshold - Taking Action:::"+action+" endpoint::" + endpoint.getEndpoint());
+							    aController.takeAction(action, endpoint.getEndpoint(), anErrorContext);
+								return true; // Handled the exception
+							}
+						}
+					}
+				}
+				catch ( Exception e)
+				{
+					//e.printStackTrace();
+					// Log this Exception and return false. Let the Default
+					// Catch All
+					// Handler handle this situation
+				}
+			}
+		}
+		return false;
+	}
+
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/GetMetaErrorHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/GetMetaErrorHandler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/GetMetaErrorHandler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/GetMetaErrorHandler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,95 @@
+package org.apache.uima.aae.error.handler;
+
+import java.util.Map;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.aae.UIMAEE_Constants;
+import org.apache.uima.aae.controller.AggregateAnalysisEngineController;
+import org.apache.uima.aae.controller.AnalysisEngineController;
+import org.apache.uima.aae.controller.BaseAnalysisEngineController;
+import org.apache.uima.aae.controller.Endpoint;
+import org.apache.uima.aae.controller.PrimitiveAnalysisEngineController;
+import org.apache.uima.aae.error.ErrorContext;
+import org.apache.uima.aae.error.ErrorHandler;
+import org.apache.uima.aae.error.ErrorHandlerBase;
+import org.apache.uima.aae.error.Threshold;
+import org.apache.uima.aae.message.AsynchAEMessage;
+import org.apache.uima.util.Level;
+
+public class GetMetaErrorHandler extends ErrorHandlerBase implements ErrorHandler
+{
+	private static final Class CLASS_NAME = GetMetaErrorHandler.class;
+
+	private Map delegateMap = null;
+	
+	public GetMetaErrorHandler( Map aDelegateMap )
+	{
+		delegateMap = aDelegateMap;
+	}
+	
+	public Map getEndpointThresholdMap()
+	{
+		return delegateMap;
+	}
+	private boolean terminate( Threshold aThreshold )
+	{
+		return (aThreshold == null || 
+				aThreshold.getAction() == null || 
+				aThreshold.getAction().trim().length() == 0 || 
+				ErrorHandler.TERMINATE.equalsIgnoreCase(aThreshold.getAction() ));
+	}
+	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		//	GetMeta errors are only handled by the Aggregate AS
+		if ( aController instanceof PrimitiveAnalysisEngineController || 
+			 !isHandlerForError(anErrorContext, AsynchAEMessage.GetMeta) )
+		{
+			return false;
+		}
+		
+		UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+				UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", t);
+
+		Endpoint endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+
+		if ( endpoint != null && aController instanceof AggregateAnalysisEngineController )
+		{
+			Threshold threshold = super.getThreshold(endpoint, delegateMap, aController);
+	    	String key = ((AggregateAnalysisEngineController)aController).lookUpDelegateKey(endpoint.getEndpoint());
+	    	//	If threshold is not defined, assume action=terminate
+	    	if (  threshold == null || threshold.getMaxRetries() == 0 || 
+	    			  ( super.retryLastCommand(AsynchAEMessage.GetMeta, endpoint, aController, key, threshold, anErrorContext) == false )	
+	    	        )
+	    	{
+	    		if ( terminate(threshold ) )
+	    		{
+	    			System.out.println("!!!!!!!!!!!! Exceeded Threshold Terminating !!!!!!!!!!!!!!");
+	    			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
+	    	                "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_terminate_service__INFO",
+	    	                new Object[] {aController.getComponentName(), endpoint.getEndpoint()});
+//	    			aController.propagateShutdownEventToTheTopComponent();
+	    			aController.terminate();
+	    		}
+	    		else
+	    		{
+		    		aController.takeAction(threshold.getAction(), endpoint.getEndpoint(), anErrorContext);
+	    		}
+	    	}
+		}
+		else
+		{
+			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(), "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_no_endpoint_for_getmeta_retry__INFO", new Object[] { aController.getName()});
+		}
+		return true;
+	}
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args)
+	{
+		// TODO Auto-generated method stub
+
+	}
+	private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/ProcessCasErrorHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/ProcessCasErrorHandler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/ProcessCasErrorHandler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/ProcessCasErrorHandler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,423 @@
+package org.apache.uima.aae.error.handler;
+
+import java.net.ConnectException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.aae.UIMAEE_Constants;
+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.error.ErrorContext;
+import org.apache.uima.aae.error.ErrorHandler;
+import org.apache.uima.aae.error.ErrorHandlerBase;
+import org.apache.uima.aae.error.ExpiredMessageException;
+import org.apache.uima.aae.error.InvalidMessageException;
+import org.apache.uima.aae.error.Threshold;
+import org.apache.uima.aae.jmx.ServiceErrors;
+import org.apache.uima.aae.message.AsynchAEMessage;
+import org.apache.uima.aae.monitor.Monitor;
+import org.apache.uima.util.Level;
+
+public class ProcessCasErrorHandler extends ErrorHandlerBase implements ErrorHandler
+{
+	private static final Class CLASS_NAME = ProcessCasErrorHandler.class;
+
+	private Map delegateMap = null;
+	private Object monitor = new Object();
+	
+	public ProcessCasErrorHandler()
+	{
+		delegateMap = new HashMap();
+	}
+	public ProcessCasErrorHandler( Map aDelegateMap )
+	{
+		delegateMap = aDelegateMap;
+	}
+	private Endpoint getDestination( AnalysisEngineController aController, ErrorContext anErrorContext)
+	{
+		Endpoint endpoint = null;
+		String casReferenceId = (String)anErrorContext.get( AsynchAEMessage.CasReference);
+		if ( aController instanceof AggregateAnalysisEngineController )
+		{
+			endpoint = ((AggregateAnalysisEngineController)aController).getMessageOrigin(casReferenceId);
+
+			//	Remove the entry from the Message Origin Map since it is no longer needed. The CAS will be
+			//	dropped as soon as the exception is sent up to the client.
+			if (endpoint != null && aController.isTopLevelComponent())
+			{
+				((AggregateAnalysisEngineController)aController).removeMessageOrigin( casReferenceId);
+			}
+		}
+		else if ( anErrorContext.containsKey(AsynchAEMessage.Endpoint))
+		{
+			endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+		}
+		return endpoint;
+	}
+	private boolean isDisabled( AggregateAnalysisEngineController aController, String aDelegateKey )
+	{
+		return aController.isDelegateDisabled(aDelegateKey);
+	}
+	
+	private boolean ignoreError(Throwable t, ErrorContext anErrorContext, boolean isClient )
+	{
+		//	Ignores Invalid Messages, expired messages and ConnectExceptions IFF a connection
+		//	to a client cannot be established. Clients can be killed in the middle of a run
+		//	and that should not be an error.
+		if ( t instanceof InvalidMessageException || 
+			 t instanceof ExpiredMessageException ||	
+			 ( isClient && t.getCause() != null && t.getCause() instanceof ConnectException ) 	
+		)
+		{
+			return true;
+		}
+		return false;
+	}
+	private void sendExceptionToClient(Throwable t, String aCasReferenceId, Endpoint anEndpoint, AnalysisEngineController aController) throws Exception 
+	{
+		//	Notify the parent of the exception
+		if ( anEndpoint != null && aCasReferenceId != null && !anEndpoint.isCasMultiplier())
+		{
+			try
+			{
+				aController.getOutputChannel().sendReply(t, aCasReferenceId, anEndpoint, AsynchAEMessage.Process);
+				//aController.dropStats(aCasReferenceId, anEndpoint.getEndpoint());
+			}
+			catch( Exception e)
+			{
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "sendExceptionToParent", 
+						UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e);
+			}
+		}
+
+	}
+
+	private boolean isClient( Endpoint anEndpoint, AnalysisEngineController aController, String aCasReferenceId )
+	{
+		Endpoint clientEndpoint = null;
+		
+		if (aController.isTopLevelComponent())
+		{
+			clientEndpoint = aController.
+				getInProcessCache().
+					getEndpoint(null, aCasReferenceId);
+		}
+		else  if ( aController instanceof AggregateAnalysisEngineController )
+		{
+			clientEndpoint = 
+				((AggregateAnalysisEngineController)aController).
+					getMessageOrigin(aCasReferenceId);
+		}
+		if (anEndpoint != null && clientEndpoint != null )
+		{
+			return anEndpoint.getEndpoint().equalsIgnoreCase(clientEndpoint.getEndpoint());
+		}
+		return false;
+	}
+	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		
+		if ( !isHandlerForError(anErrorContext, AsynchAEMessage.Process))
+		{
+			return false;
+		}
+		
+		UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+				UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", t);
+
+		
+		String casReferenceId = null;
+		if ( anErrorContext.containsKey(AsynchAEMessage.CasReference)) 
+		{
+			casReferenceId = (String) anErrorContext.get(AsynchAEMessage.CasReference);
+		}
+		else
+		{
+			return true; // No CAS, nothing to do
+		}
+		boolean isRequest = false;
+		
+		if ( anErrorContext.containsKey(AsynchAEMessage.MessageType)) 
+		{
+			int msgType = ((Integer)anErrorContext.get(AsynchAEMessage.MessageType)).intValue();
+			if (msgType == AsynchAEMessage.Request  )
+			{
+				isRequest = true;
+			}
+		}
+
+		//	Determine if the exception occured while sending a reply to the client
+		boolean isEndpointTheClient = 
+			isClient( (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint), aController, casReferenceId);
+		
+		
+		
+		if ( ignoreError( t, anErrorContext, isEndpointTheClient ))
+		{
+    		UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(), "handleError", 
+    				UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_ignore_error__INFO", new Object[] { aController.getComponentName(), t.getClass().getName()});
+		
+//			Endpoint endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+//			if ( endpoint != null && endpoint.getReplyToEndpoint() != null &&
+//				 t.getCause() != null && t.getCause() instanceof ConnectException ) 	
+//			{
+//	    		//	Special case: disable a listener on queue that no longer exists
+//				aController.getUimaEEAdminContext().stopListener(endpoint.getReplyToEndpoint());
+//			}
+    		return true;   // handled here. This message will not processed
+		}
+
+		String key = ""; 
+		Threshold threshold = null;
+		boolean delegateDisabled = false;
+		//                       R E T R Y
+		//	Do retry first if this an Aggregate Controller
+		if ( !isEndpointTheClient && aController instanceof AggregateAnalysisEngineController )
+		{
+			Endpoint endpoint = null;
+			
+			if ( anErrorContext.get(AsynchAEMessage.Endpoint) != null )
+			{
+				endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+			}
+			threshold = super.getThreshold(endpoint, delegateMap, aController);
+			if ( endpoint != null )
+			{
+		    	key = ((AggregateAnalysisEngineController)aController).lookUpDelegateKey(endpoint.getEndpoint());
+		    	delegateDisabled = ((AggregateAnalysisEngineController)aController).isDelegateDisabled(key);
+		    	if ( threshold != null && threshold.getMaxRetries() > 0 && !delegateDisabled)
+		    	{
+		    		//	If max retry count is not reached, send the last command again and return true
+		    		if ( super.retryLastCommand(AsynchAEMessage.Process, endpoint, aController, key, threshold, anErrorContext) )
+			    	{
+			    		UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, getClass().getName(), "handleError", 
+			    				UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_retry_cas__FINE", new Object[] { aController.getComponentName(), key, casReferenceId });
+				    	return true;   // Command has been retried. Done here.
+			    	}
+		    	}
+		    	else if ( threshold == null )
+		    	{
+					UIMAFramework.getLogger(CLASS_NAME).logrb(Level.CONFIG, getClass().getName(), "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_no_threshold_for_endpoint__CONFIG", new Object[] { aController.getComponentName(), "Process",  key });
+		    	}
+			}
+			else
+			{
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(), "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_no_endpoint_provided__INFO", new Object[] { aController.getComponentName() });
+			}
+		}
+		else
+		{
+	    	if ( delegateMap != null && delegateMap.containsKey(key))
+	    	{
+	        	threshold = (Threshold)delegateMap.get(key);
+	    	}
+		}
+
+		
+		if ( key != null && key.trim().length() > 0)
+		{
+			//	Retries either exceeded or not configured for retry
+			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, getClass().getName(), "handleError", 
+					UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_cas_retries_exceeded__FINE", new Object[] { aController.getComponentName(), key, casReferenceId });
+		}
+
+		//	Dont increment errors for destinations that are clients of this service.
+		if ( !aController.isStopped() && (isRequest || !isEndpointTheClient ) )
+		{
+			synchronized( monitor )
+			{
+				//	Dont increment errors for delegates that have been already disabled 
+				if ( !delegateDisabled )
+				{
+					//	Process Error Count is only incremented after retries are done. 
+					super.incrementStatistic(aController.getMonitor(), key, Monitor.ProcessErrorCount);
+					super.incrementStatistic(aController.getMonitor(), key, Monitor.TotalProcessErrorCount);
+					aController.getServiceErrors().incrementProcessErrors();
+					if ( aController instanceof AggregateAnalysisEngineController && anErrorContext.get(AsynchAEMessage.Endpoint) != null )
+					{
+						Endpoint endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+						if ( endpoint.isRemote())
+						{
+							ServiceErrors serviceErrs = 
+								((AggregateAnalysisEngineController)aController).getDelegateServiceErrors(key);
+//							ServiceErrors serviceErrs = ((AggregateAnalysisEngineController)aController).getServiceErrors(key);
+							if (serviceErrs != null )
+							{
+								serviceErrs.incrementProcessErrors();
+							}
+						}
+					}
+					if (threshold != null && threshold.getThreshold() > 0 && super.exceedsThresholdWithinWindow(aController.getMonitor(), Monitor.ProcessErrorCount, key, threshold) )
+					{
+						UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(), "handleError", 
+								UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_process_cas_exceeded_threshold__INFO", new Object[] { aController.getComponentName(), key, casReferenceId, threshold.getThreshold(), threshold.getAction() });
+						aController.takeAction(threshold.getAction(), key, anErrorContext);
+					}
+				}
+				else
+				{
+					UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(), "handleError", 
+							UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_delegate_already_disabled__INFO", new Object[] { aController.getComponentName(), key, casReferenceId });
+				}
+			}
+			
+		}
+		else
+		{
+			Endpoint endpt = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+			if ( endpt != null )
+			{
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, getClass().getName(), "handleError", 
+						UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception_while_sending_reply_to_client__FINE", new Object[] { aController.getComponentName(), endpt.getEndpoint(), casReferenceId });
+			}
+		}
+		
+		int totalNumberOfParallelDelegatesProcessingCas = 1; // default
+		CacheEntry cacheEntry = null;
+		try
+		{
+			cacheEntry = aController.getInProcessCache().getCacheEntryForCAS(casReferenceId);
+			if ( cacheEntry != null )
+			{
+				totalNumberOfParallelDelegatesProcessingCas = cacheEntry.getNumberOfParallelDelegates();
+			}
+
+		}
+		catch( Exception e) {}
+		//	Determine where to send the message
+		Endpoint endpoint = getDestination(aController, anErrorContext);
+/*
+		//	Notify the parent of the exception
+		if ( endpoint != null && casReferenceId != null && !endpoint.isCasMultiplier())
+		{
+			try
+			{
+				aController.getOutputChannel().sendReply(t, casReferenceId, endpoint, AsynchAEMessage.Process);
+				aController.dropStats(casReferenceId, endpoint.getEndpoint());
+			}
+			catch( Exception e)
+			{
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+						UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e);
+			}
+		}
+*/		
+		//	If the error occured during parallel step, treat the exception as response from the delegate
+		//	When all responses from delegates are accounted for we allow the CAS to move on to the next
+		//	step in the flow
+		if ( cacheEntry != null && totalNumberOfParallelDelegatesProcessingCas > 1 && ( cacheEntry.howManyDelegatesResponded() < totalNumberOfParallelDelegatesProcessingCas))
+		{
+			synchronized( cacheEntry )
+			{
+				cacheEntry.incrementHowManyDelegatesResponded();
+			}
+		}
+
+		if (aController instanceof AggregateAnalysisEngineController)
+		{
+			if ( threshold != null && continueOnError(key, threshold, casReferenceId, t, aController))
+			{
+				if (totalNumberOfParallelDelegatesProcessingCas == 1 || ( cacheEntry.howManyDelegatesResponded() == totalNumberOfParallelDelegatesProcessingCas) )
+				{
+					aController.process(aController.getInProcessCache().getCasByReference(casReferenceId), casReferenceId);
+				}
+				//	Dont send request to release the CAS to remote CM. This will happen in the final step. We are continuing
+				//	despite the error here.
+				return true;
+			}
+			else
+			{
+				try
+				{
+					sendExceptionToClient( t, casReferenceId, endpoint, aController );
+				}
+				catch( Exception e) 
+				{
+					e.printStackTrace();
+					UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+							UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e);
+				}
+			}
+			
+			//	Now check if the CAS origin is a remote CAS Multiplier. If so, send a request to release the CAS. Remote
+			//	CAS Multipliers must be "gated" to prevent flooding the Aggregate queue with too many CASes. There is
+			//	an explicit protocol between an Aggregate AS and its CM. The Aggregate AS sends a request to free a CAS
+			//	in the CM whenever the Aggregate has capacity to process more CASes. Here we are recovering from an
+			//	an error but we still need to send a request to free the CAS in the remote CM to prevent a hang in the CM
+			try
+			{
+				//	First check if the current controller is the one that first produced the CAS
+				if ( cacheEntry != null && aController.getName().equalsIgnoreCase(cacheEntry.getCasProducerAggregateName() ) )
+				{
+					//	Fetch the key of the Cas Multiplier
+					String casProducerKey = cacheEntry.getCasMultiplierKey();
+					if ( casProducerKey != null )
+					{
+						//	Create an endpoint object from the key. This object will be cloned from the Endpoint object
+						//	defined in the spring configuration file.
+						Endpoint cmEndpoint = ((AggregateAnalysisEngineController)aController).lookUpEndpoint(casProducerKey, true);
+						
+						//	CAS reference id will be different if the CAS originated from a remote Cas Multiplier. 
+						//String cmCasReferenceId = cacheEntry.getRemoteCMCasReferenceId();
+						//	If the Cas Multiplier is remote send a request to free a CAS with a given cas id
+						if ( cmEndpoint != null && cmEndpoint.isCasMultiplier() && cmEndpoint.isRemote() )
+						{
+							cmEndpoint.setEndpoint(cmEndpoint.getEndpoint()+"__CasSync");
+							aController.getOutputChannel().sendRequest(AsynchAEMessage.ReleaseCAS, cmEndpoint);
+						}
+					}
+				}
+			}
+			catch( Exception e) 
+			{
+				e.printStackTrace();
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+						UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e);
+			}
+		}
+		else  // Primitive Controller
+		{
+			try
+			{
+				sendExceptionToClient( t, casReferenceId, endpoint, aController );
+			}
+			catch( Exception e) 
+			{
+				e.printStackTrace();
+				UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+						UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e);
+			}
+		}
+
+		try
+		{
+			//	Only top level component can Drop the CAS. 
+			if ( aController.isTopLevelComponent() )
+			{
+				aController.takeAction( ErrorHandler.DROPCAS, key, anErrorContext);
+			}			
+			if ( casReferenceId != null && aController instanceof AggregateAnalysisEngineController )
+			{
+				//	Cleanup state information from local caches
+				((AggregateAnalysisEngineController)aController).dropFlow(casReferenceId, true);
+				((AggregateAnalysisEngineController)aController).removeMessageOrigin(casReferenceId);
+			}
+
+			aController.dropStats(casReferenceId, aController.getName());
+		}
+		catch( Exception e)
+		{
+			e.printStackTrace();
+			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), "handleError", 
+					UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_exception__WARNING", e);
+		}
+
+		
+		return true;
+	}
+	private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/UnknownDestinationHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/UnknownDestinationHandler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/UnknownDestinationHandler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/error/handler/UnknownDestinationHandler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,47 @@
+package org.apache.uima.aae.error.handler;
+
+import java.util.Map;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.aae.UIMAEE_Constants;
+import org.apache.uima.aae.controller.AnalysisEngineController;
+import org.apache.uima.aae.error.ErrorContext;
+import org.apache.uima.aae.error.ErrorHandler;
+import org.apache.uima.aae.error.ErrorHandlerBase;
+import org.apache.uima.aae.error.ExpiredMessageException;
+import org.apache.uima.aae.error.UnknownDestinationException;
+import org.apache.uima.aae.message.AsynchAEMessage;
+import org.apache.uima.util.Level;
+
+public class UnknownDestinationHandler extends ErrorHandlerBase implements ErrorHandler
+{
+private static final Class CLASS_NAME = UnknownDestinationHandler.class;
+
+	public UnknownDestinationHandler(Map anEndpointThreasholdMap)
+	{
+		super(anEndpointThreasholdMap);
+	}
+
+	public UnknownDestinationHandler()
+	{
+	}
+
+	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
+	{
+		if (t instanceof UnknownDestinationException)
+		{
+			String casReferenceId = null;
+			if (anErrorContext.containsKey(AsynchAEMessage.CasReference))
+			{
+				casReferenceId = (String) anErrorContext.get(AsynchAEMessage.CasReference);
+			}
+			UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_handling_bad_destination__INFO", new Object[] { null, casReferenceId });
+
+			return true;
+		}
+		return false;
+	}
+
+
+private static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}

Added: incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/handler/Handler.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/handler/Handler.java?rev=610003&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/handler/Handler.java (added)
+++ incubator/uima/sandbox/trunk/uima-ee/uimaj-ee-core/src/main/java/org/apache/uima/aae/handler/Handler.java Tue Jan  8 06:38:38 2008
@@ -0,0 +1,25 @@
+package org.apache.uima.aae.handler;
+
+import org.apache.uima.aae.error.AsynchAEException;
+import org.apache.uima.aae.message.MessageContext;
+import org.apache.uima.cas.CAS;
+
+public interface Handler
+{
+	public void setDelegate(Handler aHandler);
+	public Handler getDelegate();
+	public void removeDelegate(String aHandlerName);
+	public void resequenceDelegateHandler( String aHandlerName, int aNewPositionInHandlerChain);
+	public void delegate( MessageContext aMessageContext) throws AsynchAEException;
+	public void invokeProcess(CAS aCAS, String casReferenceId1, String aCasReferenceId2, MessageContext aMessageContext, String aNewCasProducedBy) throws AsynchAEException;
+	public boolean isHandlerForMessage( MessageContext aMessageContext, int anExpectedMessageType, int anExpectedCommand ) throws AsynchAEException;
+
+	public void handle(Object anObjectToHandle) throws AsynchAEException;
+
+	//Deprecate below handlers
+	public void handle( Object anObjectToHandle, String expectedOutputType ) throws AsynchAEException;
+	public boolean hasDelegateHandler();
+	public String getName();
+
+	static final String copyright = com.ibm.uima.copyright.Copyright.COPYRIGHT;
+}