Project

General

Profile

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

    
3
import org.apache.commons.logging.Log;
4
import org.apache.commons.logging.LogFactory;
5
import org.apache.oozie.client.OozieClient;
6
import org.springframework.beans.factory.annotation.Autowired;
7

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

    
11
/**
12
 * Factory bean for Oozie client instances.
13
 * 
14
 * oozie server may not be available in every hadoop deployment, so every oozie specific operation should be defined as optional.
15
 * 
16
 * @author claudio
17
 * 
18
 */
19
public class OozieClientFactory {
20

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

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

    
25
	@Autowired
26
	private ConfigurationEnumerator configurationEnumerator;
27

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

    
39
}
(1-1/2)