1
|
package eu.dnetlib.msro.workflows.nodes.dfm;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import javax.annotation.Resource;
|
5
|
|
6
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
7
|
import eu.dnetlib.monitoring.core.sensors.SensorCreationException;
|
8
|
import eu.dnetlib.monitoring.core.sensors.SensorFactory;
|
9
|
import eu.dnetlib.monitoring.core.sensors.collection.SensorWrapper;
|
10
|
import eu.dnetlib.monitoring.core.sensors.collection.index.solr.SolrSensor;
|
11
|
import eu.dnetlib.monitoring.core.sensors.collection.kv.redis.RedisSensor;
|
12
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
13
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
14
|
import eu.dnetlib.msro.workflows.procs.Env;
|
15
|
import eu.dnetlib.rmi.enabling.ISLookUpException;
|
16
|
import org.apache.commons.logging.Log;
|
17
|
import org.apache.commons.logging.LogFactory;
|
18
|
|
19
|
public class TriggerPrepublicMonitoringScenarioJobNode extends SimpleJobNode {
|
20
|
|
21
|
private final static String SOLR_COLLECTION_POSTFIX = "-index-openaire";
|
22
|
private final Log log = LogFactory.getLog(TriggerPrepublicMonitoringScenarioJobNode.class);
|
23
|
private String mdFormat;
|
24
|
|
25
|
@Resource
|
26
|
private UniqueServiceLocator serviceLocator;
|
27
|
|
28
|
private SolrSensor solrSensor;
|
29
|
private RedisSensor redisSensor;
|
30
|
private SensorWrapper wrapper;
|
31
|
|
32
|
@Override
|
33
|
protected String execute(final Env env) throws IOException, InstantiationException, IllegalAccessException, InterruptedException,
|
34
|
ISLookUpException, SensorCreationException {
|
35
|
this.log.info("Execution of TriggerPrepublicMonitoringScenarioJobNode");
|
36
|
|
37
|
/* Configuring SOLR sensor */
|
38
|
final String actualCollection = this.mdFormat + SOLR_COLLECTION_POSTFIX;
|
39
|
this.log.info("At this round, the Pre-public monitoring scenario will check against " + actualCollection + " SOLR collection");
|
40
|
this.solrSensor = (SolrSensor) SensorFactory.createSensorWithConfiguration(SolrSensor.class, "prepublic", "solr");
|
41
|
this.solrSensor.getConfiguration().setParam("collection", actualCollection);
|
42
|
this.solrSensor.reinitialize();
|
43
|
|
44
|
/* Configuring Redis sensor */
|
45
|
this.redisSensor = (RedisSensor) SensorFactory.createSensorWithConfiguration(RedisSensor.class, "prepublic", "redis");
|
46
|
|
47
|
/* Wrapping the two sensors together */
|
48
|
this.wrapper = (SensorWrapper) SensorFactory.createSensor(SensorWrapper.class);
|
49
|
this.wrapper.registerSensor(this.solrSensor);
|
50
|
this.wrapper.registerSensor(this.redisSensor);
|
51
|
|
52
|
this.log.info("Measuring prepublic scenario");
|
53
|
this.wrapper.measure();
|
54
|
this.log.info("DONE!");
|
55
|
return Arc.DEFAULT_ARC;
|
56
|
}
|
57
|
|
58
|
public String getMdFormat() {
|
59
|
return this.mdFormat;
|
60
|
}
|
61
|
|
62
|
public void setMdFormat(final String mdFormat) {
|
63
|
this.mdFormat = mdFormat;
|
64
|
}
|
65
|
|
66
|
}
|