if (closed || DEFAULT != LogsManager.this) {
LOG.log(Level.INFO, "Stopping processing at {0} files", cnt);
break;
}
Logfile tempLog = LogFileTask.getLogInfo(f.getName(), em);
if (tempLog == null){
tempLog = new Logfile(LogFileTask.getIdSes(f.getName()), LogFileTask.getSessionNumber(f.getName()));
em.persist(tempLog);
} else if (isOldBuild(tempLog)){
LOG.log(Level.FINER, "Skipping old build.", f);
continue;
}
final Logfile log = tempLog;
try {
assert log != null;
final List<Value> recompute = statisticsToRecompute(em, log);
if (recompute.isEmpty()) {
LOG.log(Level.FINER, "File {0} is up to date.", f);
} else {
if (LOG.isLoggable(Level.FINER)) {
StringBuilder sb = new StringBuilder();
sb.append("File ");
sb.append(f.getPath());
sb.append(" needs reparse for ");
String sep = "";
for (Value<?> value : recompute) {
sb.append(sep);
sb.append(value.statistics.name);
sep = ", ";
}
LOG.finer(sb.toString());
}
class RecomputeTask extends LogFileTask{
public RecomputeTask() {
super(f, null, null);
}
@Override
public void run() {
if (closed) {
LOG.info("Processing cancelled");
return;
}
runningTask = this;
handleAddNewLog(f, recompute, false, log, em);
notifyFinished();
}
}
em.getTransaction().begin();
new RecomputeTask().run();
em.getTransaction().commit();
}
LOG.log(Level.FINE, "Recomputing {0}", log.getFileName());
for (Value<?> v : sum) {
addDataForLog(v, log, em);
}
} catch (ThreadDeath td) {
throw td;
} catch (Throwable t) {
if (log == null){
LOG.log(Level.SEVERE, "Exception when processing: " , t);
}else{
LOG.log(Level.SEVERE, "Exception when processing: " + log.getFileName(), t);
}
em.getTransaction().rollback();
break;
}
}