refactoring
This commit is contained in:
parent
0ef83b9900
commit
fe1e851939
|
@ -9,10 +9,10 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import eu.dnetlib.common.controller.DnetRestController;
|
||||
import eu.dnetlib.domain.wfs.jobs.WfRunningJob;
|
||||
import eu.dnetlib.wfs.graph.GraphLoader;
|
||||
import eu.dnetlib.wfs.procs.ProcessEngine;
|
||||
import eu.dnetlib.wfs.procs.ProcessRegistry;
|
||||
import eu.dnetlib.wfs.procs.WorkflowProcess;
|
||||
|
||||
public abstract class AbstractWfExecutorApiController extends DnetRestController {
|
||||
|
||||
|
@ -26,8 +26,8 @@ public abstract class AbstractWfExecutorApiController extends DnetRestController
|
|||
private GraphLoader graphLoader;
|
||||
|
||||
@GetMapping("/process/{id}")
|
||||
public WorkflowProcess findProcess(@PathVariable final String id) throws Exception {
|
||||
return this.registry.findProcess(id);
|
||||
public WfRunningJob findProcess(@PathVariable final String id) throws Exception {
|
||||
return this.registry.findProcess(id).getJobDetails();
|
||||
}
|
||||
|
||||
@GetMapping("/procs")
|
||||
|
|
|
@ -310,6 +310,8 @@ public class ProcessEngine {
|
|||
updateRunningJob(process, token);
|
||||
saveHistoryJob(process);
|
||||
|
||||
this.processRegistry.unregisterProcess(process.getId());
|
||||
|
||||
final String wfConfId = (String) process.getGlobalParams().get("wfConfId");
|
||||
if (StringUtils.isNotBlank(wfConfId)) {
|
||||
this.emailSender.sendMails(wfConfId, process);
|
||||
|
|
|
@ -4,11 +4,9 @@ import java.util.Collection;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import eu.dnetlib.errors.WorkflowManagerException;
|
||||
|
@ -50,17 +48,7 @@ public class ProcessRegistry {
|
|||
this.procs.put(process.getId(), process);
|
||||
}
|
||||
|
||||
@Scheduled(fixedRate = 10, timeUnit = TimeUnit.MINUTES)
|
||||
public void removeTerminatedProcess() {
|
||||
for (final Map.Entry<String, WorkflowProcess> e : this.procs.entrySet()) {
|
||||
final WorkflowProcess proc = e.getValue();
|
||||
if (proc.isTerminated()) {
|
||||
unregisterProcess(proc.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void unregisterProcess(final String procId) {
|
||||
public void unregisterProcess(final String procId) {
|
||||
this.procs.remove(procId);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue