1 |
1 |
package eu.dnetlib.msro.openaireplus.workflows.nodes.dataFlowMonitoring;
|
2 |
2 |
|
3 |
3 |
import java.io.IOException;
|
|
4 |
import java.util.HashMap;
|
4 |
5 |
import java.util.List;
|
5 |
6 |
|
6 |
7 |
import javax.annotation.Resource;
|
7 |
8 |
|
|
9 |
import org.apache.commons.io.IOUtils;
|
8 |
10 |
import org.apache.commons.logging.Log;
|
9 |
11 |
import org.apache.commons.logging.LogFactory;
|
10 |
12 |
|
|
13 |
import com.google.gson.Gson;
|
11 |
14 |
import com.googlecode.sarasvati.Arc;
|
12 |
15 |
import com.googlecode.sarasvati.NodeToken;
|
13 |
16 |
|
14 |
17 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
15 |
18 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
16 |
19 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
|
20 |
import eu.dnetlib.monitoring.core.sensors.SensorFactory;
|
|
21 |
import eu.dnetlib.monitoring.core.sensors.collection.CollectionSensor;
|
|
22 |
import eu.dnetlib.monitoring.core.sensors.collection.SensorWrapper;
|
|
23 |
import eu.dnetlib.monitoring.core.sensors.collection.index.solr.SolrObserverFactory;
|
|
24 |
import eu.dnetlib.monitoring.core.sensors.collection.kv.redis.RedisObserverFactory;
|
|
25 |
import eu.dnetlib.monitoring.model.SensorConfiguration;
|
17 |
26 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
18 |
27 |
|
19 |
28 |
public class TriggerPrepublicMonitoringScenarioJobNode extends SimpleJobNode {
|
... | ... | |
30 |
39 |
@Resource
|
31 |
40 |
private UniqueServiceLocator serviceLocator;
|
32 |
41 |
|
33 |
|
// private CollectionSensor solrSensor;
|
34 |
|
// private CollectionSensor redisSensor;
|
35 |
|
// private SensorWrapper wrapper;
|
|
42 |
private CollectionSensor solrSensor;
|
|
43 |
private CollectionSensor redisSensor;
|
|
44 |
private SensorWrapper wrapper;
|
36 |
45 |
|
37 |
46 |
@Override
|
38 |
47 |
protected String execute(final NodeToken token) throws IOException, InstantiationException, IllegalAccessException, InterruptedException, ISLookUpException {
|
39 |
48 |
log.info("Execution of TriggerPrepublicMonitoringScenarioJobNode");
|
40 |
49 |
|
41 |
50 |
/* Configuring SOLR sensor */
|
42 |
|
// String conf =
|
43 |
|
// IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/msro/openaireplus/workflows/data-flow-monitoring/solr-conf.json"));
|
44 |
|
// SensorConfiguration solrConf = new SensorConfiguration(new Gson().fromJson(conf, HashMap.class));
|
45 |
|
// String actualCollection = evaluateCurrentSolrCollection();
|
46 |
|
// log.info("At this round, the Pre-public monitoring scenario will check against " + actualCollection + "SOLR collection");
|
47 |
|
// solrConf.setParam("collection", actualCollection);
|
48 |
|
// solrSensor = SensorFactory.createSensorWithConfiguration(CollectionSensor.class, solrConf, new SolrObserverFactory(solrConf),
|
49 |
|
// "solrQueries");
|
|
51 |
String conf =
|
|
52 |
IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/msro/openaireplus/workflows/data-flow-monitoring/solr-conf.json"));
|
|
53 |
SensorConfiguration solrConf = new SensorConfiguration(new Gson().fromJson(conf, HashMap.class));
|
|
54 |
String actualCollection = evaluateCurrentSolrCollection();
|
|
55 |
log.info("At this round, the Pre-public monitoring scenario will check against " + actualCollection + "SOLR collection");
|
|
56 |
solrConf.setParam("collection", actualCollection);
|
|
57 |
solrSensor = SensorFactory.createSensorWithConfiguration(CollectionSensor.class, solrConf, new SolrObserverFactory(solrConf),
|
|
58 |
"solrQueries");
|
50 |
59 |
|
51 |
60 |
/* Configuring Redis sensor */
|
52 |
|
// conf =
|
53 |
|
// IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/msro/openaireplus/workflows/data-flow-monitoring/redis-conf.json"));
|
54 |
|
// SensorConfiguration redisConf = new SensorConfiguration(new Gson().fromJson(conf, HashMap.class));
|
55 |
|
// redisSensor = SensorFactory.createSensorWithConfiguration(CollectionSensor.class, redisConf, new RedisObserverFactory(redisConf),
|
56 |
|
// "redisQueries");
|
57 |
|
//
|
58 |
|
// /* Wrapping the two sensors together */
|
59 |
|
// wrapper = (SensorWrapper) SensorFactory.createSensor(SensorWrapper.class);
|
60 |
|
// wrapper.registerSensor(solrSensor);
|
61 |
|
// wrapper.registerSensor(redisSensor);
|
62 |
|
//
|
63 |
|
// log.info("Measuring prepublic scenario");
|
64 |
|
// wrapper.measure();
|
65 |
|
// log.info("DONE!");
|
|
61 |
conf =
|
|
62 |
IOUtils.toString(getClass().getResourceAsStream("/eu/dnetlib/msro/openaireplus/workflows/data-flow-monitoring/redis-conf.json"));
|
|
63 |
SensorConfiguration redisConf = new SensorConfiguration(new Gson().fromJson(conf, HashMap.class));
|
|
64 |
redisSensor = SensorFactory.createSensorWithConfiguration(CollectionSensor.class, redisConf, new RedisObserverFactory(redisConf),
|
|
65 |
"redisQueries");
|
|
66 |
|
|
67 |
/* Wrapping the two sensors together */
|
|
68 |
wrapper = (SensorWrapper) SensorFactory.createSensor(SensorWrapper.class);
|
|
69 |
wrapper.registerSensor(solrSensor);
|
|
70 |
wrapper.registerSensor(redisSensor);
|
|
71 |
|
|
72 |
log.info("Measuring prepublic scenario");
|
|
73 |
wrapper.measure();
|
|
74 |
log.info("DONE!");
|
66 |
75 |
return Arc.DEFAULT_ARC;
|
67 |
76 |
}
|
68 |
77 |
|
added back the dep to DFM