Revision 59415
Added by Claudio Atzori over 3 years ago
modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.mdstore.modular; |
2 | 2 |
|
3 | 3 |
import com.google.common.collect.Maps; |
4 |
import com.googlecode.sarasvati.GraphProcess; |
|
4 | 5 |
import eu.dnetlib.data.mdstore.MDStoreServiceException; |
5 | 6 |
import eu.dnetlib.data.mdstore.modular.action.DoneCallback; |
6 | 7 |
import eu.dnetlib.data.mdstore.modular.action.FailedCallback; |
... | ... | |
34 | 35 |
final String storingType, |
35 | 36 |
final boolean sync, |
36 | 37 |
final List<MDFormatDescription> mdformats, |
38 |
final GraphProcess graphProcess, |
|
37 | 39 |
final DoneCallback doneCallback, |
38 | 40 |
final FailedCallback failCallback) throws MDStoreServiceException { |
39 |
log.info("Start feeding mdstore " + mdId); |
|
41 |
|
|
40 | 42 |
log.debug("Start feeding mdstore " + mdId + " with epr " + rsEpr); |
41 | 43 |
|
42 | 44 |
String transactionId = null; |
... | ... | |
60 | 62 |
writeOps = mdstore.feed(records, refresh, mdformats); |
61 | 63 |
} |
62 | 64 |
|
63 |
if(writeOps == -1){
|
|
65 |
if(graphProcess.isCanceled()){
|
|
64 | 66 |
//means the process was cancelled, so we must not commit |
65 | 67 |
log.warn(String.format("The feeding process on mdstore %s has been cancelled. Records will not be committed. Transaction %s set as invalid.", mdId, transactionId)); |
66 | 68 |
dao.invalidTransaction(transactionId, mdId); |
modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import javax.annotation.Resource; |
7 | 7 |
|
8 |
import eu.dnetlib.msro.workflows.sarasvati.registry.GraphProcessRegistry; |
|
8 | 9 |
import org.antlr.stringtemplate.StringTemplate; |
9 | 10 |
import org.apache.commons.io.IOUtils; |
10 | 11 |
import org.apache.commons.logging.Log; |
... | ... | |
27 | 28 |
@Resource |
28 | 29 |
private UniqueServiceLocator serviceLocator; |
29 | 30 |
|
31 |
@Resource |
|
32 |
private GraphProcessRegistry graphProcessRegistry; |
|
33 |
|
|
30 | 34 |
/** The dao. */ |
31 | 35 |
private MDStoreDao dao; |
32 | 36 |
|
... | ... | |
122 | 126 |
this.dao = dao; |
123 | 127 |
} |
124 | 128 |
|
129 |
public GraphProcessRegistry getGraphProcessRegistry() { |
|
130 |
return graphProcessRegistry; |
|
131 |
} |
|
132 |
|
|
125 | 133 |
} |
modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.List; |
4 | 4 |
|
5 |
import com.googlecode.sarasvati.GraphProcess; |
|
5 | 6 |
import eu.dnetlib.data.mdstore.MDStoreServiceException; |
6 | 7 |
import eu.dnetlib.data.mdstore.modular.MDFormatDescription; |
7 | 8 |
import eu.dnetlib.data.mdstore.modular.MDStoreFeeder; |
8 | 9 |
import eu.dnetlib.data.mdstore.modular.MDStoreUtils; |
9 | 10 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
10 | 11 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
12 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
11 | 13 |
import org.apache.commons.logging.Log; |
12 | 14 |
import org.apache.commons.logging.LogFactory; |
13 | 15 |
import org.springframework.beans.factory.annotation.Autowired; |
... | ... | |
47 | 49 |
} |
48 | 50 |
} |
49 | 51 |
|
52 |
final String processId = job.getParameters().get(WorkflowsConstants.SYSTEM_WF_PROCESS_ID); |
|
53 |
final GraphProcess proc = getGraphProcessRegistry().findProcess(processId); |
|
50 | 54 |
|
51 |
feeder.feed(mdId, epr, storingType, true, mdformats, params -> { |
|
55 |
log.info(String.format("feeding mdstore %s from workflow process %s", mdId, processId)); |
|
56 |
|
|
57 |
feeder.feed(mdId, epr, storingType, true, mdformats, proc, params -> { |
|
52 | 58 |
job.getParameters().put("mdstoreSize", "" + params.get("mdstoreSize")); |
53 | 59 |
job.getParameters().put("writeOps", "" + params.get("writeOps")); |
54 | 60 |
completeWithSuccess(handler, job); |
modules/cnr-modular-mdstore-service/trunk/pom.xml | ||
---|---|---|
64 | 64 |
<artifactId>cnr-resultset-client</artifactId> |
65 | 65 |
<version>[2.0.0,3.0.0)</version> |
66 | 66 |
</dependency> |
67 |
<dependency> |
|
68 |
<groupId>eu.dnetlib</groupId> |
|
69 |
<artifactId>dnet-msro-service</artifactId> |
|
70 |
<version>[3.0.0,4.0.0)</version> |
|
71 |
</dependency> |
|
67 | 72 |
</dependencies> |
68 | 73 |
</project> |
Also available in: Unified diff
making the mdstore feed action aware of the workflow process registry to handle workflow kills