Revision 46450
Added by Michele Artini over 7 years ago
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/controllers/MsroWorkerController.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.msro.controllers; |
2 | 2 |
|
3 |
import org.apache.commons.logging.Log; |
|
4 |
import org.apache.commons.logging.LogFactory; |
|
5 |
import org.springframework.beans.factory.annotation.Autowired; |
|
3 | 6 |
import org.springframework.web.bind.annotation.RequestMapping; |
4 | 7 |
import org.springframework.web.bind.annotation.RestController; |
5 | 8 |
|
9 |
import com.fasterxml.jackson.databind.ObjectMapper; |
|
10 |
|
|
11 |
import eu.dnetlib.clients.msro.Workflow; |
|
12 |
import eu.dnetlib.clients.msro.WorkflowTemplate; |
|
6 | 13 |
import eu.dnetlib.enabling.annotations.DnetService; |
7 | 14 |
import eu.dnetlib.enabling.annotations.DnetServiceType; |
15 |
import eu.dnetlib.msro.workflows.util.WorkflowDispatcher; |
|
8 | 16 |
import eu.dnetlib.services.BaseService; |
17 |
import eu.dnetlib.services.async.AsyncMethodException; |
|
18 |
import eu.dnetlib.services.async.AsyncServerCallback; |
|
19 |
import eu.dnetlib.services.async.HasAsyncMethods; |
|
9 | 20 |
|
10 | 21 |
@RestController |
11 | 22 |
@RequestMapping("/msro") |
12 | 23 |
@DnetService(DnetServiceType.msro) |
13 |
public class MsroWorkerController extends BaseService { |
|
24 |
public class MsroWorkerController extends BaseService implements HasAsyncMethods {
|
|
14 | 25 |
|
26 |
private static final Log log = LogFactory.getLog(MsroWorkerController.class); |
|
27 |
|
|
28 |
@Autowired |
|
29 |
private WorkflowDispatcher dispatcher; |
|
30 |
|
|
31 |
@Override |
|
32 |
public void processMethod(final String method, final String jsonParams, final AsyncServerCallback callback) throws AsyncMethodException { |
|
33 |
final ObjectMapper mapper = new ObjectMapper(); |
|
34 |
|
|
35 |
try { |
|
36 |
if (method == "startWorkflow") { |
|
37 |
dispatcher.startWorkflow(mapper.readValue(jsonParams, Workflow.class)); |
|
38 |
} else if (method == "startWorkflowTemplate") { |
|
39 |
dispatcher.startWorkflowTemplate(mapper.readValue(jsonParams, WorkflowTemplate.class)); |
|
40 |
} else { |
|
41 |
log.warn("Invalid method: " + method); |
|
42 |
throw new AsyncMethodException("Invalid method: " + method); |
|
43 |
} |
|
44 |
} catch (final Throwable e) { |
|
45 |
log.warn("Error executing method: " + method, e); |
|
46 |
throw new AsyncMethodException("Error executing method: " + method, e); |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
15 | 50 |
} |
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/workflows/util/WorkflowDispatcher.java | ||
---|---|---|
15 | 15 |
import org.springframework.stereotype.Component; |
16 | 16 |
|
17 | 17 |
import eu.dnetlib.clients.is.InformationServiceClient; |
18 |
import eu.dnetlib.clients.msro.Workflow; |
|
19 |
import eu.dnetlib.clients.msro.WorkflowTemplate; |
|
18 | 20 |
import eu.dnetlib.msro.exceptions.MSROException; |
19 |
import eu.dnetlib.msro.workflows.Workflow; |
|
21 |
import eu.dnetlib.msro.workflows.WorkflowInstance;
|
|
20 | 22 |
|
21 | 23 |
@Component |
22 | 24 |
public class WorkflowDispatcher { |
... | ... | |
29 | 31 |
@Autowired |
30 | 32 |
private GraphLoader graphLoader; |
31 | 33 |
|
32 |
public String startRepoHiWorkflow(final String profileId, final String dsId, final String iface) throws MSROException { |
|
33 |
try { |
|
34 |
final Workflow wf = newWorkflowInstance(profileId); |
|
35 |
wf.setDsId(dsId); |
|
36 |
wf.setDsInterface(iface); |
|
37 |
wf.setParent(null); |
|
38 |
return executeWf(wf); |
|
39 |
} catch (final Exception e) { |
|
40 |
log.error("Error parsing workflow: " + profileId, e); |
|
41 |
throw new MSROException("Error parsing workflow"); |
|
42 |
} |
|
34 |
public static final int DEFAULT_PRIORITY = 50; |
|
35 |
|
|
36 |
public String startWorkflow(final Workflow wf) throws MSROException { |
|
37 |
return startWorkflow(wf.getId(), wf.getParent(), wf.getDsId(), wf.getIface()); |
|
43 | 38 |
} |
44 | 39 |
|
45 |
public String startWorkflow(final String profileId, final String parent) throws MSROException { |
|
40 |
public String startWorkflow(final String profileId, final String parent, final String dsId, final String iface) throws MSROException {
|
|
46 | 41 |
try { |
47 |
final Workflow wf = newWorkflowInstance(profileId); |
|
48 |
wf.setParent(parent); |
|
42 |
final WorkflowInstance wf = newWorkflowInstance(profileId); |
|
43 |
|
|
44 |
// override |
|
45 |
if (StringUtils.isNotBlank(parent)) { |
|
46 |
wf.setParent(parent); |
|
47 |
} |
|
48 |
if (StringUtils.isNotBlank(dsId)) { |
|
49 |
wf.setDsId(dsId); |
|
50 |
} |
|
51 |
if (StringUtils.isNotBlank(iface)) { |
|
52 |
wf.setDsInterface(iface); |
|
53 |
} |
|
54 |
// end |
|
49 | 55 |
return executeWf(wf); |
50 | 56 |
} catch (final Exception e) { |
51 | 57 |
log.error("Error parsing workflow: " + profileId, e); |
... | ... | |
53 | 59 |
} |
54 | 60 |
} |
55 | 61 |
|
56 |
private Workflow newWorkflowInstance(final String profileId) throws Exception { |
|
62 |
private WorkflowInstance newWorkflowInstance(final String profileId) throws Exception {
|
|
57 | 63 |
final String profile = isLookup.getProfile(profileId); |
58 | 64 |
final Document doc = new SAXReader().read(new StringReader(profile)); |
59 | 65 |
|
... | ... | |
70 | 76 |
globalParams.put(p.valueOf("@name"), p.getTextTrim()); |
71 | 77 |
} |
72 | 78 |
|
73 |
final Workflow wf = new Workflow();
|
|
79 |
final WorkflowInstance wf = new WorkflowInstance();
|
|
74 | 80 |
wf.setProfileId(profileId); |
75 | 81 |
wf.setName(doc.valueOf("//WORKFLOW_NAME")); |
76 | 82 |
wf.setFamily(doc.valueOf("//WORKFLOW_FAMILY")); |
77 |
wf.setPriority(NumberUtils.toInt("//WORKFLOW_PRIORITY", WorkflowsConstants.DEFAULT_WF_PRIORITY));
|
|
83 |
wf.setPriority(NumberUtils.toInt("//WORKFLOW_PRIORITY", DEFAULT_PRIORITY));
|
|
78 | 84 |
wf.setDsId(doc.valueOf("//DATASOURCE/@id")); |
79 | 85 |
wf.setDsInterface(doc.valueOf("//DATASOURCE/@interface")); |
80 | 86 |
wf.setTemplate(false); |
... | ... | |
84 | 90 |
return wf; |
85 | 91 |
} |
86 | 92 |
|
93 |
public String startWorkflowTemplate(final WorkflowTemplate wf) throws MSROException { |
|
94 |
return startWorkflowTemplate(wf.getId(), wf.getParent(), wf.getName(), wf.getFamily(), wf.getDsId(), wf.getIface(), wf.getParams()); |
|
95 |
} |
|
96 |
|
|
87 | 97 |
public String startWorkflowTemplate(final String profileId, |
98 |
final String parent, |
|
88 | 99 |
final String name, |
89 | 100 |
final String family, |
90 |
final int priority, |
|
91 | 101 |
final String dsId, |
92 | 102 |
final String iface, |
93 |
final Map<String, String> params, |
|
94 |
final String parent) throws MSROException { |
|
103 |
final Map<String, String> params) throws MSROException { |
|
95 | 104 |
|
96 | 105 |
try { |
97 | 106 |
final String profile = isLookup.getProfile(profileId); |
... | ... | |
112 | 121 |
} |
113 | 122 |
} |
114 | 123 |
|
115 |
final Workflow wf = new Workflow();
|
|
124 |
final WorkflowInstance wf = new WorkflowInstance();
|
|
116 | 125 |
wf.setName(name); |
117 | 126 |
wf.setFamily(family); |
118 | 127 |
wf.setDsId(dsId); |
119 | 128 |
wf.setDsInterface(iface); |
120 | 129 |
wf.setGraph(graphLoader.loadGraph(doc, globalParams)); |
121 |
wf.setPriority(priority);
|
|
130 |
wf.setPriority(DEFAULT_PRIORITY);
|
|
122 | 131 |
wf.setProfileId(profileId); |
123 | 132 |
wf.setTemplate(true); |
124 | 133 |
wf.setGlobalParams(globalParams); |
... | ... | |
131 | 140 |
} |
132 | 141 |
} |
133 | 142 |
|
134 |
private String executeWf(final Workflow wf) { |
|
143 |
private String executeWf(final WorkflowInstance wf) {
|
|
135 | 144 |
final String url = searchMsroWorker(wf); |
136 | 145 |
final String procId = assignWorkflow(url, wf); |
137 | 146 |
|
... | ... | |
140 | 149 |
return procId; |
141 | 150 |
} |
142 | 151 |
|
143 |
private String searchMsroWorker(final Workflow wf) { |
|
152 |
private String searchMsroWorker(final WorkflowInstance wf) {
|
|
144 | 153 |
// TODO Auto-generated method stub |
145 | 154 |
return null; |
146 | 155 |
} |
147 | 156 |
|
148 |
private String assignWorkflow(final String url, final Workflow wf) { |
|
157 |
private String assignWorkflow(final String url, final WorkflowInstance wf) {
|
|
149 | 158 |
// TODO send message to MSRO_WORKER (blackboard ?) |
150 | 159 |
|
151 | 160 |
return null; |
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/workflows/util/WorkflowsConstants.java | ||
---|---|---|
49 | 49 |
// public static final String DATASOURCE_ACRONYM = WorkflowsConstants.DATASOURCE_PREFIX + "acronym"; |
50 | 50 |
// public static final String DATASOURCE_URL = WorkflowsConstants.DATASOURCE_PREFIX + "url"; |
51 | 51 |
|
52 |
public static final int MIN_WF_PRIORITY = 0; |
|
53 |
public static final int MAX_WF_PRIORITY = 100; |
|
54 |
public static final int DEFAULT_WF_PRIORITY = 50; |
|
55 | 52 |
public static final int MAX_PENDING_PROCS_SIZE = 100; |
56 | 53 |
public static final int MAX_RUNNING_PROCS_SIZE = 100; |
57 | 54 |
|
modules/dnet-springboot-apps/trunk/dnet-simple-aggregation-worker/src/main/java/eu/dnetlib/msro/workflows/procs/ProcessFactory.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import eu.dnetlib.clients.is.InformationServiceClient; |
13 | 13 |
import eu.dnetlib.msro.exceptions.MSROException; |
14 |
import eu.dnetlib.msro.workflows.Workflow; |
|
14 |
import eu.dnetlib.msro.workflows.WorkflowInstance;
|
|
15 | 15 |
import eu.dnetlib.msro.workflows.util.ProcessCallback; |
16 | 16 |
|
17 | 17 |
/** |
... | ... | |
27 | 27 |
@Autowired |
28 | 28 |
private InformationServiceClient isLookup; |
29 | 29 |
|
30 |
public WorkflowProcess newProcess(final Workflow wf, final ProcessCallback processCallback) throws MSROException { |
|
30 |
public WorkflowProcess newProcess(final WorkflowInstance wf, final ProcessCallback processCallback) throws MSROException {
|
|
31 | 31 |
return new WorkflowProcess(generateProcessId(), |
32 | 32 |
wf.getName(), |
33 | 33 |
wf.getFamily(), |
modules/dnet-springboot-apps/trunk/dnet-simple-aggregation-worker/src/main/java/eu/dnetlib/msro/workflows/procs/WorkflowExecutor.java | ||
---|---|---|
14 | 14 |
import eu.dnetlib.enabling.common.Stoppable; |
15 | 15 |
import eu.dnetlib.enabling.common.StoppableDetails; |
16 | 16 |
import eu.dnetlib.msro.exceptions.MSROException; |
17 |
import eu.dnetlib.msro.workflows.Workflow; |
|
17 |
import eu.dnetlib.msro.workflows.WorkflowInstance;
|
|
18 | 18 |
import eu.dnetlib.msro.workflows.util.ProcessCallback; |
19 | 19 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
20 | 20 |
|
... | ... | |
49 | 49 |
}, 10, 10, TimeUnit.SECONDS); |
50 | 50 |
} |
51 | 51 |
|
52 |
public String startWorkflow(final Workflow wf, final ProcessCallback processCallback) throws Exception { |
|
52 |
public String startWorkflow(final WorkflowInstance wf, final ProcessCallback processCallback) throws Exception {
|
|
53 | 53 |
|
54 | 54 |
if (isPaused()) { |
55 | 55 |
log.warn("Wf " + wf.getProfileId() + " not launched, because WorkflowExecutor is preparing for shutdown"); |
modules/dnet-springboot-apps/trunk/dnet-simple-aggregation-worker/src/main/java/eu/dnetlib/msro/workflows/nodes/LaunchWorkflowTemplateJobNode.java | ||
---|---|---|
54 | 54 |
|
55 | 55 |
final MsroClient msro = serviceClientFactory.getClient(MsroClient.class); |
56 | 56 |
|
57 |
msro.startWorkflowTemplate(getWfTemplateId(), process.getProfileId(), wfTemplateParams, new AsyncClientCallback() { |
|
57 |
msro.startWorkflowTemplate(getWfTemplateId(), process.getProfileId(), getNodeName(), family, wfTemplateParams, new AsyncClientCallback() {
|
|
58 | 58 |
|
59 | 59 |
@Override |
60 | 60 |
public void onGoing(final AsyncResponse res) { |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/msro/workflows/Workflow.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
public class Workflow { |
|
6 |
|
|
7 |
private String name; |
|
8 |
private String family; |
|
9 |
private String parent; |
|
10 |
private String dsId; |
|
11 |
private String dsInterface; |
|
12 |
private Graph graph; |
|
13 |
private int priority; |
|
14 |
private String profileId; |
|
15 |
private boolean template; |
|
16 |
private Map<String, String> globalParams; |
|
17 |
|
|
18 |
public String getName() { |
|
19 |
return name; |
|
20 |
} |
|
21 |
|
|
22 |
public void setName(final String name) { |
|
23 |
this.name = name; |
|
24 |
} |
|
25 |
|
|
26 |
public String getFamily() { |
|
27 |
return family; |
|
28 |
} |
|
29 |
|
|
30 |
public void setFamily(final String family) { |
|
31 |
this.family = family; |
|
32 |
} |
|
33 |
|
|
34 |
public String getParent() { |
|
35 |
return parent; |
|
36 |
} |
|
37 |
|
|
38 |
public void setParent(final String parent) { |
|
39 |
this.parent = parent; |
|
40 |
} |
|
41 |
|
|
42 |
public String getDsId() { |
|
43 |
return dsId; |
|
44 |
} |
|
45 |
|
|
46 |
public void setDsId(final String dsId) { |
|
47 |
this.dsId = dsId; |
|
48 |
} |
|
49 |
|
|
50 |
public String getDsInterface() { |
|
51 |
return dsInterface; |
|
52 |
} |
|
53 |
|
|
54 |
public void setDsInterface(final String dsInterface) { |
|
55 |
this.dsInterface = dsInterface; |
|
56 |
} |
|
57 |
|
|
58 |
public Graph getGraph() { |
|
59 |
return graph; |
|
60 |
} |
|
61 |
|
|
62 |
public void setGraph(final Graph graph) { |
|
63 |
this.graph = graph; |
|
64 |
} |
|
65 |
|
|
66 |
public int getPriority() { |
|
67 |
return priority; |
|
68 |
} |
|
69 |
|
|
70 |
public void setPriority(final int priority) { |
|
71 |
this.priority = priority; |
|
72 |
} |
|
73 |
|
|
74 |
public String getProfileId() { |
|
75 |
return profileId; |
|
76 |
} |
|
77 |
|
|
78 |
public void setProfileId(final String profileId) { |
|
79 |
this.profileId = profileId; |
|
80 |
} |
|
81 |
|
|
82 |
public boolean isTemplate() { |
|
83 |
return template; |
|
84 |
} |
|
85 |
|
|
86 |
public void setTemplate(final boolean template) { |
|
87 |
this.template = template; |
|
88 |
} |
|
89 |
|
|
90 |
public Map<String, String> getGlobalParams() { |
|
91 |
return globalParams; |
|
92 |
} |
|
93 |
|
|
94 |
public void setGlobalParams(final Map<String, String> globalParams) { |
|
95 |
this.globalParams = globalParams; |
|
96 |
} |
|
97 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/msro/workflows/WorkflowInstance.java | ||
---|---|---|
1 |
package eu.dnetlib.msro.workflows; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
public class WorkflowInstance { |
|
6 |
|
|
7 |
private String name; |
|
8 |
private String family; |
|
9 |
private String parent; |
|
10 |
private String dsId; |
|
11 |
private String dsInterface; |
|
12 |
private Graph graph; |
|
13 |
private int priority; |
|
14 |
private String profileId; |
|
15 |
private boolean template; |
|
16 |
private Map<String, String> globalParams; |
|
17 |
|
|
18 |
public String getName() { |
|
19 |
return name; |
|
20 |
} |
|
21 |
|
|
22 |
public void setName(final String name) { |
|
23 |
this.name = name; |
|
24 |
} |
|
25 |
|
|
26 |
public String getFamily() { |
|
27 |
return family; |
|
28 |
} |
|
29 |
|
|
30 |
public void setFamily(final String family) { |
|
31 |
this.family = family; |
|
32 |
} |
|
33 |
|
|
34 |
public String getParent() { |
|
35 |
return parent; |
|
36 |
} |
|
37 |
|
|
38 |
public void setParent(final String parent) { |
|
39 |
this.parent = parent; |
|
40 |
} |
|
41 |
|
|
42 |
public String getDsId() { |
|
43 |
return dsId; |
|
44 |
} |
|
45 |
|
|
46 |
public void setDsId(final String dsId) { |
|
47 |
this.dsId = dsId; |
|
48 |
} |
|
49 |
|
|
50 |
public String getDsInterface() { |
|
51 |
return dsInterface; |
|
52 |
} |
|
53 |
|
|
54 |
public void setDsInterface(final String dsInterface) { |
|
55 |
this.dsInterface = dsInterface; |
|
56 |
} |
|
57 |
|
|
58 |
public Graph getGraph() { |
|
59 |
return graph; |
|
60 |
} |
|
61 |
|
|
62 |
public void setGraph(final Graph graph) { |
|
63 |
this.graph = graph; |
|
64 |
} |
|
65 |
|
|
66 |
public int getPriority() { |
|
67 |
return priority; |
|
68 |
} |
|
69 |
|
|
70 |
public void setPriority(final int priority) { |
|
71 |
this.priority = priority; |
|
72 |
} |
|
73 |
|
|
74 |
public String getProfileId() { |
|
75 |
return profileId; |
|
76 |
} |
|
77 |
|
|
78 |
public void setProfileId(final String profileId) { |
|
79 |
this.profileId = profileId; |
|
80 |
} |
|
81 |
|
|
82 |
public boolean isTemplate() { |
|
83 |
return template; |
|
84 |
} |
|
85 |
|
|
86 |
public void setTemplate(final boolean template) { |
|
87 |
this.template = template; |
|
88 |
} |
|
89 |
|
|
90 |
public Map<String, String> getGlobalParams() { |
|
91 |
return globalParams; |
|
92 |
} |
|
93 |
|
|
94 |
public void setGlobalParams(final Map<String, String> globalParams) { |
|
95 |
this.globalParams = globalParams; |
|
96 |
} |
|
97 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/msro/WorkflowDesc.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.msro; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
public class WorkflowDesc { |
|
7 |
|
|
8 |
private String id; |
|
9 |
private String parent; |
|
10 |
private boolean template = false; |
|
11 |
private Map<String, String> params = new HashMap<>(); |
|
12 |
private String family; |
|
13 |
private int priority = 50; |
|
14 |
private String dsId; |
|
15 |
private String iface; |
|
16 |
|
|
17 |
public String getId() { |
|
18 |
return id; |
|
19 |
} |
|
20 |
|
|
21 |
public void setId(final String id) { |
|
22 |
this.id = id; |
|
23 |
} |
|
24 |
|
|
25 |
public String getParent() { |
|
26 |
return parent; |
|
27 |
} |
|
28 |
|
|
29 |
public void setParent(final String parent) { |
|
30 |
this.parent = parent; |
|
31 |
} |
|
32 |
|
|
33 |
public boolean isTemplate() { |
|
34 |
return template; |
|
35 |
} |
|
36 |
|
|
37 |
public void setTemplate(final boolean template) { |
|
38 |
this.template = template; |
|
39 |
} |
|
40 |
|
|
41 |
public Map<String, String> getParams() { |
|
42 |
return params; |
|
43 |
} |
|
44 |
|
|
45 |
public void setParams(final Map<String, String> params) { |
|
46 |
this.params = params; |
|
47 |
} |
|
48 |
|
|
49 |
public String getFamily() { |
|
50 |
return family; |
|
51 |
} |
|
52 |
|
|
53 |
public void setFamily(final String family) { |
|
54 |
this.family = family; |
|
55 |
} |
|
56 |
|
|
57 |
public int getPriority() { |
|
58 |
return priority; |
|
59 |
} |
|
60 |
|
|
61 |
public void setPriority(final int priority) { |
|
62 |
this.priority = priority; |
|
63 |
} |
|
64 |
|
|
65 |
public String getDsId() { |
|
66 |
return dsId; |
|
67 |
} |
|
68 |
|
|
69 |
public void setDsId(final String dsId) { |
|
70 |
this.dsId = dsId; |
|
71 |
} |
|
72 |
|
|
73 |
public String getIface() { |
|
74 |
return iface; |
|
75 |
} |
|
76 |
|
|
77 |
public void setIface(final String iface) { |
|
78 |
this.iface = iface; |
|
79 |
} |
|
80 |
|
|
81 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/msro/MsroClient.java | ||
---|---|---|
21 | 21 |
private AsyncClientUtils asyncClientUtils; |
22 | 22 |
|
23 | 23 |
public void startWorkflow(final String wfId, final String parent, final AsyncClientCallback callback) { |
24 |
final WorkflowDesc wf = new WorkflowDesc(); |
|
25 |
wf.setId(wfId); |
|
26 |
wf.setParent(parent); |
|
24 |
final Workflow wf = new Workflow(wfId, parent); |
|
27 | 25 |
asyncClientUtils.invokeRemoteMethod(getBaseUrl(), "startWorkflow", wf, callback); |
28 | 26 |
} |
29 | 27 |
|
30 |
public void startWorkflowTemplate(final String wfTemplateId, final String parent, final Map<String, String> params, final AsyncClientCallback callback) { |
|
31 |
final WorkflowDesc wf = new WorkflowDesc(); |
|
32 |
wf.setId(wfTemplateId); |
|
33 |
wf.setParent(parent); |
|
34 |
wf.setTemplate(true); |
|
35 |
wf.setParams(params); |
|
28 |
public void startWorkflow(final String wfId, final String parent, final String dsId, final String ifaceId, final AsyncClientCallback callback) { |
|
29 |
final Workflow wf = new Workflow(wfId, parent, dsId, ifaceId); |
|
30 |
asyncClientUtils.invokeRemoteMethod(getBaseUrl(), "startWorkflow", wf, callback); |
|
31 |
} |
|
36 | 32 |
|
33 |
public void startWorkflowTemplate(final String wfTemplateId, |
|
34 |
final String parent, |
|
35 |
final String name, |
|
36 |
final String family, |
|
37 |
final Map<String, String> params, |
|
38 |
final AsyncClientCallback callback) { |
|
39 |
final WorkflowTemplate wf = new WorkflowTemplate(wfTemplateId, parent, name, family, params); |
|
37 | 40 |
asyncClientUtils.invokeRemoteMethod(getBaseUrl(), "startWorkflow", wf, callback); |
38 | 41 |
} |
42 |
|
|
43 |
public void startWorkflowTemplate(final String wfTemplateId, |
|
44 |
final String parent, |
|
45 |
final String name, |
|
46 |
final String family, |
|
47 |
final Map<String, String> params, |
|
48 |
final String dsId, |
|
49 |
final String ifaceId, |
|
50 |
final AsyncClientCallback callback) { |
|
51 |
final WorkflowTemplate wf = new WorkflowTemplate(wfTemplateId, parent, name, family, dsId, ifaceId, params); |
|
52 |
asyncClientUtils.invokeRemoteMethod(getBaseUrl(), "startWorkflow", wf, callback); |
|
53 |
} |
|
54 |
|
|
39 | 55 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/msro/WorkflowTemplate.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.msro; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
public class WorkflowTemplate extends Workflow { |
|
7 |
|
|
8 |
private String name; |
|
9 |
private String family; |
|
10 |
|
|
11 |
private Map<String, String> params = new HashMap<>(); |
|
12 |
|
|
13 |
public WorkflowTemplate() {} |
|
14 |
|
|
15 |
public WorkflowTemplate(final String id, final String parent, final String name, final String family, final Map<String, String> params) { |
|
16 |
super(id, parent); |
|
17 |
this.name = name; |
|
18 |
this.family = family; |
|
19 |
this.params = params; |
|
20 |
} |
|
21 |
|
|
22 |
public WorkflowTemplate(final String id, final String parent, final String name, final String family, final String dsId, |
|
23 |
final String iface, final Map<String, String> params) { |
|
24 |
super(id, parent, dsId, iface); |
|
25 |
this.name = name; |
|
26 |
this.family = family; |
|
27 |
this.params = params; |
|
28 |
} |
|
29 |
|
|
30 |
public String getName() { |
|
31 |
return name; |
|
32 |
} |
|
33 |
|
|
34 |
public void setName(final String name) { |
|
35 |
this.name = name; |
|
36 |
} |
|
37 |
|
|
38 |
public String getFamily() { |
|
39 |
return family; |
|
40 |
} |
|
41 |
|
|
42 |
public void setFamily(final String family) { |
|
43 |
this.family = family; |
|
44 |
} |
|
45 |
|
|
46 |
public Map<String, String> getParams() { |
|
47 |
return params; |
|
48 |
} |
|
49 |
|
|
50 |
public void setParams(final Map<String, String> params) { |
|
51 |
this.params = params; |
|
52 |
} |
|
53 |
|
|
54 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/clients/msro/Workflow.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.msro; |
|
2 |
|
|
3 |
public class Workflow { |
|
4 |
|
|
5 |
private String id; |
|
6 |
private String parent; |
|
7 |
private String dsId; |
|
8 |
private String iface; |
|
9 |
|
|
10 |
public Workflow() {} |
|
11 |
|
|
12 |
public Workflow(final String id, final String parent) { |
|
13 |
this.id = id; |
|
14 |
this.parent = parent; |
|
15 |
} |
|
16 |
|
|
17 |
public Workflow(final String id, final String parent, final String dsId, final String iface) { |
|
18 |
this.id = id; |
|
19 |
this.parent = parent; |
|
20 |
this.dsId = dsId; |
|
21 |
this.iface = iface; |
|
22 |
} |
|
23 |
|
|
24 |
public String getId() { |
|
25 |
return id; |
|
26 |
} |
|
27 |
|
|
28 |
public void setId(final String id) { |
|
29 |
this.id = id; |
|
30 |
} |
|
31 |
|
|
32 |
public String getParent() { |
|
33 |
return parent; |
|
34 |
} |
|
35 |
|
|
36 |
public void setParent(final String parent) { |
|
37 |
this.parent = parent; |
|
38 |
} |
|
39 |
|
|
40 |
public String getDsId() { |
|
41 |
return dsId; |
|
42 |
} |
|
43 |
|
|
44 |
public void setDsId(final String dsId) { |
|
45 |
this.dsId = dsId; |
|
46 |
} |
|
47 |
|
|
48 |
public String getIface() { |
|
49 |
return iface; |
|
50 |
} |
|
51 |
|
|
52 |
public void setIface(final String iface) { |
|
53 |
this.iface = iface; |
|
54 |
} |
|
55 |
|
|
56 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/services/BaseService.java | ||
---|---|---|
28 | 28 |
import eu.dnetlib.enabling.annotations.DnetServiceType; |
29 | 29 |
import eu.dnetlib.exceptions.DnetGenericException; |
30 | 30 |
import eu.dnetlib.services.async.AsyncClientUtils; |
31 |
import eu.dnetlib.services.async.AsyncMethodNotFoundException;
|
|
31 |
import eu.dnetlib.services.async.AsyncMethodException; |
|
32 | 32 |
import eu.dnetlib.services.async.AsyncResponse; |
33 | 33 |
import eu.dnetlib.services.async.HasAsyncMethods; |
34 | 34 |
import eu.dnetlib.services.async.ResponseAck; |
... | ... | |
124 | 124 |
((HasAsyncMethods) this).processMethod(method, jsonParams, res -> restTemplate.postForObject(url, res, ResponseAckStatus.class)); |
125 | 125 |
|
126 | 126 |
return id; |
127 |
} catch (final AsyncMethodNotFoundException e) {
|
|
128 |
log.error("Async method " + method + " not found");
|
|
127 |
} catch (final AsyncMethodException e) { |
|
128 |
log.error("Invocation of async method failed", e);
|
|
129 | 129 |
throw e; |
130 | 130 |
} |
131 | 131 |
|
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/services/async/AsyncMethodNotFoundException.java | ||
---|---|---|
1 |
package eu.dnetlib.services.async; |
|
2 |
|
|
3 |
import eu.dnetlib.exceptions.DnetGenericException; |
|
4 |
|
|
5 |
public class AsyncMethodNotFoundException extends DnetGenericException { |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
*/ |
|
10 |
private static final long serialVersionUID = 4505152782783864469L; |
|
11 |
|
|
12 |
public AsyncMethodNotFoundException() { |
|
13 |
super(); |
|
14 |
} |
|
15 |
|
|
16 |
public AsyncMethodNotFoundException(final String message, final Throwable cause) { |
|
17 |
super(message, cause); |
|
18 |
} |
|
19 |
|
|
20 |
public AsyncMethodNotFoundException(final String message) { |
|
21 |
super(message); |
|
22 |
} |
|
23 |
|
|
24 |
public AsyncMethodNotFoundException(final Throwable cause) { |
|
25 |
super(cause); |
|
26 |
} |
|
27 |
|
|
28 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/services/async/AsyncMethodException.java | ||
---|---|---|
1 |
package eu.dnetlib.services.async; |
|
2 |
|
|
3 |
import eu.dnetlib.exceptions.DnetGenericException; |
|
4 |
|
|
5 |
public class AsyncMethodException extends DnetGenericException { |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
*/ |
|
10 |
private static final long serialVersionUID = 4505152782783864469L; |
|
11 |
|
|
12 |
public AsyncMethodException() { |
|
13 |
super(); |
|
14 |
} |
|
15 |
|
|
16 |
public AsyncMethodException(final String message, final Throwable cause) { |
|
17 |
super(message, cause); |
|
18 |
} |
|
19 |
|
|
20 |
public AsyncMethodException(final String message) { |
|
21 |
super(message); |
|
22 |
} |
|
23 |
|
|
24 |
public AsyncMethodException(final Throwable cause) { |
|
25 |
super(cause); |
|
26 |
} |
|
27 |
|
|
28 |
} |
modules/dnet-springboot-apps/trunk/dnet-common-utils/src/main/java/eu/dnetlib/services/async/HasAsyncMethods.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
public interface HasAsyncMethods { |
4 | 4 |
|
5 |
void processMethod(String method, String jsonParams, AsyncServerCallback callback) throws AsyncMethodNotFoundException;
|
|
5 |
void processMethod(String method, String jsonParams, AsyncServerCallback callback) throws AsyncMethodException; |
|
6 | 6 |
|
7 | 7 |
} |
Also available in: Unified diff
msro: async methods