You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2015/02/04 20:00:07 UTC

svn commit: r1657372 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-container/src: main/java/org/apache/uima/ducc/container/jd/ main/java/org/apache/uima/ducc/container/jd/classload/ test/java/org/apache/uima/ducc/container/jd/test/ test/java/org/apache/...

Author: degenaro
Date: Wed Feb  4 19:00:06 2015
New Revision: 1657372

URL: http://svn.apache.org/r1657372
Log:
UIMA-4069 DUCC Job Driver (JD) system classpath

provide full stack trace in JD log when CR throws an exception

Added:
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/helper/CrInitException.java   (with props)
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/resources/CrInitException.xml   (with props)
Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/JobDriver.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/JobDriverException.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverCollectionReader.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverErrorHandler.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverUserError.java
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/TestClassLoading.java

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/JobDriver.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/JobDriver.java?rev=1657372&r1=1657371&r2=1657372&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/JobDriver.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/JobDriver.java Wed Feb  4 19:00:06 2015
@@ -55,10 +55,7 @@ public class JobDriver {
 	}
 	
 	public static JobDriver createInstance() throws JobDriverException {
-		if(instance != null) {
-			throw new JobDriverException("already created");
-		}
-		else {
+		if(instance == null) {
 			instance = new JobDriver();
 		}
 		return getInstance();
@@ -111,7 +108,7 @@ public class JobDriver {
 		}
 		catch(Exception e) {
 			logger.error(location, ILogger.null_id, e);
-			throw new JobDriverException(e);
+			throw new JobDriverException();
 		}
 	}
 	

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/JobDriverException.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/JobDriverException.java?rev=1657372&r1=1657371&r2=1657372&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/JobDriverException.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/JobDriverException.java Wed Feb  4 19:00:06 2015
@@ -22,11 +22,6 @@ public class JobDriverException extends
 
 	private static final long serialVersionUID = 1L;
 	
-	public JobDriverException(String text) {
-		super(text);
-	}
-	
-	public JobDriverException(Exception e) {
-		super(e);
+	public JobDriverException() {
 	}
 }

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverCollectionReader.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverCollectionReader.java?rev=1657372&r1=1657371&r2=1657372&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverCollectionReader.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverCollectionReader.java Wed Feb  4 19:00:06 2015
@@ -66,10 +66,16 @@ public class ProxyJobDriverCollectionRea
 			};
 	
 	public ProxyJobDriverCollectionReader() throws JobDriverException {
-		initialize();
+		try {
+			initialize();
+		}
+		catch(Exception e) {
+			ProxyJobDriverUserError.loggifyUserException(e);
+			throw new JobDriverException();
+		}
 	}
 	
