hdfs user

This commit is contained in:
Michele Artini 2021-01-29 15:45:20 +01:00
parent ed92f0a3dd
commit 28788aba95
3 changed files with 16 additions and 1 deletions

View File

@ -164,6 +164,7 @@ public class MDStoreController extends AbstractDnetController {
public Map<String, Object> info() {
final Map<String, Object> info = new LinkedHashMap<>();
info.put("number_of_mdstores", databaseUtils.countMdStores());
info.put("hadoop_user", hdfsClient.getHadoopUser());
info.put("hadoop_cluster", hdfsClient.getHadoopCluster());
info.put("hdfs_base_path", databaseUtils.getHdfsBasePath());
info.put("expired_versions", databaseUtils.listExpiredVersions());

View File

@ -18,11 +18,16 @@ public class HdfsClient {
@Value("${dhp.mdstore-manager.hadoop.cluster}")
private String hadoopCluster;
@Value("${dhp.mdstore-manager.hadoop.user}")
private String hadoopUser;
private static final Log log = LogFactory.getLog(HdfsClient.class);
public void deletePath(final String path) throws MDStoreManagerException {
final Configuration conf = new Configuration();
System.setProperty("HADOOP_USER_NAME", hadoopUser);
if (hadoopCluster.equalsIgnoreCase("OCEAN")) {
conf.addResource(getClass().getResourceAsStream("/hadoop/OCEAN/core-site.xml"));
conf.addResource(getClass().getResourceAsStream("/hadoop/OCEAN/ocean-hadoop-conf.xml"));
@ -36,7 +41,7 @@ public class HdfsClient {
try (final FileSystem fs = FileSystem.get(conf)) {
fs.delete(new Path(path), true);
log.info("HDFS Pathe deleted: " + path);
log.info("HDFS Path deleted: " + path);
} catch (IllegalArgumentException | IOException e) {
log.error("Eror deleting path: " + path, e);
throw new MDStoreManagerException("Eror deleting path: " + path, e);
@ -50,4 +55,12 @@ public class HdfsClient {
public void setHadoopCluster(final String hadoopCluster) {
this.hadoopCluster = hadoopCluster;
}
public String getHadoopUser() {
return hadoopUser;
}
public void setHadoopUser(final String hadoopUser) {
this.hadoopUser = hadoopUser;
}
}

View File

@ -24,3 +24,4 @@ logging.level.io.swagger.models.parameters.AbstractSerializableParameter = error
# Hadoop
dhp.mdstore-manager.hadoop.cluster = GARR
dhp.mdstore-manager.hdfs.base-path = /tmp/mdstoremanager_dev
dhp.mdstore-manager.hadoop.user = dnet.dev