StringBuilder sb = new StringBuilder("Status:\n");
ExecutionMetadata em = ExecutionMetadata.parseFrom(job.getExecutionMetadata(), ci.getUri());
for(Entry<String,Execution> ex : em.getEngineExecutions().entrySet()){
sb.append(" -").append(ex.getKey()).append(": ").append(ex.getValue().getStatus()).append('\n');
}
throw new ChainException("Execution timeout after "
+((System.currentTimeMillis()-start)/1000f)+"sec (timeout:"+(maxEnhancementJobWaitTime/1000)
+ "sec) for ContentItem "+ci.getUri()+"\n"+sb.toString()
+ " \n To change the timeout change value of property '"+
MAX_ENHANCEMENT_JOB_WAIT_TIME+"' for the service "+getClass());
}
log.debug("Execution of Chain {} {} after {}ms for ContentItem {}",
new Object[]{ chain.getName(), job.isFailed() ? "failed" : "finished",
System.currentTimeMillis()-start,
job.getContentItem().getUri()});
//NOTE: ExecutionMetadata are not added to the metadata of the ContentItem
// by the EnhancementJobManager.
// However one could add this as an optional feature to the
// RESTful interface of the Enhancer!
//ci.getMetadata().addAll(job.getExecutionMetadata());
if(job.isFailed()){
Exception e = job.getError();
EnhancementJobHandler.logJobInfo(enhancementJobManagerLog, job,
"-- log information about failed EnhancementJob --", true);
logExecutionMetadata(job);
log.warn("ExecutionMetadata: ");
for(Iterator<Triple> it = job.getExecutionMetadata().iterator();
it.hasNext();
log.warn(it.next().toString()));
if (e instanceof SecurityException) {
throw (SecurityException)e;
} else {
throw new ChainException(job.getErrorMessage(), e);
}
}
if(!job.isFinished()){
log.warn("Execution finished, but Job is not finished!");
EnhancementJobHandler.logJobInfo(log, job, null, true);
logExecutionMetadata(job);
throw new ChainException("EnhancementJobManager was deactivated while" +
" enhancing the passed ContentItem "+job.getContentItem()+
" (EnhancementJobManager type: "+getClass()+")");
} else {
//log infos about the execution times to the enhancementJobManager
EnhancementJobHandler.logExecutionTimes(enhancementJobManagerLog, job);