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:

HBaseAdminFactory.java
1 1
package eu.dnetlib.data.hadoop.hbase;
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.hadoop.hbase.client.HBaseAdmin;
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
import eu.dnetlib.data.hadoop.rmi.HadoopServiceException;
10
public class HBaseAdminFactory extends AbstractHadoopClient {
11 11

  
12
public class HBaseAdminFactory {
13

  
14 12
	private static final Log log = LogFactory.getLog(HBaseAdminFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
15 13

  
16
	@Autowired
17
	private ConfigurationEnumerator configurationEnumerator;
18

  
19 14
	public HBaseAdmin newInstance(final ClusterName clusterName) throws HadoopServiceException {
20 15
		try {
21 16
			log.info("init hbaseAdmin, cluster: " + clusterName.toString());
17
			setHadoopUser();
22 18
			return new HBaseAdmin(configurationEnumerator.get(clusterName));
23 19
		} catch (final Throwable e) {
24
			log.warn("unable to initialize hbase client for cluster: " + clusterName.toString(), e);
25
			return null;
20
			throw new HadoopServiceException("unable to initialize hbase client for cluster: " + clusterName.toString(), e);
26 21
		}
27 22
	}
23

  
28 24
}

Also available in: Unified diff