Author: cwiklik Date: Thu Apr 12 19:31:07 2012 New Revision: 1325457 URL: http://svn.apache.org/viewvc?rev=1325457&view=rev Log: UIMA-2388 support self-destruct (System.exit()) when error threshold is exceeded and action=terminate
Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java uima/uima-as/trunk/uimaj-as-core/src/main/resources/uimaee_messages.properties Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java?rev=1325457&r1=1325456&r2=1325457&view=diff ============================================================================== --- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java (original) +++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java Thu Apr 12 19:31:07 2012 @@ -1135,7 +1135,7 @@ public abstract class BaseAnalysisEngine return replyTime; } - protected void handleAction(String anAction, String anEndpoint, ErrorContext anErrorContext) + protected void handleAction(String anAction, String anEndpoint, final ErrorContext anErrorContext) throws Exception { String casReferenceId = null; @@ -1144,6 +1144,67 @@ public abstract class BaseAnalysisEngine } if (ErrorHandler.TERMINATE.equalsIgnoreCase(anAction)) { + if ( casReferenceId != null ) { + CasStateEntry stateEntry = null; + String parentCasReferenceId = null; + try { + stateEntry = getLocalCache().lookupEntry(casReferenceId); + if (stateEntry != null && stateEntry.isSubordinate()) { + CasStateEntry topParentEntry = getLocalCache().getTopCasAncestor(casReferenceId); + parentCasReferenceId = topParentEntry.getCasReferenceId(); + } + if (!isStopped()) { + Endpoint endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint); + if ( endpoint != null ) { + getOutputChannel().sendReply((Throwable) anErrorContext.get(ErrorContext.THROWABLE_ERROR), + casReferenceId, parentCasReferenceId, + endpoint, AsynchAEMessage.Process); + } + } + } catch (Exception e) { + } + + } + // Extended tests cant be killed, so skip this if dontKill is defined + // in System properties. + if ( System.getProperty("dontKill") == null) { + // The UIMA AS service error handling says to terminate. Try to terminate + // cleanly. If the process is not down after 40 secs, take it down via + // System.exit. + Thread reaperThread = new Thread( new Runnable() { + public void run() { + System.out.println("++++++++++++++++++++++++ Starting Reaper thread"); + Object sleepLock = new Object(); + try { + synchronized( sleepLock ) { + sleepLock.wait(40000); // allow up to 40 sec minute for a clean shutdown. + } + } catch( Exception exx) { + exx.printStackTrace(); + } + + // ********************************************************************** + // ********************************************************************** + // ********************************************************************** + // ********************************************************************** + // ********************************************************************** + // Per discussion with Eddie on 4/11/12, exit process via System.exit() + UIMAFramework.getLogger(CLASS_NAME).logrb(Level.SEVERE, CLASS_NAME.getName(), + "handleAction", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, + "UIMAEE_killing_process__SEVERE", new Object[] { getComponentName() }); + System.exit(1); + // ********************************************************************** + // ********************************************************************** + // ********************************************************************** + // ********************************************************************** + // ********************************************************************** + } + } + ); + reaperThread.start(); + + } + // Propagate terminate event to the top controller and begin shutdown of this service along // with all collocated delegates (if any) if (anErrorContext != null && anErrorContext.containsKey(ErrorContext.THROWABLE_ERROR) @@ -1153,6 +1214,7 @@ public abstract class BaseAnalysisEngine } else { terminate(); } + } else if (ErrorHandler.DISABLE.equalsIgnoreCase(anAction)) { if (anEndpoint != null) { Modified: uima/uima-as/trunk/uimaj-as-core/src/main/resources/uimaee_messages.properties URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/resources/uimaee_messages.properties?rev=1325457&r1=1325456&r2=1325457&view=diff ============================================================================== --- uima/uima-as/trunk/uimaj-as-core/src/main/resources/uimaee_messages.properties (original) +++ uima/uima-as/trunk/uimaj-as-core/src/main/resources/uimaee_messages.properties Thu Apr 12 19:31:07 2012 @@ -55,7 +55,7 @@ UIMAEE_terminating_service__INFO = Servi UIMAEE_primitive_ctrl_init_info__CONFIG - Initializing Async Primitive Service. Number of Worker Threads: {0} UIMAEE_terminating_thread__INFO = Terminatig Worker Thread in Async Primitive Service: {0} UIMAEE_worker_threads_done__INFO = All Worker Threads Terminated in Async Primitive Service: {0} -UIMAEE_killing_process__SEVERE = Service {0} Killed With System.exit(0) +UIMAEE_killing_process__SEVERE = !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\t<<<<<<<<<<<<<< Service {0} Killed With System.exit(0) >>>>>>>>>>>>>>>>>>>>>>>>>\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! UIMAEE_rceived_work__FINE = Worker Thread: {0} Received Work. Cas ReferenceId: {1} UIMAEE_cas_notin_cache__WARNING = Worker Thread: {0} Cas ReferenceId: {1} Not In Cache. UIMAEE_produced_new_cas__FINE = Worker Thread: {0} Controller: {1} Produced New Cas: {2} From Input Cas: {3}