1 |
49795
|
claudio.at
|
package eu.dnetlib.data.hadoop;
|
2 |
|
|
|
3 |
|
|
import eu.dnetlib.data.hadoop.config.ConfigurationEnumerator;
|
4 |
|
|
import eu.dnetlib.data.hadoop.rmi.HadoopServiceException;
|
5 |
|
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
|
6 |
|
|
import org.apache.commons.logging.Log;
|
7 |
|
|
import org.apache.commons.logging.LogFactory;
|
8 |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
9 |
|
|
|
10 |
|
|
public abstract class AbstractHadoopClient {
|
11 |
|
|
|
12 |
|
|
private static final Log log = LogFactory.getLog(AbstractHadoopClient.class);
|
13 |
|
|
|
14 |
|
|
@Autowired
|
15 |
|
|
private ISClient isClient;
|
16 |
|
|
|
17 |
|
|
@Autowired
|
18 |
|
|
protected ConfigurationEnumerator configurationEnumerator;
|
19 |
|
|
|
20 |
|
|
protected void setHadoopUser() throws HadoopServiceException {
|
21 |
|
|
setHadoopUser(getDefaultUser());
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
private String getDefaultUser() throws HadoopServiceException {
|
25 |
|
|
try {
|
26 |
|
|
return isClient.queryForServiceProperty("default.hadoop.user");
|
27 |
|
|
} catch (ISLookUpException e) {
|
28 |
|
|
throw new HadoopServiceException(e);
|
29 |
|
|
}
|
30 |
|
|
}
|
31 |
|
|
|
32 |
|
|
protected void setHadoopUser(final String userName) {
|
33 |
|
|
log.info("setting HADOOP_USER_NAME as " + userName);
|
34 |
|
|
System.setProperty("HADOOP_USER_NAME", userName);
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
}
|