You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by zh...@apache.org on 2020/04/06 14:15:48 UTC
[incubator-doris] branch master updated: Fix the bug that
'username' in broker load is invalid (#3237)
This is an automated email from the ASF dual-hosted git repository.
zhaoc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 79bac50 Fix the bug that 'username' in broker load is invalid (#3237)
79bac50 is described below
commit 79bac5036111d6bd63339f3ca9c35925fe376023
Author: frwrdt <38...@users.noreply.github.com>
AuthorDate: Mon Apr 6 22:15:37 2020 +0800
Fix the bug that 'username' in broker load is invalid (#3237)
---
.../doris/broker/hdfs/FileSystemManager.java | 24 ++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/FileSystemManager.java b/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/FileSystemManager.java
index e801340..1d377b1 100644
--- a/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/FileSystemManager.java
+++ b/fs_brokers/apache_hdfs_broker/src/main/java/org/apache/doris/broker/hdfs/FileSystemManager.java
@@ -46,6 +46,7 @@ import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
@@ -65,7 +66,6 @@ public class FileSystemManager {
private static final String HDFS_SCHEME = "hdfs";
private static final String S3A_SCHEME = "s3a";
- private static final String HDFS_UGI_CONF = "hadoop.job.ugi";
private static final String USER_NAME_KEY = "username";
private static final String PASSWORD_KEY = "password";
private static final String AUTHENTICATION_SIMPLE = "simple";
@@ -246,9 +246,7 @@ public class FileSystemManager {
// TODO get this param from properties
// conf.set("dfs.replication", "2");
String tmpFilePath = null;
- if (authentication.equals(AUTHENTICATION_SIMPLE)) {
- conf.set(HDFS_UGI_CONF, hdfsUgi);
- } else if (authentication.equals(AUTHENTICATION_KERBEROS)){
+ if (authentication.equals(AUTHENTICATION_KERBEROS)){
conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
AUTHENTICATION_KERBEROS);
@@ -287,9 +285,6 @@ public class FileSystemManager {
e.getMessage());
}
}
- } else {
- throw new BrokerException(TBrokerOperationStatusCode.INVALID_ARGUMENT,
- "invalid authentication.");
}
if (!Strings.isNullOrEmpty(dfsNameServices)) {
// ha hdfs arguments
@@ -338,7 +333,20 @@ public class FileSystemManager {
}
conf.set(FS_HDFS_IMPL_DISABLE_CACHE, "true");
- FileSystem dfsFileSystem = FileSystem.get(pathUri.getUri(), conf);
+ FileSystem dfsFileSystem = null;
+ if (authentication.equals(AUTHENTICATION_SIMPLE) &&
+ properties.containsKey(USER_NAME_KEY)) {
+ // Use the specified 'username' as the login name
+ UserGroupInformation ugi = UserGroupInformation.createRemoteUser(username);
+ dfsFileSystem = ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {
+ @Override
+ public FileSystem run() throws Exception {
+ return FileSystem.get(pathUri.getUri(), conf);
+ }
+ });
+ } else {
+ dfsFileSystem = FileSystem.get(pathUri.getUri(), conf);
+ }
fileSystem.setFileSystem(dfsFileSystem);
}
return fileSystem;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org