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 2016/09/30 15:41:32 UTC

svn commit: r1762927 - in /uima/uima-as/trunk: uima-as-docbooks/src/docbook/async.monitoring.and.tuning.xml uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java

Author: eae
Date: Fri Sep 30 15:41:32 2016
New Revision: 1762927

URL: http://svn.apache.org/viewvc?rev=1762927&view=rev
Log:
UIMA-5120 make caslogging more threadsafe; document dynamic enable/disable

Modified:
    uima/uima-as/trunk/uima-as-docbooks/src/docbook/async.monitoring.and.tuning.xml
    uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java

Modified: uima/uima-as/trunk/uima-as-docbooks/src/docbook/async.monitoring.and.tuning.xml
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uima-as-docbooks/src/docbook/async.monitoring.and.tuning.xml?rev=1762927&r1=1762926&r2=1762927&view=diff
==============================================================================
--- uima/uima-as/trunk/uima-as-docbooks/src/docbook/async.monitoring.and.tuning.xml (original)
+++ uima/uima-as/trunk/uima-as-docbooks/src/docbook/async.monitoring.and.tuning.xml Fri Sep 30 15:41:32 2016
@@ -1095,8 +1095,26 @@ under the License.
 	      <title>CAS Logging</title>
 	      <para>Within a UIMA AS asynchronous aggregate, CASes can be saved before sending to any local or remote 
 	        	delegate and later used to reproduce a problem in a simple unit testing environment.
-	        	Logging is currently not supported for delegates of a UIMA AS synchronous aggregate.
-	        	Control of CAS logging is done via Java properties:
+	        	Logging is currently not supported for delegates of a UIMA aggregate deployed synchronously.  
+	        	</para>
+
+	      <para>CASes are stored
+	        	in XmiCas format in a separate directory for each delegate with logging enabled. 
+	        	Along with the CAS files in each directory is a file "typesystem.xml" containing the complete CAS type system.
+	        	A delegate's directory name is the full delegate context with '/' chars converted to '-'.
+	        	If not specified, the base CAS logging directory is the process current directory.
+	      		By default the name of each CAS file is the time in milliseconds after CAS logging begins
+	            for a delegate. If a string exists in the CAS that should be used as the file name,
+	            it can be specified by {type, feature} found in a specific view.
+	      </para>
+
+	      <para>A list of delegates to enable for CAS logging can be specified as a Java property.
+	      		Logging can also be enabled/disabled dynamically via JMX. CAS logging control is
+	      		enabled in the "Annotator_Service Info" bean for each asynchonous delegate. 
+	      </para>
+
+	      <para>  	
+	        	Java properties used for CAS logging:
 	      </para>
 	        <informaltable frame="all">
 	          <tgroup cols="2" colsep="1" rowsep="1">

Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java?rev=1762927&r1=1762926&r2=1762927&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java (original)
+++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java Fri Sep 30 15:41:32 2016
@@ -1383,36 +1383,42 @@ public class AggregateAnalysisEngineCont
    *   
    */
   private void logCasForEndpoint(String analysisEngineKey, CAS cas) throws Exception {
-    if (null == enableCasLogMap.get(analysisEngineKey)) {
-      String dir = analysisEngineKey;
-   	  if ( getUimaContext() != null ) {  // getUimaContext() = null for TLA
-  		  // Get this aggregate's fully rooted context
-          String ctxName = ((UimaContextAdmin)this.getUimaContext()).getQualifiedContextName();
-          // ctxName contains trailing '/'
-          dir = ctxName + analysisEngineKey;
-      } 
-      dir = dir.replace('/', '-');
-      setCasLoggingDirectory(analysisEngineKey, dir);
-    }
-    if (!((Boolean)enableCasLogMap.get(analysisEngineKey))) {
-      // create dir and serialize typesystem
-      new File((String)casLogDirMap.get(analysisEngineKey)).mkdir();
-      TypeSystemDescription tsd = TypeSystemUtil.typeSystem2TypeSystemDescription(cas.getTypeSystem());
-      File tsd2xml = new File(((String)casLogDirMap.get(analysisEngineKey))+"/typesystem.xml");
-      FileOutputStream os = new FileOutputStream(tsd2xml);
-      tsd.toXML(os);
-      os.close();
-      enableCasLogMap.put(analysisEngineKey, true);
-      if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
-        String logdir = (String)casLogDirMap.get(analysisEngineKey);
-        String[] dirs = logdir.split("/");
-        String comp = dirs[dirs.length-1];
-        comp = comp.replace('-', '/');
-        UIMAFramework.getLogger(CLASS_NAME).log(Level.INFO, "UIMA_CASLOG: CAS logging started for "+ 
-                comp + " to " + logdir);
+    synchronized (enableCasLogMap) {
+      // synchronize the following two blocks because there may be multiple threads of an analysisEngine
+      if (null == enableCasLogMap.get(analysisEngineKey)) {
+        String dir = analysisEngineKey;
+        if ( getUimaContext() != null ) {  // getUimaContext() = null for TLA
+          // Get this aggregate's fully rooted context
+            String ctxName = ((UimaContextAdmin)this.getUimaContext()).getQualifiedContextName();
+            // ctxName contains trailing '/'
+            dir = ctxName + analysisEngineKey;
+            if (dir.startsWith("/")) {
+              dir = dir.substring(1);
+            }
+        } 
+        dir = dir.replace('/', '-');
+        setCasLoggingDirectory(analysisEngineKey, dir);
+      }
+      if (!((Boolean)enableCasLogMap.get(analysisEngineKey))) {
+        // create dir and serialize typesystem
+        new File((String)casLogDirMap.get(analysisEngineKey)).mkdir();
+        TypeSystemDescription tsd = TypeSystemUtil.typeSystem2TypeSystemDescription(cas.getTypeSystem());
+        File tsd2xml = new File(((String)casLogDirMap.get(analysisEngineKey))+"/typesystem.xml");
+        FileOutputStream os = new FileOutputStream(tsd2xml);
+        tsd.toXML(os);
+        os.close();
+        enableCasLogMap.put(analysisEngineKey, true);
+        if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
+          String logdir = (String)casLogDirMap.get(analysisEngineKey);
+          String[] dirs = logdir.split("/");
+          String comp = dirs[dirs.length-1];
+          comp = comp.replace('-', '/');
+          UIMAFramework.getLogger(CLASS_NAME).log(Level.INFO, "UIMA_CASLOG: CAS logging started for "+ 
+                  comp + " to " + logdir);
+        }
+        // set initialization time to use for CasLogging
+        initializationTime=System.nanoTime();
       }
-      // set initialization time to use for CasLogging
-      initializationTime=System.nanoTime();
     }
     // create XmiCas file name
     Long now = Long.valueOf((System.nanoTime()-initializationTime)/1000);