2021-09-09 20:25:25 +08:00
|
|
|
//go:build !plan9
|
2020-09-29 01:29:44 +08:00
|
|
|
// +build !plan9
|
|
|
|
|
2022-08-28 19:21:57 +08:00
|
|
|
// Package hdfs provides an interface to the HDFS storage system.
|
2020-09-29 01:29:44 +08:00
|
|
|
package hdfs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/rclone/rclone/fs"
|
|
|
|
"github.com/rclone/rclone/fs/config"
|
|
|
|
"github.com/rclone/rclone/lib/encoder"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
fsi := &fs.RegInfo{
|
|
|
|
Name: "hdfs",
|
|
|
|
Description: "Hadoop distributed file system",
|
|
|
|
NewFs: NewFs,
|
|
|
|
Options: []fs.Option{{
|
2023-07-07 00:55:53 +08:00
|
|
|
Name: "namenode",
|
|
|
|
Help: "Hadoop name node and port.\n\nE.g. \"namenode:8020\" to connect to host namenode at port 8020.",
|
|
|
|
Required: true,
|
|
|
|
Sensitive: true,
|
2020-09-29 01:29:44 +08:00
|
|
|
}, {
|
2021-08-23 00:39:38 +08:00
|
|
|
Name: "username",
|
|
|
|
Help: "Hadoop user name.",
|
2020-09-29 01:29:44 +08:00
|
|
|
Examples: []fs.OptionExample{{
|
|
|
|
Value: "root",
|
2021-08-16 17:30:01 +08:00
|
|
|
Help: "Connect to hdfs as root.",
|
2020-09-29 01:29:44 +08:00
|
|
|
}},
|
2023-07-07 00:55:53 +08:00
|
|
|
Sensitive: true,
|
2021-01-16 23:52:08 +08:00
|
|
|
}, {
|
|
|
|
Name: "service_principal_name",
|
2021-08-16 17:30:01 +08:00
|
|
|
Help: `Kerberos service principal name for the namenode.
|
2021-01-16 23:52:08 +08:00
|
|
|
|
|
|
|
Enables KERBEROS authentication. Specifies the Service Principal Name
|
2021-08-22 21:11:41 +08:00
|
|
|
(SERVICE/FQDN) for the namenode. E.g. \"hdfs/namenode.hadoop.docker\"
|
|
|
|
for namenode running as service 'hdfs' with FQDN 'namenode.hadoop.docker'.`,
|
2023-07-07 00:55:53 +08:00
|
|
|
Advanced: true,
|
|
|
|
Sensitive: true,
|
2021-01-16 23:52:08 +08:00
|
|
|
}, {
|
|
|
|
Name: "data_transfer_protection",
|
2021-08-16 17:30:01 +08:00
|
|
|
Help: `Kerberos data transfer protection: authentication|integrity|privacy.
|
2021-01-16 23:52:08 +08:00
|
|
|
|
|
|
|
Specifies whether or not authentication, data signature integrity
|
2023-03-25 15:58:44 +08:00
|
|
|
checks, and wire encryption are required when communicating with
|
|
|
|
the datanodes. Possible values are 'authentication', 'integrity'
|
|
|
|
and 'privacy'. Used only with KERBEROS enabled.`,
|
2021-01-16 23:52:08 +08:00
|
|
|
Examples: []fs.OptionExample{{
|
|
|
|
Value: "privacy",
|
|
|
|
Help: "Ensure authentication, integrity and encryption enabled.",
|
|
|
|
}},
|
|
|
|
Advanced: true,
|
2020-09-29 01:29:44 +08:00
|
|
|
}, {
|
|
|
|
Name: config.ConfigEncoding,
|
|
|
|
Help: config.ConfigEncodingHelp,
|
|
|
|
Advanced: true,
|
|
|
|
Default: (encoder.Display | encoder.EncodeInvalidUtf8 | encoder.EncodeColon),
|
|
|
|
}},
|
|
|
|
}
|
|
|
|
fs.Register(fsi)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Options for this backend
|
|
|
|
type Options struct {
|
2021-01-16 23:52:08 +08:00
|
|
|
Namenode string `config:"namenode"`
|
|
|
|
Username string `config:"username"`
|
|
|
|
ServicePrincipalName string `config:"service_principal_name"`
|
|
|
|
DataTransferProtection string `config:"data_transfer_protection"`
|
|
|
|
Enc encoder.MultiEncoder `config:"encoding"`
|
2020-09-29 01:29:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// xPath make correct file path with leading '/'
|
|
|
|
func xPath(root string, tail string) string {
|
|
|
|
if !strings.HasPrefix(root, "/") {
|
|
|
|
root = "/" + root
|
|
|
|
}
|
|
|
|
return path.Join(root, tail)
|
|
|
|
}
|