Project

General

Profile

« Previous | Next » 

Revision 49795

lazy init of hadoop clients allow to define the user for HBase admin and jtClient once. The user is available as service property

View differences:

OozieClientFactory.java
1 1
package eu.dnetlib.data.hadoop.oozie;
2 2

  
3
import eu.dnetlib.data.hadoop.AbstractHadoopClient;
4
import eu.dnetlib.data.hadoop.config.ClusterName;
5
import eu.dnetlib.data.hadoop.rmi.HadoopServiceException;
3 6
import org.apache.commons.logging.Log;
4 7
import org.apache.commons.logging.LogFactory;
5 8
import org.apache.oozie.client.OozieClient;
6
import org.springframework.beans.factory.annotation.Autowired;
7 9

  
8
import eu.dnetlib.data.hadoop.config.ClusterName;
9
import eu.dnetlib.data.hadoop.config.ConfigurationEnumerator;
10

  
11 10
/**
12 11
 * Factory bean for Oozie client instances.
13 12
 * 
......
16 15
 * @author claudio
17 16
 * 
18 17
 */
19
public class OozieClientFactory {
18
public class OozieClientFactory extends AbstractHadoopClient {
20 19

  
21 20
	private static final String ENV_ATTRIBUTE_OOZIE_SERVICE_LOC = "oozie.service.loc";
22 21

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

  
25
	@Autowired
26
	private ConfigurationEnumerator configurationEnumerator;
27

  
28
	public OozieClient newInstance(ClusterName clusterName) {
24
	public OozieClient newInstance(ClusterName clusterName) throws HadoopServiceException {
29 25
		final String oozieServiceLocation = configurationEnumerator.get(clusterName).get(ENV_ATTRIBUTE_OOZIE_SERVICE_LOC);
30 26
		log.info("init oozie client, cluster: " + clusterName.toString() + ", oozie server: " + oozieServiceLocation);
27
		setHadoopUser();
31 28
		try {
32 29
			return new OozieClient(oozieServiceLocation);
33 30
		} catch (Throwable e) {
34
			log.warn("unable to initialize oozie client for cluster: " + clusterName.toString(), e);
35
			return null;
31
			throw new HadoopServiceException("unable to initialize oozie client for cluster: " + clusterName.toString(), e);
36 32
		}
37 33
	}
38 34

  

Also available in: Unified diff