Project

General

Profile

1
package eu.dnetlib.msro.openaireplus.workflows.nodes;
2

    
3
import javax.annotation.Resource;
4

    
5
import com.googlecode.sarasvati.Arc;
6
import com.googlecode.sarasvati.NodeToken;
7
import eu.dnetlib.data.hadoop.config.ClusterName;
8
import eu.dnetlib.data.hadoop.config.ConfigurationEnumerator;
9
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
10
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
11
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
12
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
13
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
14
import org.apache.commons.logging.Log;
15
import org.apache.commons.logging.LogFactory;
16
import org.apache.hadoop.conf.Configuration;
17

    
18
public class PrepareStatsParamJobNode extends SimpleJobNode {
19

    
20
	/**
21
	 * logger.
22
	 */
23
	private static final Log log = LogFactory.getLog(PrepareStatsParamJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
24

    
25
	private static final String xqueryIsLookupEndpoint =
26
			"//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value='IS_LookUpServiceResourceType']//PROTOCOL[./@name='SOAP']/@address/string()";
27

    
28
	@Resource
29
	private UniqueServiceLocator serviceLocator;
30

    
31
	@Resource
32
	protected ConfigurationEnumerator configurationEnumerator;
33

    
34
	@Override
35
	protected String execute(final NodeToken token) throws Exception {
36

    
37
		log.info("prepare stats update job");
38

    
39
		Configuration conf = configurationEnumerator.get(ClusterName.DM);
40
		String nameNode = conf.get("fs.defaultFS");
41

    
42
		token.getEnv().setAttribute("nameNode", nameNode);
43
		token.getEnv().setAttribute("jobTracker", conf.get("mapred.job.tracker"));
44

    
45
		token.getEnv().setAttribute("isLookupEndpoint", getIsLookupEndpoint());
46

    
47
		return Arc.DEFAULT_ARC;
48
	}
49

    
50
	private String getIsLookupEndpoint() throws ISLookUpDocumentNotFoundException, ISLookUpException {
51
		return serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xqueryIsLookupEndpoint);
52
	}
53

    
54
}
(19-19/24)