Project

General

Profile

1
package eu.dnetlib.data.hadoop.action;
2

    
3
import org.apache.commons.logging.Log;
4
import org.apache.commons.logging.LogFactory;
5
import org.springframework.beans.factory.annotation.Required;
6

    
7
import eu.dnetlib.data.hadoop.config.ClusterName;
8
import eu.dnetlib.data.hadoop.hbase.HbaseTableFeeder;
9
import eu.dnetlib.data.hadoop.rmi.HadoopServiceException;
10
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
11
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
12
import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
13

    
14
public class ImportEprHbaseAction extends AbstractHadoopAction {
15

    
16
	private static final Log log = LogFactory.getLog(ImportEprHbaseAction.class); // NOPMD by marko on 11/24/08 5:02 PM
17

    
18
	private HbaseTableFeeder hbaseTableFeeder;
19

    
20
	@Override
21
	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws HadoopServiceException {
22

    
23
		final String epr = DnetXsltFunctions.decodeBase64(job.getParameters().get("input_epr"));
24
		final String xsl = DnetXsltFunctions.decodeBase64(job.getParameters().get("xslt"));
25
		final ClusterName clusterName = ClusterName.valueOf(job.getParameters().get("cluster"));
26
		final String table = job.getParameters().get("table");
27
		final boolean simulation = Boolean.valueOf(job.getParameters().get("simulation"));
28

    
29
		log.info("Starting import in table " + table);
30

    
31
		try {
32
			final Integer count = getHbaseTableFeeder().feed(epr, xsl, clusterName, table, simulation);
33

    
34
			if (count != null) {
35
				log.info("Import completed successfully");
36
				job.getParameters().put("count", String.valueOf(count));
37
			}
38

    
39
			handler.done(job);
40
		} catch (final Throwable e) {
41
			log.error("Import failed", e);
42
			throw new HadoopServiceException("Import failed", e);
43
		}
44
	}
45

    
46
	public HbaseTableFeeder getHbaseTableFeeder() {
47
		return hbaseTableFeeder;
48
	}
49

    
50
	@Required
51
	public void setHbaseTableFeeder(final HbaseTableFeeder hbaseTableFeeder) {
52
		this.hbaseTableFeeder = hbaseTableFeeder;
53
	}
54

    
55
}
(5-5/13)