Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
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;
Expand All @@ -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";
Expand Down Expand Up @@ -246,9 +246,7 @@ public BrokerFileSystem getDistributedFileSystem(String path, Map<String, String
// 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);

Expand Down Expand Up @@ -287,9 +285,6 @@ public BrokerFileSystem getDistributedFileSystem(String path, Map<String, String
e.getMessage());
}
}
} else {
throw new BrokerException(TBrokerOperationStatusCode.INVALID_ARGUMENT,
"invalid authentication.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to determine whether the authentication method exists

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The authentication has been checked before, so this is redundant here.

}
if (!Strings.isNullOrEmpty(dfsNameServices)) {
// ha hdfs arguments
Expand Down Expand Up @@ -338,7 +333,20 @@ public BrokerFileSystem getDistributedFileSystem(String path, Map<String, String
}

conf.set(FS_HDFS_IMPL_DISABLE_CACHE, "true");
FileSystem dfsFileSystem = FileSystem.get(pathUri.getUri(), conf);
FileSystem dfsFileSystem = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method compatible with versions of hdfs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version 2.7.3 of package hadoop-common including this method is the same as package hadoop-hdfs.

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;
Expand Down