2021-09-09 12:25:25 +00:00
|
|
|
//go:build !plan9
|
2020-09-28 17:29:44 +00:00
|
|
|
// +build !plan9
|
|
|
|
|
|
|
|
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{{
|
|
|
|
Name: "namenode",
|
|
|
|
Help: "hadoop name node and port",
|
|
|
|
Required: true,
|
|
|
|
Examples: []fs.OptionExample{{
|
|
|
|
Value: "namenode:8020",
|
|
|
|
Help: "Connect to host namenode at port 8020",
|
|
|
|
}},
|
|
|
|
}, {
|
|
|
|
Name: "username",
|
|
|
|
Help: "hadoop user name",
|
|
|
|
Required: false,
|
|
|
|
Examples: []fs.OptionExample{{
|
|
|
|
Value: "root",
|
|
|
|
Help: "Connect to hdfs as root",
|
|
|
|
}},
|
2021-01-16 15:52:08 +00:00
|
|
|
}, {
|
|
|
|
Name: "service_principal_name",
|
|
|
|
Help: `Kerberos service principal name for the namenode
|
|
|
|
|
|
|
|
Enables KERBEROS authentication. Specifies the Service Principal Name
|
2021-07-20 18:36:30 +00:00
|
|
|
(SERVICE/FQDN) for the namenode.`,
|
2021-01-16 15:52:08 +00:00
|
|
|
Required: false,
|
|
|
|
Examples: []fs.OptionExample{{
|
|
|
|
Value: "hdfs/namenode.hadoop.docker",
|
|
|
|
Help: "Namenode running as service 'hdfs' with FQDN 'namenode.hadoop.docker'.",
|
|
|
|
}},
|
|
|
|
Advanced: true,
|
|
|
|
}, {
|
|
|
|
Name: "data_transfer_protection",
|
|
|
|
Help: `Kerberos data transfer protection: authentication|integrity|privacy
|
|
|
|
|
|
|
|
Specifies whether or not authentication, data signature integrity
|
|
|
|
checks, and wire encryption is required when communicating the the
|
|
|
|
datanodes. Possible values are 'authentication', 'integrity' and
|
|
|
|
'privacy'. Used only with KERBEROS enabled.`,
|
|
|
|
Required: false,
|
|
|
|
Examples: []fs.OptionExample{{
|
|
|
|
Value: "privacy",
|
|
|
|
Help: "Ensure authentication, integrity and encryption enabled.",
|
|
|
|
}},
|
|
|
|
Advanced: true,
|
2020-09-28 17:29:44 +00: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 15:52:08 +00: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-28 17:29:44 +00: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)
|
|
|
|
}
|