2019-04-03 16:05:16 +02:00
|
|
|
package eu.dnetlib.collector.worker;
|
|
|
|
|
2019-10-02 14:45:12 +02:00
|
|
|
import eu.dnetlib.collector.worker.utils.CollectorPluginFactory;
|
2019-10-03 12:22:44 +02:00
|
|
|
import eu.dnetlib.dhp.application.ArgumentApplicationParser;
|
2019-04-11 15:39:29 +02:00
|
|
|
import eu.dnetlib.message.MessageManager;
|
2019-10-03 12:22:44 +02:00
|
|
|
import org.apache.commons.io.IOUtils;
|
2019-04-03 16:05:16 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DnetCollectortWorkerApplication is the main class responsible to start
|
|
|
|
* the Dnet Collection into HDFS.
|
|
|
|
* This module will be executed on the hadoop cluster and taking in input some parameters
|
|
|
|
* that tells it which is the right collector plugin to use and where store the data into HDFS path
|
|
|
|
*
|
|
|
|
* @author Sandro La Bruzzo
|
|
|
|
*/
|
|
|
|
|
2019-10-02 14:45:12 +02:00
|
|
|
public class DnetCollectorWorkerApplication {
|
2019-04-03 16:05:16 +02:00
|
|
|
|
2019-10-02 14:45:12 +02:00
|
|
|
private static final Logger log = LoggerFactory.getLogger(DnetCollectorWorkerApplication.class);
|
2019-04-16 12:28:01 +02:00
|
|
|
|
2019-10-02 14:45:12 +02:00
|
|
|
private static CollectorPluginFactory collectorPluginFactory = new CollectorPluginFactory();
|
2019-04-03 16:05:16 +02:00
|
|
|
|
2019-10-03 12:22:44 +02:00
|
|
|
private static ArgumentApplicationParser argumentParser;
|
2019-04-16 12:28:01 +02:00
|
|
|
|
2019-04-11 15:39:29 +02:00
|
|
|
|
2019-10-02 14:45:12 +02:00
|
|
|
/**
|
|
|
|
* @param args
|
|
|
|
*/
|
|
|
|
public static void main(final String[] args) throws Exception {
|
2019-04-03 16:05:16 +02:00
|
|
|
|
2019-10-03 12:22:44 +02:00
|
|
|
argumentParser= new ArgumentApplicationParser(IOUtils.toString(DnetCollectorWorker.class.getResourceAsStream("/eu/dnetlib/collector/worker/collector_parameter.json")));
|
2019-10-02 14:45:12 +02:00
|
|
|
argumentParser.parseArgument(args);
|
2019-10-03 12:22:44 +02:00
|
|
|
log.info("hdfsPath =" + argumentParser.get("hdfsPath"));
|
|
|
|
log.info("json = " + argumentParser.get("apidescriptor"));
|
|
|
|
final MessageManager manager = new MessageManager(argumentParser.get("rabbitHost"), argumentParser.get("rabbitUser"), argumentParser.get("rabbitPassword"), false, false, null);
|
2019-10-02 14:45:12 +02:00
|
|
|
final DnetCollectorWorker worker = new DnetCollectorWorker(collectorPluginFactory, argumentParser, manager);
|
|
|
|
worker.collect();
|
2019-04-11 15:39:29 +02:00
|
|
|
|
2019-04-03 16:05:16 +02:00
|
|
|
|
2019-10-02 14:45:12 +02:00
|
|
|
}
|
2019-04-11 15:39:29 +02:00
|
|
|
|
2019-04-03 16:05:16 +02:00
|
|
|
|
|
|
|
}
|