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 2015/02/18 20:06:37 UTC
svn commit: r1660700 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user:
common/main/DuccJobService.java jp/DuccAbstractProcessContainer.java
Author: cwiklik
Date: Wed Feb 18 19:06:37 2015
New Revision: 1660700
URL: http://svn.apache.org/r1660700
Log:
UIMA-4253 removes log4j.configuration from System properties before running Ducc code. Restores the property before crossing from ducc to user container on deploy
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/DuccJobService.java
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jp/DuccAbstractProcessContainer.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/DuccJobService.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/DuccJobService.java?rev=1660700&r1=1660699&r2=1660700&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/DuccJobService.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/main/DuccJobService.java Wed Feb 18 19:06:37 2015
@@ -81,6 +81,17 @@ public class DuccJobService {
}
public void start(String[] args) throws Exception {
+ String log4jConfigurationFile = System.getProperty("log4j.configuration");
+ // if user provided log4j configuration file via -D, save it for later
+ // under a different property name. Remove "log4j.configuration" from System
+ // properties to prevent Ducc from using it to configure its logger.
+ // The user's log4j configuration property will be restored before crossing
+ // class loader boundary from ducc to user.
+ if ( log4jConfigurationFile != null ) {
+ System.setProperty("ducc.user.log4j.saved.configuration",log4jConfigurationFile);
+ System.getProperties().remove("log4j.configuration");
+ }
+
// cache current context classloader
ClassLoader sysCL = Thread.currentThread().getContextClassLoader();
// Fetch a classpath for the fenced Ducc container
@@ -109,9 +120,10 @@ public class DuccJobService {
.getProperty("ducc.deploy.JpProcessorClass");
// Instantiate process container where the actual analysis will be done.
- // Currently there are two containers:
+ // Currently there are three containers:
// 1 - UimaProcessContainer - used for pieces parts (UIMA only)
// 2 - UimaASProcessContainer - used for DD jobs
+ // 3 - UimaASServiceContainer - used for UIMA-AS based services
//
// NOTE: the container class is loaded by the main System classloader
// and requires uima-ducc-user jar to be in the System classpath.
@@ -125,8 +137,8 @@ public class DuccJobService {
Method setProcessorMethod = classToLaunch.getMethod("setProcessor",
Object.class, String[].class);
setProcessorMethod.invoke(duccContainerInstance, pc, args);
- // Call DuccService.start() to initialize worker threads and to
- // start fetching Work Items from a JD for processing.
+ // Call DuccService.start() to initialize the process
+ // and begin processing
Method startMethod = classToLaunch.getMethod("start");// ,
startMethod.invoke(duccContainerInstance);
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jp/DuccAbstractProcessContainer.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jp/DuccAbstractProcessContainer.java?rev=1660700&r1=1660699&r2=1660700&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jp/DuccAbstractProcessContainer.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jp/DuccAbstractProcessContainer.java Wed Feb 18 19:06:37 2015
@@ -49,17 +49,25 @@ public abstract class DuccAbstractProces
return serializerMap.get(Thread.currentThread().getId());
}
+ private void restoreLog4j() {
+ String log4jConfigurationFile="";
+ if ( (log4jConfigurationFile = System.getProperty("ducc.user.log4j.saved.configuration")) != null ) {
+ System.setProperty("log4j.configuration", log4jConfigurationFile);
+ }
+ }
public int initialize(Properties p, String[] arg) throws Exception {
// save current context cl and inject System classloader as
// a context cl before calling user code. This is done in
// user code needs to load resources
ClassLoader savedCL = Thread.currentThread().getContextClassLoader();
+ restoreLog4j();
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
try {
return doInitialize(p, arg);
}finally {
Thread.currentThread().setContextClassLoader(savedCL);
+ System.setProperty("log4j.configuration", "");
}
}
public void deploy() throws Exception {
@@ -67,13 +75,20 @@ public abstract class DuccAbstractProces
// save current context cl and inject System classloader as
// a context cl before calling user code.
ClassLoader savedCL = Thread.currentThread().getContextClassLoader();
+ restoreLog4j();
+ System.out.println("DuccAbstractProcessContainer.deploy() >>>>>>>>> Crossing from Ducc Container to User Container");
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
try {
doDeploy();
- }finally {
+ } finally {
Thread.currentThread().setContextClassLoader(savedCL);
+ System.out.println("DuccAbstractProcessContainer.deploy() <<<<<<<< Returning from User Container to Ducc Container");
// Pin thread to its own CAS serializer instance
serializerMap.put( Thread.currentThread().getId(), new DuccUimaSerializer());
+ if ( System.getProperties().containsKey("log4j.configuration")) {
+ // remove log4j configuration property after calling user code
+ System.getProperties().remove("log4j.configuration");
+ }
}
}
public List<Properties> process(Object xmi) throws Exception {