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