Skip to content

Commit

Permalink
支持hdfs配置UseDatanodeHostname (PaddlePaddle#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
mountainhua authored Apr 10, 2024
1 parent 0038a39 commit 9828d8f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkg/fs/client/ufs/hdfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,10 @@ func NewHdfsFileSystem(properties map[string]interface{}) (UnderFileStorage, err
options := hdfs.ClientOptions{
Addresses: strings.Split(nameNodeAddress, ","),
}
useDatanodeHostname, ok := properties[common.UseDatanodeHostname].(bool)
if ok && useDatanodeHostname {
options.UseDatanodeHostname = true
}
options.User = properties[common.UserKey].(string)
cli, err := hdfs.NewClient(options)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/fs/client/ufs/hdfs_kerberos.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func NewHdfsWithKerberosFileSystem(properties map[string]interface{}) (UnderFile
options := hdfs.ClientOptions{
Addresses: strings.Split(nameNodeAddress, ","),
}
useDatanodeHostname, ok := properties[common.UseDatanodeHostname].(bool)
if ok && useDatanodeHostname {
options.UseDatanodeHostname = true
}
krbConfig, _ := buildKerberosConf(properties)
if krbClient, err := NewKerberosClientWithKeyTab(krbConfig); err == nil {
options.KerberosClient = krbClient
Expand Down
9 changes: 5 additions & 4 deletions pkg/fs/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ const (
Type = "type"

// HDFS properties
NameNodeAddress = "dfs.namenode.address"
UserKey = "user"
BlockSizeKey = "blockSize"
ReplicationKey = "replication"
NameNodeAddress = "dfs.namenode.address"
UseDatanodeHostname = "dfs.client.use.datanode.hostname"
UserKey = "user"
BlockSizeKey = "blockSize"
ReplicationKey = "replication"

Sts = "sts"
Token = "token"
Expand Down

0 comments on commit 9828d8f

Please sign in to comment.