Revision 47183
Added by Michele Artini about 7 years ago
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/workflows/util/logger/WorkflowLog.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.msro.workflows.util.logger; |
2 | 2 |
|
3 |
import java.util.LinkedHashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
3 | 6 |
import org.springframework.data.annotation.Id; |
7 |
import org.springframework.data.mongodb.core.mapping.Document; |
|
4 | 8 |
|
9 |
@Document(collection = "wf_logs") |
|
5 | 10 |
public class WorkflowLog { |
6 | 11 |
|
7 | 12 |
@Id |
... | ... | |
21 | 26 |
public String datasourceApi; |
22 | 27 |
public String error; |
23 | 28 |
public String stacktrace; |
29 |
public String workerUrl; |
|
30 |
public Map<String, String> outputParams = new LinkedHashMap<>(); |
|
24 | 31 |
|
25 | 32 |
public String getProcId() { |
26 | 33 |
return procId; |
... | ... | |
142 | 149 |
this.stacktrace = stacktrace; |
143 | 150 |
} |
144 | 151 |
|
152 |
public String getWorkerUrl() { |
|
153 |
return workerUrl; |
|
154 |
} |
|
155 |
|
|
156 |
public void setWorkerUrl(final String workerUrl) { |
|
157 |
this.workerUrl = workerUrl; |
|
158 |
} |
|
159 |
|
|
160 |
public Map<String, String> getOutputParams() { |
|
161 |
return outputParams; |
|
162 |
} |
|
163 |
|
|
164 |
public void setOutputParams(final Map<String, String> outputParams) { |
|
165 |
this.outputParams = outputParams; |
|
166 |
} |
|
167 |
|
|
145 | 168 |
@Override |
146 | 169 |
public String toString() { |
147 | 170 |
return String.format("[procId=%s, name='%s', profile='%s']", procId, name, profileId); |
148 | 171 |
} |
149 |
|
|
150 | 172 |
} |
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/java/eu/dnetlib/msro/workflows/util/WorkflowDispatcher.java | ||
---|---|---|
195 | 195 |
public void onFailed(final AsyncResponse res) { |
196 | 196 |
log.info("FAILED - " + res.getResponseJson()); |
197 | 197 |
try { |
198 |
saveResponse(wf, false, mapper.readValue(res.getResponseJson(), new TypeReference<List<Pair<String, String>>>() {})); |
|
198 |
saveResponse(wf, false, worker.getBaseUrl(), mapper.readValue(res.getResponseJson(), new TypeReference<List<Pair<String, String>>>() {}));
|
|
199 | 199 |
|
200 | 200 |
if (callback != null) { |
201 | 201 |
callback.notify(res); |
... | ... | |
210 | 210 |
public void onDone(final AsyncResponse res) { |
211 | 211 |
log.info("DONE - " + res.getResponseJson()); |
212 | 212 |
try { |
213 |
saveResponse(wf, true, mapper.readValue(res.getResponseJson(), new TypeReference<List<Pair<String, String>>>() {})); |
|
213 |
saveResponse(wf, true, worker.getBaseUrl(), mapper.readValue(res.getResponseJson(), new TypeReference<List<Pair<String, String>>>() {}));
|
|
214 | 214 |
|
215 | 215 |
if (callback != null) { |
216 | 216 |
callback.notify(res); |
... | ... | |
227 | 227 |
return ref; |
228 | 228 |
} |
229 | 229 |
|
230 |
private void saveResponse(final WorkflowInstance wf, final boolean success, final List<Pair<String, String>> res) { |
|
231 |
updateWfProfile(wf, success, res); |
|
232 |
updateJournal(wf, success, res); |
|
233 |
sendMail(wf, success, res); |
|
230 |
private void saveResponse(final WorkflowInstance wf, final boolean success, final String workerUrl, final List<Pair<String, String>> res) {
|
|
231 |
updateWfProfile(wf, success, workerUrl, res);
|
|
232 |
updateJournal(wf, success, workerUrl, res);
|
|
233 |
sendMail(wf, success, workerUrl, res);
|
|
234 | 234 |
} |
235 | 235 |
|
236 |
private void sendMail(final WorkflowInstance wf, final boolean success, final List<Pair<String, String>> res) { |
|
236 |
private void sendMail(final WorkflowInstance wf, final boolean success, final String workerUrl, final List<Pair<String, String>> res) {
|
|
237 | 237 |
log.info("Sending mail to ... TODO"); |
238 | 238 |
|
239 | 239 |
/* |
... | ... | |
241 | 241 |
*/ |
242 | 242 |
} |
243 | 243 |
|
244 |
private void updateJournal(final WorkflowInstance wf, final boolean success, final List<Pair<String, String>> res) { |
|
244 |
private void updateJournal(final WorkflowInstance wf, final boolean success, final String workerUrl, final List<Pair<String, String>> res) {
|
|
245 | 245 |
|
246 | 246 |
final WorkflowLog wfLog = new WorkflowLog(); |
247 | 247 |
wfLog.setName(wf.getName()); |
... | ... | |
253 | 253 |
wfLog.setDatasourceId(wf.getDsId()); |
254 | 254 |
wfLog.setDatasourceApi(wf.getDsInterface()); |
255 | 255 |
wfLog.setSuccess(success); |
256 |
wfLog.setWorkerUrl(workerUrl); |
|
256 | 257 |
|
257 | 258 |
for (final Pair<String, String> p : res) { |
258 | 259 |
if (p.getKey().equals(WorkflowsConstants.LOG_WF_PROCESS_ID)) { |
... | ... | |
267 | 268 |
wfLog.setError(p.getValue()); |
268 | 269 |
} else if (p.getKey().equals(WorkflowsConstants.LOG_SYSTEM_ERROR_STACKTRACE) && !success) { |
269 | 270 |
wfLog.setStacktrace(p.getValue()); |
271 |
} else { |
|
272 |
wfLog.getOutputParams().put(p.getKey(), p.getValue()); |
|
270 | 273 |
} |
271 | 274 |
|
272 | 275 |
} |
... | ... | |
277 | 280 |
|
278 | 281 |
} |
279 | 282 |
|
280 |
private void updateWfProfile(final WorkflowInstance wf, final boolean success, final List<Pair<String, String>> res) { |
|
283 |
private void updateWfProfile(final WorkflowInstance wf, final boolean success, final String workerUrl, final List<Pair<String, String>> res) {
|
|
281 | 284 |
if (!wf.isTemplate() && StringUtils.isNotBlank(wf.getProfileId())) { |
282 | 285 |
try { |
283 | 286 |
final String template = IOUtils.toString(getClass().getResourceAsStream("/templates/workflow_status.xml.st")); |
modules/dnet-springboot-apps/trunk/dnet-msro-application/src/main/resources/application.properties | ||
---|---|---|
10 | 10 |
msro.worker.datasourceProtocolsJson = [ {"name": "OAI", "value": "OAI", "icon": "icon-book"}, {"name": "FTP", "value": "FTP", "icon": "icon-download-alt"}, {"name": "local dir", "value": "filesystem", "icon": "icon-folder-open"}, {"name": "local file", "value": "file", "icon": "icon-file"}, {"name": "http", "value": "http", "icon": "icon-arrow-down"} ] |
11 | 11 |
msro.worker.datasourceTypologiesJson = [ {"name": "Publication repository", "value": "pubsrepository", "icon": "icon-hdd"}, {"name": "Dataset repository", "value": "datarepository", "icon": "icon-hdd"}, {"name": "Aggregator", "value": "AGGREGATOR", "icon": "icon-hdd"}, {"name": "Entity registry", "value": "entityregistry", "icon": "icon-hdd"} ] |
12 | 12 |
|
13 |
spring.data.mongodb.database = dnet_wf_logs |
|
13 |
spring.data.mongodb.database = dnet_msro_db |
Also available in: Unified diff