Author: rwesten
Date: Tue Feb 28 14:26:00 2012
New Revision: 1294670
URL: http://svn.apache.org/viewvc?rev=1294670&view=rev
Log:
Bug fix:
This fixes a thread synchronisation Issue during the initialisation phase (line
145-153 EnhancementJobHandler).
The first call to "executeNextNodes(..)" - async. calls EnhancementEngines that
are not dependendOn any other - was not executed within a write lock.
Therefore in cases multiple EnhancementEngines could be started there was the
possibility that the first one completed before the second one was correctly
initialised. In such cases it could happen, that the JobManager attempt to
start the same engine twice. This caused an IllegalStateException.
Now the "executeNextNodes(..)" during the initialisation is correctly issued
within a write lock.
Other changes:
* improved debug level logging messages to be more informative
Modified:
incubator/stanbol/trunk/enhancer/jobmanager/event/src/main/java/org/apache/stanbol/enhancer/jobmanager/event/impl/EnhancementJob.java
incubator/stanbol/trunk/enhancer/jobmanager/event/src/main/java/org/apache/stanbol/enhancer/jobmanager/event/impl/EnhancementJobHandler.java
Modified:
incubator/stanbol/trunk/enhancer/jobmanager/event/src/main/java/org/apache/stanbol/enhancer/jobmanager/event/impl/EnhancementJob.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/jobmanager/event/src/main/java/org/apache/stanbol/enhancer/jobmanager/event/impl/EnhancementJob.java?rev=1294670&r1=1294669&r2=1294670&view=diff
==============================================================================
---
incubator/stanbol/trunk/enhancer/jobmanager/event/src/main/java/org/apache/stanbol/enhancer/jobmanager/event/impl/EnhancementJob.java
(original)
+++
incubator/stanbol/trunk/enhancer/jobmanager/event/src/main/java/org/apache/stanbol/enhancer/jobmanager/event/impl/EnhancementJob.java
Tue Feb 28 14:26:00 2012
@@ -376,13 +376,14 @@ public class EnhancementJob {
throw new IllegalArgumentException("The parsed em:Execution
instance MUST NOT be NULL!");
}
writeLock.lock();
- log.debug("++ w: {}: {}","setCompleted",getEngine(executionPlan,
execution));
+ NonLiteral executionNode = getExecutionNode(execution);
+ log.debug("++ w: {}: {}","setCompleted",getEngine(executionPlan,
executionNode));
try {
- log.debug(">> w: {}: {}","setCompleted",getEngine(executionPlan,
execution));
- setNodeCompleted(getExecutionNode(execution));
+ log.debug(">> w: {}: {}","setCompleted",getEngine(executionPlan,
executionNode));
+ setNodeCompleted(executionNode);
setExecutionCompleted(executionMetadata, execution, null);
} finally {
- log.debug("<< w: {}: {}","setCompleted",getEngine(executionPlan,
execution));
+ log.debug("<< w: {}: {}","setCompleted",getEngine(executionPlan,
executionNode));
writeLock.unlock();
}
}
@@ -459,28 +460,27 @@ public class EnhancementJob {
try {
log.debug(">> w: {}:
{}","setRunning",ExecutionPlanHelper.getEngine(executionPlan, executionNode));
if (completed.contains(executionNode)) {
- throw new IllegalStateException(
- "Unable to set state of ExectionNode '"+ executionNode
- + "'(chain '"+chain+ "' | contentItem '"
- + contentItem.getUri()+"') to running, because"
- + "it is already marked as completed. This indicates "
- + "an Bug in the implementation of the JobManager "
- + "used to execute the ExecutionPlan (chain state: "
- +"completed " + completed + " | running " + running
- + ")!");
+ String message = "Unable to set state of ExectionNode '" +
executionNode + "'(chain '"
+ + chain + "' | contentItem '" +
contentItem.getUri()
+ + "') to running, because"
+ + "it is already marked as completed. This
indicates "
+ + "an Bug in the implementation of the
JobManager "
+ + "used to execute the ExecutionPlan (chain
state: " + "completed "
+ + completed + " | running " + running + ")!";
+ log.error(message);
+ throw new IllegalStateException(message);
}
if (!completed.containsAll(dependsOn)) {
// TODO maybe define an own Exception for such cases
- throw new IllegalStateException(
- "Unable to set state of ExectionNode '"+ executionNode
- + "' (chain '"+chain+ "' | contentItem '"
- + contentItem.getUri()+"') to running, because "
- + "some of its depended nodes are not marked "
- + "completed yet. This indicates an Bug in the "
- + "implementation of the JobManager used to execute "
- + "the ExecutionPlan (this.dependsOn=" + dependsOn
- + "| chain.completed " + completed
- + " | chain.running " + running + ")!");
+ String message = "Unable to set state of ExectionNode '" +
executionNode + "' (chain '"
+ + chain + "' | contentItem '" +
contentItem.getUri()
+ + "') to running, because " + "some of its
depended nodes are not marked "
+ + "completed yet. This indicates an Bug in
the "
+ + "implementation of the JobManager used to
execute "
+ + "the ExecutionPlan (this.dependsOn=" +
dependsOn + "| chain.completed "
+ + completed + " | chain.running " + running +
")!";
+ log.error(message);
+ throw new IllegalStateException(message);
}
if (!running.add(executionNode)) {
log.warn("Execution of Engine '{}' for ContentItem {} already "
@@ -577,7 +577,7 @@ public class EnhancementJob {
try {
return executable;
} finally {
- log.debug("<< r: {}","getExecutable");
+ log.debug("<< r: {}:{}","getExecutable",executable);
readLock.unlock();
}
}
Modified:
incubator/stanbol/trunk/enhancer/jobmanager/event/src/main/java/org/apache/stanbol/enhancer/jobmanager/event/impl/EnhancementJobHandler.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/jobmanager/event/src/main/java/org/apache/stanbol/enhancer/jobmanager/event/impl/EnhancementJobHandler.java?rev=1294670&r1=1294669&r2=1294670&view=diff
==============================================================================
---
incubator/stanbol/trunk/enhancer/jobmanager/event/src/main/java/org/apache/stanbol/enhancer/jobmanager/event/impl/EnhancementJobHandler.java
(original)
+++
incubator/stanbol/trunk/enhancer/jobmanager/event/src/main/java/org/apache/stanbol/enhancer/jobmanager/event/impl/EnhancementJobHandler.java
Tue Feb 28 14:26:00 2012
@@ -142,7 +142,15 @@ public class EnhancementJobHandler imple
}
if(init){
enhancementJob.startProcessing();
- executeNextNodes(enhancementJob);
+ log.debug("++ w: {}","init execution");
+ enhancementJob.getLock().writeLock().lock();
+ try {
+ log.debug(">> w: {}","init execution");
+ executeNextNodes(enhancementJob);
+ } finally {
+ log.debug("<< w: {}","init execution");
+ enhancementJob.getLock().writeLock().unlock();
+ }
}
return o;
}
@@ -280,12 +288,17 @@ public class EnhancementJobHandler imple
protected void executeNextNodes(EnhancementJob job) {
//getExecutable returns an snapshot so we do not need to lock
for(NonLiteral executable : job.getExecutable()){
+ if(log.isDebugEnabled()){
+ log.debug("PREPARE execution of Engine {}",
+ getEngine(job.getExecutionPlan(),
job.getExecutionNode(executable)));
+ }
Dictionary<String,Object> properties = new
Hashtable<String,Object>();
properties.put(PROPERTY_JOB_MANAGER, job);
properties.put(PROPERTY_EXECUTION, executable);
job.setRunning(executable);
if(log.isDebugEnabled()){
- log.debug("SHEDULE execution of Engine
{}",ExecutionPlanHelper.getEngine(job.getExecutionPlan(), executable));
+ log.debug("SHEDULE execution of Engine {}",
+ getEngine(job.getExecutionPlan(),
job.getExecutionNode(executable)));
}
eventAdmin.postEvent(new Event(TOPIC_JOB_MANAGER,properties));
}