提交 de5736be 编写于 作者: L lgcareer

add

上级 e4bed69c
......@@ -70,6 +70,11 @@ public final class Constants {
*/
public static final String YARN_APPLICATION_STATUS_ADDRESS = "yarn.application.status.address";
/**
* hdfs configuration
* hdfs.root.user
*/
public static final String HDFS_ROOT_USER = "hdfs.root.user";
/**
* hdfs configuration
......
......@@ -35,6 +35,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -63,6 +66,30 @@ public class HadoopUtils implements Closeable {
return instance;
}
/**
* init escheduler root path in hdfs
*/
private void initHdfsPath(){
String hdfsUser = getString(Constants.HDFS_ROOT_USER);
String hdfsPath = getString(Constants.DATA_STORE_2_HDFS_BASEPATH);
Path path = new Path(hdfsPath);
try {
UserGroupInformation ugi = UserGroupInformation.createProxyUser(hdfsUser,UserGroupInformation.getLoginUser());
ugi.doAs(new PrivilegedExceptionAction<Boolean>() {
@Override
public Boolean run() throws Exception {
if(!fs.exists(path)){
return fs.mkdirs(path);
}
return true;
}
});
} catch (Exception e) {
logger.error(e.getMessage(),e);
}
}
/**
* init hadoop configuration
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册