Project

General

Profile

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

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

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

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

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

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

    
35
}
(1-1/2)