1 |
36217
|
andrea.man
|
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 |
39139
|
andrea.man
|
import eu.dnetlib.monitoring.core.sensors.SensorCreationException;
|
11 |
36275
|
andrea.man
|
import eu.dnetlib.monitoring.core.sensors.SensorFactory;
|
12 |
36392
|
andrea.man
|
import eu.dnetlib.monitoring.core.sensors.collection.index.solr.SolrSensor;
|
13 |
36217
|
andrea.man
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
14 |
42353
|
alessia.ba
|
import org.apache.commons.logging.Log;
|
15 |
|
|
import org.apache.commons.logging.LogFactory;
|
16 |
36217
|
andrea.man
|
|
17 |
42353
|
alessia.ba
|
public class TriggerIndexMonitoringScenarioJobNode extends SimpleJobNode {
|
18 |
36217
|
andrea.man
|
|
19 |
42353
|
alessia.ba
|
private static final Log log = LogFactory.getLog(TriggerIndexMonitoringScenarioJobNode.class);
|
20 |
|
|
private static final String SOLR_COLLECTION_POSTFIX = "-index-openaire";
|
21 |
36217
|
andrea.man
|
|
22 |
|
|
@Resource
|
23 |
|
|
private UniqueServiceLocator serviceLocator;
|
24 |
42353
|
alessia.ba
|
private String mdFormat;
|
25 |
36392
|
andrea.man
|
private SolrSensor solrSensor;
|
26 |
36217
|
andrea.man
|
|
27 |
|
|
@Override
|
28 |
39139
|
andrea.man
|
protected String execute(final NodeToken token) throws IOException, InstantiationException, IllegalAccessException, InterruptedException,
|
29 |
42353
|
alessia.ba
|
ISLookUpException, SensorCreationException {
|
30 |
36217
|
andrea.man
|
|
31 |
|
|
/* Configuring SOLR sensor */
|
32 |
38275
|
andrea.man
|
String actualCollection = mdFormat + SOLR_COLLECTION_POSTFIX;
|
33 |
42353
|
alessia.ba
|
log.info("Executing on " + actualCollection + " SOLR collection");
|
34 |
|
|
solrSensor = (SolrSensor) SensorFactory.createSensorWithConfiguration(SolrSensor.class, "index", "solr2");
|
35 |
36392
|
andrea.man
|
solrSensor.getConfiguration().setParam("collection", actualCollection);
|
36 |
38299
|
andrea.man
|
solrSensor.reinitialize();
|
37 |
42353
|
alessia.ba
|
log.info("Measuring...");
|
38 |
|
|
solrSensor.measure();
|
39 |
36275
|
andrea.man
|
log.info("DONE!");
|
40 |
36217
|
andrea.man
|
return Arc.DEFAULT_ARC;
|
41 |
|
|
}
|
42 |
|
|
|
43 |
38275
|
andrea.man
|
public String getMdFormat() {
|
44 |
|
|
return mdFormat;
|
45 |
36217
|
andrea.man
|
}
|
46 |
|
|
|
47 |
38275
|
andrea.man
|
public void setMdFormat(final String mdFormat) {
|
48 |
|
|
this.mdFormat = mdFormat;
|
49 |
36217
|
andrea.man
|
}
|
50 |
|
|
|
51 |
|
|
}
|