You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2019/05/22 15:51:17 UTC

svn commit: r1859733 - in /uima/uima-ducc/trunk: uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/processor/uima/ uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/ uima-ducc-user/src/main/java/org/apache/uima/ducc/user/c...

Author: cwiklik
Date: Wed May 22 15:51:17 2019
New Revision: 1859733

URL: http://svn.apache.org/viewvc?rev=1859733&view=rev
Log:
UIMA-6040 modified uima JP to use classpath separation. User code runs in System classloader whereas ducc runs fenced in a custom classloader

Added:
    uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/processor/uima/UimaDelegator.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/BasicUimaMetricsGenerator.java   (with props)
    uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/UimaWrapper.java   (with props)

Added: uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/processor/uima/UimaDelegator.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/processor/uima/UimaDelegator.java?rev=1859733&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/processor/uima/UimaDelegator.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/processor/uima/UimaDelegator.java Wed May 22 15:51:17 2019
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ducc.ps.service.processor.uima;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Properties;
+
+import javax.xml.parsers.FactoryConfigurationError;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.impl.XmiCasDeserializer;
+import org.apache.uima.ducc.ps.service.processor.uima.utils.PerformanceMetrics;
+import org.apache.uima.ducc.ps.service.processor.uima.utils.UimaMetricsGenerator;
+import org.apache.uima.internal.util.XMLUtils;
+import org.apache.uima.resource.Resource;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceManager;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.util.CasPool;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+public class UimaDelegator {
+	private CasPool casPool = null;
+	private ResourceManager rm = UIMAFramework.newDefaultResourceManager();
+	private static Object platformMBeanServer;
+	private boolean deserializeFromXMI;
+
+	static {
+		// try to get platform MBean Server (Java 1.5 only)
+		try {
+			Class<?> managementFactory = Class.forName("java.lang.management.ManagementFactory");
+			Method getPlatformMBeanServer = managementFactory.getMethod("getPlatformMBeanServer", new Class[0]);
+			platformMBeanServer = getPlatformMBeanServer.invoke(null, (Object[]) null);
+		} catch (Exception e) {
+			platformMBeanServer = null;
+		}
+	}
+
+	public void initialize(ResourceSpecifier rSpecifier, int scaleout, boolean deserialize,
+			ThreadLocal<AnalysisEngine> threadLocal) throws Exception {
+
+		HashMap<String, Object> paramsMap = new HashMap<>();
+		paramsMap.put(Resource.PARAM_RESOURCE_MANAGER, rm);
+		paramsMap.put(AnalysisEngine.PARAM_MBEAN_SERVER, platformMBeanServer);
+		deserializeFromXMI = deserialize;
+
+		AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(rSpecifier, paramsMap);
+		// pin AE instance to this thread
+		threadLocal.set(ae);
+
+		synchronized (UimaDelegator.class) {
+			if (casPool == null) {
+				initializeCasPool(ae.getAnalysisEngineMetaData(), scaleout);
+			}
+		}
+	}
+
+	public List<PerformanceMetrics> process(String serializedTask, ThreadLocal<AnalysisEngine> threadLocal)
+			throws Exception {
+		List<PerformanceMetrics> delta = null;
+		CAS cas = casPool.getCas();
+		try {
+			if (deserializeFromXMI) {
+				deserializeCasFromXmi(serializedTask, cas);
+			} else {
+				cas.setDocumentText(serializedTask);
+				cas.setDocumentLanguage("en");
+
+			}
+
+			// check out AE instance pinned to this thread
+			AnalysisEngine ae = threadLocal.get();
+
+			List<PerformanceMetrics> preProcessMetrics = UimaMetricsGenerator.get(ae);
+			ae.process(cas);
+			List<PerformanceMetrics> postProcessMetrics = UimaMetricsGenerator.get(ae);
+			delta = UimaMetricsGenerator.getDelta(postProcessMetrics, preProcessMetrics);
+		} finally {
+			if (cas != null) {
+				casPool.releaseCas(cas);
+			}
+		}
+		return delta;
+
+	}
+
+	public void deserializeCasFromXmi(String anXmlStr, CAS aCAS)
+			throws FactoryConfigurationError, SAXException, IOException {
+
+		XMLReader xmlReader = XMLUtils.createXMLReader();
+		Reader reader = new StringReader(anXmlStr);
+		XmiCasDeserializer deser = new XmiCasDeserializer(aCAS.getTypeSystem());
+		ContentHandler handler = deser.getXmiCasHandler(aCAS);
+		xmlReader.setContentHandler(handler);
+		xmlReader.parse(new InputSource(reader));
+	}
+
+	public void stop(ThreadLocal<AnalysisEngine> threadLocal) {
+		AnalysisEngine ae = threadLocal.get();
+		if (ae != null) {
+			ae.destroy();
+		}
+	}
+
+	private void initializeCasPool(AnalysisEngineMetaData analysisEngineMetadata, int scaleout)
+			throws ResourceInitializationException {
+		Properties props = new Properties();
+		props.setProperty(UIMAFramework.CAS_INITIAL_HEAP_SIZE, "1000");
+		casPool = new CasPool(scaleout, analysisEngineMetadata, rm);
+	}
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-pullservice/src/main/java/org/apache/uima/ducc/ps/service/processor/uima/UimaDelegator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/BasicUimaMetricsGenerator.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/BasicUimaMetricsGenerator.java?rev=1859733&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/BasicUimaMetricsGenerator.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/BasicUimaMetricsGenerator.java Wed May 22 15:51:17 2019
@@ -0,0 +1,262 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.user.common;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.AnalysisEngineManagement;
+import org.apache.uima.util.Level;
+import org.apache.uima.util.Logger;
+
+public class BasicUimaMetricsGenerator {
+	public static final String AE_NAME = "AeName";
+	public static final String AE_CONTEXT = "AeContext";
+	public static final String AE_ANALYSIS_TIME = "AeAnalysisTime";
+	public static final String AE_CAS_PROCESSED = "AeProcessedCasCount";
+
+	private BasicUimaMetricsGenerator() {
+		
+	}
+	public static void getLeafManagementObjects(AnalysisEngineManagement aem, List<Properties> result) {
+		getLeafManagementObjects(aem, result, "");
+	}
+
+	public static List<Properties> get(AnalysisEngine ae) throws Exception {
+		List<Properties> analysisManagementObjects = new ArrayList<>();
+		synchronized (BasicUimaMetricsGenerator.class) {
+			// Fetch AE's management information that includes per component
+			// performance stats
+			// These stats are internally maintained in a Map. If the AE is an
+			// aggregate
+			// the Map will contain AnalysisEngineManagement instance for each AE.
+			AnalysisEngineManagement aem = ae.getManagementInterface();
+			if (aem.getComponents().size() > 0) {
+				// Flatten the hierarchy by recursively (if this AE is an aggregate)
+				// extracting
+				// primitive AE's AnalysisEngineManagement instance and placing it
+				// in
+				// afterAnalysisManagementObjects List.
+				getLeafManagementObjects(aem, analysisManagementObjects);
+			} else {
+				String path = produceUniqueName(aem);
+				analysisManagementObjects.add(deepCopyMetrics(aem, path));
+
+			}
+
+		}
+		return analysisManagementObjects;
+	}
+
+	public static List<Properties> get(AnalysisEngineManagement aem) throws Exception {
+		List<Properties> analysisManagementObjects = new ArrayList<>();
+		synchronized (BasicUimaMetricsGenerator.class) {
+			// Fetch AE's management information that includes per component
+			// performance stats
+			// These stats are internally maintained in a Map. If the AE is an
+			// aggregate
+			// the Map will contain AnalysisEngineManagement instance for each AE.
+			// AnalysisEngineManagement aem = ae.getManagementInterface();
+			if (aem.getComponents().size() > 0) {
+				// Flatten the hierarchy by recursively (if this AE is an aggregate)
+				// extracting
+				// primitive AE's AnalysisEngineManagement instance and placing it
+				// in
+				// afterAnalysisManagementObjects List.
+				getLeafManagementObjects(aem, analysisManagementObjects);
+			} else {
+				String path = produceUniqueName(aem);
+				analysisManagementObjects.add(deepCopyMetrics(aem, path));
+
+			}
+
+		}
+		return analysisManagementObjects;
+	}
+
+	/**
+	 * Recursively
+	 * 
+	 * @param aem
+	 * @param result
+	 * @param uimaFullyQualifiedAEContext
+	 */
+	private static void getLeafManagementObjects(AnalysisEngineManagement aem, List<Properties> result,
+			String uimaFullyQualifiedAEContext) {
+		if (aem.getComponents().isEmpty()) {
+			// skip Flow Controller
+			if (!aem.getName().equals("Fixed Flow Controller")) {
+				// is this primitive AE delegate in an aggregate. If so the
+				// mbean unique name will have "p0=" string. An examples mbean
+				// name looks like this:
+				// org.apache.uima:type=ee.jms.services,s=Top Level Aggregate
+				// TAE Uima EE Service,p0=Top Level Aggregate TAE
+				// Components,p1=SecondLevelAggregateCM
+				// Components,p2=ThirdLevelAggregateCM
+				// Components,name=Multiplier1
+				if (aem.getUniqueMBeanName().indexOf("p0=") > -1) {
+					int p1indx = aem.getUniqueMBeanName().indexOf("p1=");
+					if (p1indx > -1) {
+						String tmp = aem.getUniqueMBeanName().substring(p1indx);
+						String[] parts = tmp.split(",");
+						for (String part : parts) {
+							if (part.startsWith("name=")) {
+								uimaFullyQualifiedAEContext += "/" + part.substring(5);
+								break;
+							}
+						}
+					} else {
+						uimaFullyQualifiedAEContext = "";
+					}
+
+				}
+				result.add(deepCopyMetrics(aem, uimaFullyQualifiedAEContext));
+			}
+		} else {
+			for (AnalysisEngineManagement child : (Iterable<AnalysisEngineManagement>) aem.getComponents().values()) {
+				getLeafManagementObjects(child, result, produceUniqueName(aem));
+			}
+		}
+	}
+
+	private static String produceUniqueName(AnalysisEngineManagement aem) {
+		String[] parts = aem.getUniqueMBeanName().split(",");
+		StringBuffer sb = new StringBuffer();
+		for (String part : parts) {
+			int pos;
+			if ((pos = part.indexOf("=")) > -1 && part.startsWith("p")) {
+				String n = part.substring(pos + 1, part.indexOf(" Components"));
+				if (part.startsWith("p0=") && n.indexOf(" ") > -1) {
+					String indx = n.substring(n.lastIndexOf(" "));
+					if (indx != null) {
+						int instanceNumber = -1;
+						try {
+							instanceNumber = Integer.parseInt(indx.trim());
+							sb.append(instanceNumber).append(" Components ");
+							n = n.substring(0, n.lastIndexOf(" "));
+						} catch (NumberFormatException nfe) {
+						}
+					}
+				}
+				sb.append("/").append(n.trim());
+			} else if (part.trim().startsWith("name=") || part.trim().startsWith("org.apache.uima:name=")) {
+				sb.append("/").append(part.substring(part.trim().indexOf("=") + 1));
+			}
+		}
+		return sb.toString();
+	}
+
+	private static Properties deepCopyMetrics(AnalysisEngineManagement aem, String uimaFullyQualifiedAEContext) {
+		String index = "";
+
+		// Create a unique name with each AE name is separated with "/". Prepend
+		// "X Components" where
+		// X is a instance number of a scaled AE. Also, strip the X from the AE
+		// name. The instance number
+		// is added to each scaled up component during initialization of the
+		// uima-as. We need to prepend
+		// "X Components" to allow DUCC JD to parse the unique name correctly (
+		// basically for backwards
+		// compatibility.
+		int pos = aem.getUniqueMBeanName().lastIndexOf("name=");
+		if (pos > -1) {
+			// get the name of the component. In case of nested component this
+			// will be the KEY from AE descriptor
+			String tmp = aem.getUniqueMBeanName().substring(pos + 5);
+			// in case this is the top level AE, check if it has been scaled up
+			// by extracting its instance number.For example,
+			// NoOpAnnotator 2.
+			int last = tmp.lastIndexOf(" ");
+			if (last == -1) {
+				index = "1";
+			} else {
+				index = tmp.substring(last).trim();
+			}
+			if (uimaFullyQualifiedAEContext.trim().length() > 0 && last > -1) {
+				// extract instance number
+
+				try {
+					// check if the instance number is a number. If not silently
+					// handle the exception.
+					Integer.parseInt(index);
+					// strip the instance number from the AE name
+					uimaFullyQualifiedAEContext = uimaFullyQualifiedAEContext.substring(0, last + 1);
+				} catch (NumberFormatException nfe) {
+
+				} catch (Exception e) {
+				}
+			} else {
+
+				if (!uimaFullyQualifiedAEContext.endsWith(tmp)) {
+					uimaFullyQualifiedAEContext += "/" + tmp;
+				}
+			}
+		}
+		Properties p = new Properties();
+		p.setProperty(AE_NAME, aem.getName());
+		p.setProperty(AE_CONTEXT, uimaFullyQualifiedAEContext);
+		p.setProperty(AE_ANALYSIS_TIME, String.valueOf(aem.getAnalysisTime()));
+		p.setProperty(AE_CAS_PROCESSED, String.valueOf(aem.getNumberOfCASesProcessed()));
+
+		return p;
+	}
+
+	public static List<Properties> getDelta(List<Properties> afterAnalysisManagementObjects,
+			List<Properties> beforeAnalysisManagementObjects) throws Exception {
+
+		List<Properties> deltaMetrics = new ArrayList<>();
+		// Diff the before process() performance metrics with post process performance
+		// metrics
+		for (Properties after : afterAnalysisManagementObjects) {
+			for (Properties before : beforeAnalysisManagementObjects) {
+				String uniqueName = (String) after.get(AE_CONTEXT);
+				if (((String) before.get(AE_CONTEXT)).equals(uniqueName)) {
+					long postProcessCasCount = Long.valueOf(after.getProperty(AE_CAS_PROCESSED));
+					long preProcessCasCount = Long.valueOf(before.getProperty(AE_CAS_PROCESSED));
+
+					long deltaProcessCasCount = postProcessCasCount - preProcessCasCount;
+
+					long afterAnalysisTime = Long.valueOf(after.getProperty(AE_ANALYSIS_TIME)).longValue();
+					long beforeAnalysisTime = Long.valueOf(before.getProperty(AE_ANALYSIS_TIME)).longValue();
+
+					long deltaAnalysisTime = afterAnalysisTime - beforeAnalysisTime;
+					if (deltaAnalysisTime < 0) {
+						Logger logger = UIMAFramework.getLogger();
+						logger.log(Level.WARNING, "Thread:" + Thread.currentThread()
+								+ " UimaProcessContainer.getAEMetricsForCAS() - Unexpected negative result for analysis time:"
+								+ (afterAnalysisTime - beforeAnalysisTime) + " Component:" + uniqueName + " before="
+								+ beforeAnalysisTime + " after=" + afterAnalysisTime);
+					}
+					Properties metrics = new Properties();
+					metrics.setProperty(AE_NAME, after.getProperty(AE_NAME));
+					metrics.setProperty(AE_CONTEXT, uniqueName);
+					metrics.setProperty(AE_ANALYSIS_TIME, String.valueOf(deltaAnalysisTime));
+					metrics.setProperty(AE_CAS_PROCESSED, String.valueOf(deltaProcessCasCount));
+					deltaMetrics.add(metrics);
+					break;
+				}
+			}
+		}
+		return deltaMetrics;
+
+	}
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/BasicUimaMetricsGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/UimaWrapper.java
URL: http://svn.apache.org/viewvc/uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/UimaWrapper.java?rev=1859733&view=auto
==============================================================================
--- uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/UimaWrapper.java (added)
+++ uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/UimaWrapper.java Wed May 22 15:51:17 2019
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.user.common.main;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Properties;
+
+import javax.xml.parsers.FactoryConfigurationError;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.impl.XmiCasDeserializer;
+import org.apache.uima.ducc.user.common.BasicUimaMetricsGenerator;
+import org.apache.uima.ducc.user.common.UimaUtils;
+import org.apache.uima.internal.util.XMLUtils;
+import org.apache.uima.resource.Resource;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceManager;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.util.CasPool;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+public class UimaWrapper {
+	private CasPool casPool = null;
+	private ResourceManager rm = UIMAFramework.newDefaultResourceManager();
+	// Platform MBean server if one is available (Java 1.5 only)
+	private static Object platformMBeanServer;
+	private boolean deserializeFromXMI;
+
+	static {
+		// try to get platform MBean Server (Java 1.5 only)
+		try {
+			Class<?> managementFactory = Class.forName("java.lang.management.ManagementFactory");
+			Method getPlatformMBeanServer = managementFactory.getMethod("getPlatformMBeanServer", new Class[0]);
+			platformMBeanServer = getPlatformMBeanServer.invoke(null, (Object[]) null);
+		} catch (Exception e) {
+			platformMBeanServer = null;
+		}
+	}
+
+	public void initialize(String analysisEngineDescriptor, int scaleout, boolean deserialize,
+			ThreadLocal<AnalysisEngine> threadLocal) throws Exception {
+
+		ResourceSpecifier rSpecifier = UimaUtils.getResourceSpecifier(analysisEngineDescriptor);
+		HashMap<String, Object> paramsMap = new HashMap<>();
+		paramsMap.put(Resource.PARAM_RESOURCE_MANAGER, rm);
+		paramsMap.put(AnalysisEngine.PARAM_MBEAN_SERVER, platformMBeanServer);
+		deserializeFromXMI = deserialize;
+
+		AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(rSpecifier, paramsMap);
+		// pin AE instance to this thread
+		threadLocal.set(ae);
+
+		// check out AE instance pinned to this thread
+
+		synchronized (UimaWrapper.class) {
+			if (casPool == null) {
+				initializeCasPool(ae.getAnalysisEngineMetaData(), scaleout);
+			}
+		}
+	}
+
+	public List<Properties> process(String serializedTask, ThreadLocal<AnalysisEngine> threadLocal) throws Exception {
+
+		CAS cas = casPool.getCas();
+		try {
+			if (deserializeFromXMI) {
+				deserializeCasFromXmi(serializedTask, cas);
+			} else {
+				cas.setDocumentText(serializedTask);
+				cas.setDocumentLanguage("en");
+
+			}
+			// check out AE instance pinned to this thread
+			AnalysisEngine ae = threadLocal.get();
+			List<Properties> preProcessMetrics = BasicUimaMetricsGenerator.get(ae);
+			ae.process(cas);
+			List<Properties> postProcessMetrics = BasicUimaMetricsGenerator.get(ae);
+			return BasicUimaMetricsGenerator.getDelta(postProcessMetrics, preProcessMetrics);
+
+		} finally {
+			if (cas != null) {
+				casPool.releaseCas(cas);
+			}
+		}
+
+	}
+
+	public void deserializeCasFromXmi(String anXmlStr, CAS aCAS)
+			throws FactoryConfigurationError, SAXException, IOException {
+
+		XMLReader xmlReader = XMLUtils.createXMLReader();
+		Reader reader = new StringReader(anXmlStr);
+		XmiCasDeserializer deser = new XmiCasDeserializer(aCAS.getTypeSystem());
+		ContentHandler handler = deser.getXmiCasHandler(aCAS);
+		xmlReader.setContentHandler(handler);
+		xmlReader.parse(new InputSource(reader));
+	}
+
+	public void stop(ThreadLocal<AnalysisEngine> threadLocal) {
+		AnalysisEngine ae = threadLocal.get();
+		if (ae != null) {
+			ae.destroy();
+		}
+	}
+
+	private void initializeCasPool(AnalysisEngineMetaData analysisEngineMetadata, int scaleout)
+			throws ResourceInitializationException {
+		Properties props = new Properties();
+		props.setProperty(UIMAFramework.CAS_INITIAL_HEAP_SIZE, "1000");
+		casPool = new CasPool(scaleout, analysisEngineMetadata, rm);
+	}
+
+}

Propchange: uima/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/UimaWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native