-	private void initialize() throws JobDriverException {
+	private void initialize() throws Exception {
 		FlagsExtendedHelper feh = FlagsExtendedHelper.getInstance();
 		String userClasspath = feh.getUserClasspath();
 		URLClassLoader classLoader = createClassLoader(userClasspath);
@@ -78,35 +84,25 @@ public class ProxyJobDriverCollectionRea
 		construct(classLoader, crXml, crCfg);
 	}
 	
-	private URLClassLoader createClassLoader(String userClasspath) {
-		String location = "createClassLoader";
+	private URLClassLoader createClassLoader(String userClasspath) throws Exception {
 		URLClassLoader retVal = null;
-		try {
-			retVal = PrivateClassLoader.create(userClasspath);
-		}
-		catch(Exception e) {
-			ProxyJobDriverUserError.loggifyUserException(e);
-			logger.error(location, ILogger.null_id, e);
-		}
+		retVal = PrivateClassLoader.create(userClasspath);
 		return retVal;
 	}
 	
 	public int getTotal() throws JobDriverException {
-		String location = "getTotal";
 		int retVal = -1;
 		try {
 			retVal = (Integer)method_getTotal.invoke(instance_JdUserCollectionReader, nullObjectArray);
 		} 
-		catch (Exception e) {
+		catch(Exception e) {
 			ProxyJobDriverUserError.loggifyUserException(e);
-			logger.error(location, ILogger.null_id, e);
-			throw new JobDriverException(e);
+			throw new JobDriverException();
 		}
 		return retVal;
 	}
 	
 	public MetaCas getMetaCas() throws JobDriverException {
-		String location = "getMetaCas";
 		MetaCas retVal = null;
 		try {
 			method_getJdUserMetaCas = class_JdUserCollectionReader.getMethod(name_getJdUserMetaCas, nullClassArray);
@@ -122,30 +118,29 @@ public class ProxyJobDriverCollectionRea
 				retVal = new MetaCas(seqNo, docId, serializedCas);
 			}
 		} 
-		catch (Exception e) {
+		catch(Exception e) {
 			ProxyJobDriverUserError.loggifyUserException(e);
-			logger.error(location, ILogger.null_id, e);
-			throw new JobDriverException(e);
+			throw new JobDriverException();
 		}
 		return retVal;
 	}
 	
-	private void construct(URLClassLoader classLoader, String crXml, String cfCfg) throws JobDriverException {
+	private void construct(URLClassLoader classLoader, String crXml, String cfCfg) throws Exception {
 		setup(classLoader, crXml, cfCfg);
 		validate();
 		prepare();
 	}
 	
-	private void setup(URLClassLoader urlClassLoader, String crXml, String crCfg) throws JobDriverException {
+	private void setup(URLClassLoader urlClassLoader, String crXml, String crCfg) throws Exception {
 		String location = "setup";
 		if(urlClassLoader == null) {
-			JobDriverException e = new JobDriverException("missing URLClassLoader");
+			Exception e = new Exception("missing URLClassLoader");
 			logger.error(location, ILogger.null_id, e);
 			throw e;
 		}
 		setURLClassLoader(urlClassLoader);
 		if(crXml == null) {
-			JobDriverException e = new JobDriverException("missing CollectionReader xml");
+			Exception e = new Exception("missing CollectionReader xml");
 			logger.error(location, ILogger.null_id, e);
 			throw e;
 		}
@@ -153,27 +148,19 @@ public class ProxyJobDriverCollectionRea
 		setCrCfg(crCfg);
 	}
 	
-	private void validate() throws JobDriverException {
+	private void validate() throws Exception {
 		for(String className : requiredClasses) {
 			loadClass(className);
 		}
 	}
 	
-	private void prepare() throws JobDriverException {
-		String location = "prepare";
-		try {
-			class_JdUserCollectionReader = urlClassLoader.loadClass("org.apache.uima.ducc.user.jd.JdUserCollectionReader");
-			Constructor<?> constructor_JdUserCollectionReader = class_JdUserCollectionReader.getConstructor(String.class,String.class);
-			instance_JdUserCollectionReader = constructor_JdUserCollectionReader.newInstance(new Object[] { crXml, crCfg });
-			method_getTotal = class_JdUserCollectionReader.getMethod(name_getTotal, nullClassArray);
-			class_JdUserMetaCas = urlClassLoader.loadClass("org.apache.uima.ducc.user.jd.JdUserMetaCas");
-			method_getJdUserMetaCas = class_JdUserCollectionReader.getMethod(name_getJdUserMetaCas, nullClassArray);
-		} 
-		catch (Exception e) {
-			ProxyJobDriverUserError.loggifyUserException(e);
-			logger.error(location, ILogger.null_id, e);
-			throw new JobDriverException(e);
-		}
+	private void prepare() throws Exception {
+		class_JdUserCollectionReader = urlClassLoader.loadClass("org.apache.uima.ducc.user.jd.JdUserCollectionReader");
+		Constructor<?> constructor_JdUserCollectionReader = class_JdUserCollectionReader.getConstructor(String.class,String.class);
+		instance_JdUserCollectionReader = constructor_JdUserCollectionReader.newInstance(new Object[] { crXml, crCfg });
+		method_getTotal = class_JdUserCollectionReader.getMethod(name_getTotal, nullClassArray);
+		class_JdUserMetaCas = urlClassLoader.loadClass("org.apache.uima.ducc.user.jd.JdUserMetaCas");
+		method_getJdUserMetaCas = class_JdUserCollectionReader.getMethod(name_getJdUserMetaCas, nullClassArray);
 	}
 	
 	private void setURLClassLoader(URLClassLoader value) {
@@ -190,25 +177,18 @@ public class ProxyJobDriverCollectionRea
 		crCfg = value;
 	}
 	
-	private void loadClass(String className) throws JobDriverException {
+	private void loadClass(String className) throws Exception {
 		String location = "loadClass";
 		MessageBuffer mb = new MessageBuffer();
 		mb.append(Standardize.Label.loading.get()+className);
-		try {
-			logger.debug(location, ILogger.null_id, mb.toString());
-			URL[] urls = urlClassLoader.getURLs();
-			for(URL url : urls) {
-				logger.trace(location, ILogger.null_id, url);
-			}
-			Class<?> loadedClass = urlClassLoader.loadClass(className);
-			mb= new MessageBuffer();
-			mb.append(Standardize.Label.loaded.get()+loadedClass.getName());
-			logger.trace(location, ILogger.null_id, mb.toString());
-		} 
-		catch (Exception e) {
-			ProxyJobDriverUserError.loggifyUserException(e);
-			logger.error(location, ILogger.null_id, mb, e);
-			throw new JobDriverException(e);
-		}
+		logger.debug(location, ILogger.null_id, mb.toString());
+		URL[] urls = urlClassLoader.getURLs();
+		for(URL url : urls) {
+			logger.trace(location, ILogger.null_id, url);
+		}
+		Class<?> loadedClass = urlClassLoader.loadClass(className);
+		mb= new MessageBuffer();
+		mb.append(Standardize.Label.loaded.get()+loadedClass.getName());
+		logger.trace(location, ILogger.null_id, mb.toString());
 	}
 }

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverErrorHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverErrorHandler.java?rev=1657372&r1=1657371&r2=1657372&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverErrorHandler.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverErrorHandler.java Wed Feb  4 19:00:06 2015
@@ -47,80 +47,74 @@ public class ProxyJobDriverErrorHandler
 	private static String directiveInterfaceName = packageName+"IJdUserDirective";
 	
 	public ProxyJobDriverErrorHandler() throws JobDriverException {
-		initialize();
+		try {
+			initialize();
+		}
+		catch(Exception e) {
+			ProxyJobDriverUserError.loggifyUserException(e);
+			throw new JobDriverException();
+		}
 	}
 	
-	private void initialize() throws JobDriverException {
+	private void initialize() throws Exception {
 		String location = "initialize";
-		try {
-			FlagsHelper fh = FlagsHelper.getInstance();
-			String userClasspath = fh.getUserClasspath();
-			String[] classpath = fh.stringToArray(userClasspath);
-			if(classpath != null) {
-				for(String item : classpath) {
-					logger.trace(location, ILogger.null_id, item);
-				}
+		FlagsHelper fh = FlagsHelper.getInstance();
+		String userClasspath = fh.getUserClasspath();
+		String[] classpath = fh.stringToArray(userClasspath);
+		if(classpath != null) {
+			for(String item : classpath) {
+				logger.trace(location, ILogger.null_id, item);
 			}
-			String className = fh.getUserErrorHandlerClassname();
-			if(className == null) {
-				className = defaultClassName;
-			}
-			String initializationData = fh.getUserErrorHandlerCfg();
-			classLoader = createClassLoader(userClasspath);
-			Class<?> classAnchor = classLoader.loadClass(className);
-			objectInstance = classAnchor.newInstance();
-			//
-			String methodNameInitialize = "initialize";
-			Method methodInstanceInitialize = classAnchor.getMethod(methodNameInitialize, String.class);
-			methodInstanceInitialize.invoke(objectInstance, initializationData);
-			//
-			Method[] classMethods = classAnchor.getMethods();
-			for(Method method : classMethods) {
-				if(method.getName().equals("handle")) {
-					Type[] types = method.getParameterTypes();
-					if(types.length == 2) {
-						if(types[0].toString().contains("String")) {
-							if(types[1].toString().contains("Object")) {
-								methodInstanceHandle = method;
-								break;
-							}
+		}
+		String className = fh.getUserErrorHandlerClassname();
+		if(className == null) {
+			className = defaultClassName;
+		}
+		String initializationData = fh.getUserErrorHandlerCfg();
+		classLoader = createClassLoader(userClasspath);
+		Class<?> classAnchor = classLoader.loadClass(className);
+		objectInstance = classAnchor.newInstance();
+		//
+		String methodNameInitialize = "initialize";
+		Method methodInstanceInitialize = classAnchor.getMethod(methodNameInitialize, String.class);
+		methodInstanceInitialize.invoke(objectInstance, initializationData);
+		//
+		Method[] classMethods = classAnchor.getMethods();
+		for(Method method : classMethods) {
+			if(method.getName().equals("handle")) {
+				Type[] types = method.getParameterTypes();
+				if(types.length == 2) {
+					if(types[0].toString().contains("String")) {
+						if(types[1].toString().contains("Object")) {
+							methodInstanceHandle = method;
+							break;
 						}
 					}
 				}
 			}
-			//
-			Class<?> directiveAnchor = classLoader.loadClass(directiveInterfaceName);
-			Method[] directiveMethods = directiveAnchor.getMethods();
-			for(Method method : directiveMethods) {
-				Type[] types = method.getParameterTypes();
-				if(types.length == 0) {
-					if(method.getName().equals("isKillJob")) {
-					methodInstanceIsKillJob = method;
-					}
-					else if(method.getName().equals("isKillProcess")) {
-						methodInstanceIsKillProcess = method;
-					}
-					else if(method.getName().equals("isKillWorkItem")) {
-						methodInstanceIsKillWorkItem = method;
-					}
+		}
+		//
+		Class<?> directiveAnchor = classLoader.loadClass(directiveInterfaceName);
+		Method[] directiveMethods = directiveAnchor.getMethods();
+		for(Method method : directiveMethods) {
+			Type[] types = method.getParameterTypes();
+			if(types.length == 0) {
+				if(method.getName().equals("isKillJob")) {
+				methodInstanceIsKillJob = method;
+				}
+				else if(method.getName().equals("isKillProcess")) {
+					methodInstanceIsKillProcess = method;
+				}
+				else if(method.getName().equals("isKillWorkItem")) {
+					methodInstanceIsKillWorkItem = method;
 				}
 			}
-		} 
-		catch (Exception e) {
-			logger.error(location, ILogger.null_id, e);
-			throw new JobDriverException(e);
 		}
 	}
 	
-	private URLClassLoader createClassLoader(String userClasspath) {
-		String location = "createClassLoader";
+	private URLClassLoader createClassLoader(String userClasspath) throws Exception {
 		URLClassLoader retVal = null;
-		try {
-			retVal = PrivateClassLoader.create(userClasspath);
-		}
-		catch(Exception e) {
-			logger.error(location, ILogger.null_id, e);
-		}
+		retVal = PrivateClassLoader.create(userClasspath);
 		return retVal;
 	}
 	

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverUserError.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverUserError.java?rev=1657372&r1=1657371&r2=1657372&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverUserError.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jd/classload/ProxyJobDriverUserError.java Wed Feb  4 19:00:06 2015
@@ -25,7 +25,7 @@ import org.apache.uima.ducc.container.co
 import org.apache.uima.ducc.container.common.logger.IComponent;
 import org.apache.uima.ducc.container.common.logger.ILogger;
 import org.apache.uima.ducc.container.common.logger.Logger;
-import org.apache.uima.ducc.user.jd.JdUserException;
+import org.apache.uima.ducc.container.jd.JobDriverException;
 
 public class ProxyJobDriverUserError {
 
@@ -34,41 +34,53 @@ public class ProxyJobDriverUserError {
 	public static void loggifyUserException(Exception e) {
 		String location = "loggifyUserException";
 		if(e != null) {
-			if(e instanceof InvocationTargetException) {
+			if(e instanceof JobDriverException) {
+				Throwable t = e.getCause();
+				if(t instanceof Exception) {
+					Exception cause = (Exception) t;
+					loggifyUserException(cause);
+				}
+				else {
+					MessageBuffer mb = new MessageBuffer();
+					mb.append(Standardize.Label.classname.get()+e.getClass().getName());
+					logger.debug(location, ILogger.null_id, mb);
+					logger.error(location, ILogger.null_id, e);
+				}
+			}
+			else if(e instanceof InvocationTargetException) {
 				InvocationTargetException ite = (InvocationTargetException) e;
 				Throwable t = ite.getTargetException();
-				if(e instanceof JdUserException) {
-					JdUserException jdUserException = (JdUserException) t;
-					loggifyJdUserException(jdUserException);
+				if(t instanceof Exception) {
+					Exception jdUserException = (Exception) t;
+					String message = jdUserException.getMessage();
+					loggifyUserException(message);
 				}
 				else {
 					MessageBuffer mb = new MessageBuffer();
 					mb.append(Standardize.Label.classname.get()+e.getClass().getName());
 					logger.debug(location, ILogger.null_id, mb);
+					logger.error(location, ILogger.null_id, e);
 				}
 			}
-			else if(e instanceof JdUserException) {
-				JdUserException jdUserException = (JdUserException) e;
-				loggifyJdUserException(jdUserException);
-			}
 			else {
 				MessageBuffer mb = new MessageBuffer();
 				mb.append(Standardize.Label.classname.get()+e.getClass().getName());
 				logger.debug(location, ILogger.null_id, mb);
+				logger.error(location, ILogger.null_id, e);
 			}
 		}
 		else {
 			MessageBuffer mb = new MessageBuffer();
 			mb.append(Standardize.Label.exception.get()+null);
 			logger.debug(location, ILogger.null_id, mb);
+			logger.error(location, ILogger.null_id, e);
 		}
 	}
 	
-	private static void loggifyJdUserException(JdUserException jdUserException) {
-		String location = "loggifyJdUserException";
-		String userException = jdUserException.getUserException();
-		if(userException != null) {
-			logger.error(location, ILogger.null_id, userException);
+	private static void loggifyUserException(String message) {
+		String location = "loggify";
+		if(message != null) {
+			logger.error(location, ILogger.null_id, message);
 		}
 		else {
 			MessageBuffer mb = new MessageBuffer();

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/TestClassLoading.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/TestClassLoading.java?rev=1657372&r1=1657371&r2=1657372&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/TestClassLoading.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/TestClassLoading.java Wed Feb  4 19:00:06 2015
@@ -32,6 +32,7 @@ import java.util.List;
 import org.apache.uima.ducc.common.container.FlagsHelper;
 import org.apache.uima.ducc.container.common.classloader.PrivateClassLoader;
 import org.apache.uima.ducc.container.dgen.classload.ProxyDeployableGeneration;
+import org.apache.uima.ducc.container.jd.JobDriverException;
 import org.apache.uima.ducc.container.jd.classload.ProxyJobDriverCollectionReader;
 import org.apache.uima.ducc.container.jd.classload.ProxyJobDriverDirective;
 import org.apache.uima.ducc.container.jd.classload.ProxyJobDriverErrorHandler;
@@ -215,6 +216,30 @@ public class TestClassLoading extends AT
 		}
 		catch(Exception e) {
 			e.printStackTrace();
+			fail("Exception");
+		}
+	}
+
+	@Test
+	public void test_06() {
+		if(isDisabled(this.getClass().getName())) {
+			return;
+		}
+		try {
+			String userClasspath = Utilities.getInstance().getUserCP();
+			System.setProperty(FlagsHelper.Name.UserClasspath.pname(), userClasspath);
+			URL urlXml = this.getClass().getResource("/CrInitException.xml");
+			File file = new File(urlXml.getFile());
+			String crXml = file.getAbsolutePath();
+			System.setProperty(FlagsHelper.Name.CollectionReaderXml.pname(), crXml);
+			new ProxyJobDriverCollectionReader();
+			fail("No Exception?");
+		}
+		catch(JobDriverException e) {
+			// as expected
+		}
+		catch(Exception e) {
+			e.printStackTrace();
 			fail("Exception");
 		}
 	}

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/helper/CrInitException.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/helper/CrInitException.java?rev=1657372&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/helper/CrInitException.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/helper/CrInitException.java Wed Feb  4 19:00:06 2015
@@ -0,0 +1,73 @@
+/*
+ * 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.container.jd.test.helper;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.collection.CollectionException;
+import org.apache.uima.collection.CollectionReader_ImplBase;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.util.Progress;
+import org.apache.uima.util.ProgressImpl;
+
+public class CrInitException extends CollectionReader_ImplBase {
+
+	private int casLimit = 100;
+	private AtomicInteger casCounter = new AtomicInteger(0);
+	
+	@Override 
+	public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
+	          throws ResourceInitializationException {
+		throw new RuntimeException();
+	}
+	
+	@Override
+	public void getNext(CAS aCAS) throws IOException, CollectionException {
+		aCAS.reset();
+		int item = casCounter.incrementAndGet();
+		if(item <= casLimit) {
+			aCAS.setSofaDataString(""+item, "text");
+		}
+	}
+
+	@Override
+	public boolean hasNext() throws IOException, CollectionException {
+		boolean retVal = false;
+		if(casCounter.get() < casLimit) {
+			retVal = true;
+		}
+		return retVal;
+	}
+
+	@Override
+	public Progress[] getProgress() {
+		ProgressImpl[] retVal = new ProgressImpl[1];
+		retVal[0] = new ProgressImpl(casCounter.get(), casLimit, "CASes");
+		return retVal;
+	}
+
+	@Override
+	public void close() throws IOException {
+	}
+
+}

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/helper/CrInitException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/java/org/apache/uima/ducc/container/jd/test/helper/CrInitException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/resources/CrInitException.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/resources/CrInitException.xml?rev=1657372&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/resources/CrInitException.xml (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/resources/CrInitException.xml Wed Feb  4 19:00:06 2015
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+	<!--
+	 ***************************************************************
+	 * 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.
+	 ***************************************************************
+   -->
+   
+<!-- A simple collection reader that reads text files from a directory in the
+     filesystem.  The Java class for this collection reader is in uima_core.jar. -->
+
+<collectionReaderDescription  xmlns="http://uima.apache.org/resourceSpecifier">
+    <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+    <implementationName>org.apache.uima.ducc.user.jd.test.helper.CrInitException</implementationName>
+    <processingResourceMetaData>
+        <name>Driver Collection Reader</name>
+        <description>Generates CASes comprising indices.</description>
+        <version>1.0</version>
+        <vendor>The Apache Software Foundation</vendor>
+        
+        <configurationParameters>
+
+    		<configurationParameter>
+      			<name>compression</name>
+      			<description>Compression</description>
+      			<type>String</type>
+      			<multiValued>false</multiValued>
+      			<mandatory>false</mandatory>
+    		</configurationParameter>
+
+    		<configurationParameter>
+      			<name>jobfile</name>
+      			<description>JobFile</description>
+      			<type>String</type>
+      			<multiValued>false</multiValued>
+      			<mandatory>false</mandatory>
+    		</configurationParameter>
+
+    		<configurationParameter>
+      			<name>error_rate</name>
+      			<description>ErrorRate</description>
+      			<type>String</type>
+      			<multiValued>false</multiValued>
+      			<mandatory>false</mandatory>
+    		</configurationParameter>
+
+    	</configurationParameters>
+
+   	 	<configurationParameterSettings>
+
+   	 	  <nameValuePair>
+		    <name>compression</name>
+		    <value>
+		      <string>10</string>
+		    </value>
+		  </nameValuePair>
+
+   	 	  <nameValuePair>
+		    <name>error_rate</name>
+		    <value>
+		      <string>0</string>
+		    </value>
+		  </nameValuePair>
+
+   	 	  <nameValuePair>
+		    <name>jobfile</name>
+		    <value>
+		      <string>../ducc_test/jobs/1.job</string>
+		    </value>
+		  </nameValuePair>
+
+    	</configurationParameterSettings>
+    	
+        <!-- Type System of CASes returned by this Collection Reader -->
+
+        <typeSystemDescription>
+          <imports>
+            <import name="org.apache.uima.examples.SourceDocumentInformation"/>
+          </imports>
+        </typeSystemDescription>
+
+        <capabilities>
+          	<capability>
+          		<inputs/>
+          		<outputs>
+          			<type allAnnotatorFeatures="true">org.apache.uima.examples.SourceDocumentInformation</type>
+          		</outputs>
+          	</capability>
+        </capabilities>
+		<operationalProperties>
+			<modifiesCas>false</modifiesCas>
+			<multipleDeploymentAllowed>false</multipleDeploymentAllowed>
+			<outputsNewCASes>true</outputsNewCASes>
+		</operationalProperties>		
+    </processingResourceMetaData>
+</collectionReaderDescription>

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/resources/CrInitException.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/test/resources/CrInitException.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain