Project

General

Profile

« Previous | Next » 

Revision 40094

partial reimplementation of the wf engine

View differences:

ProcessRegistry.java
1 1
package eu.dnetlib.msro.workflows.graph;
2 2

  
3
import java.util.ArrayList;
4
import java.util.Collection;
5
import java.util.HashMap;
6
import java.util.Map;
3
import java.util.*;
7 4

  
8 5
import com.google.common.collect.BiMap;
9 6
import com.google.common.collect.HashBiMap;
10 7
import eu.dnetlib.miscutils.datetime.DateUtils;
8
import eu.dnetlib.msro.rmi.MSROException;
11 9
import eu.dnetlib.msro.workflows.util.ProcessUtils;
12 10
import org.apache.commons.logging.Log;
13 11
import org.apache.commons.logging.LogFactory;
......
39 37
		return procs.get(procId);
40 38
	}
41 39

  
40
	public Set<Process> listProcesses() {
41
		return procs.values();
42
	}
43

  
42 44
	public Collection<Process> findProcsByOtherId(final String id) {
43 45
		synchronized (this) {
44 46
			final Collection<Process> res = byOtherId.get(id);
......
46 48
		}
47 49
	}
48 50

  
49
	public String registerProcess(final Process process, final String... ids) {
50
		if (procs.containsValue(process)) {
51
			return procs.inverse().get(process);
51
	public void registerProcess(final Process process, final String... ids) throws MSROException {
52
		if (procs.containsValue(process) || procs.containsKey(process.getId())) {
53
			log.error("Already registerd process: " + process);
54
			throw new MSROException("Already registerd process: " + process);
52 55
		}
53
		final String procId = ProcessUtils.generateProcessId();
54 56

  
55 57
		if (procs.size() >= maxSize) {
56 58
			removeOldestProcess();
57 59
		}
58 60

  
59
		procs.put(procId, process);
61
		procs.put(process.getId(), process);
60 62
		for (String id : ids) {
61 63
			synchronized (this) {
62 64
				if (!byOtherId.containsKey(id)) {
......
66 68
			}
67 69
		}
68 70

  
69
		log.info("Registered proc " + process.getName() + " with id " + procId);
70

  
71
		return procId;
71
		log.info("Registered process " + process);
72 72
	}
73 73

  
74 74
	private void removeOldestProcess() {

Also available in: Unified diff