# README
webhdfs
- Hadoop WebHDFS REST API(2.4.1) client library for Golang with S3-like interface.
- HttpFS HTTP web-service API([2.4.1(https://hadoop.apache.org/docs/r2.4.1/hadoop-hdfs-httpfs/index.html)]) calls are HTTP REST calls that map to a HDFS file system operation.
- Kerberos Authentication supported.
Examples
- More examples can be found in client_test.go.
- Write the file to HDFS and read the file back:
package main
import (
"io/ioutil"
"log"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/searKing/webhdfs"
)
const (
webHdfsEndpoint = "quickstart.cloudera:50070"
KerberosRealm = "CLOUDERA"
KerberosUsername = "hdfs/quickstart.cloudera"
KerberosServicePrincipleName = "HTTP/quickstart.cloudera"
KerberosConfigFile = "/etc/krb5.conf"
// pick one auth way by 3 ways below, if all below are empty, kerberos is disabled.
KerberosPassword = ""
KerberosKeyTabFile = "/hdfs.keytab" // /krb5.keytab
KerberosCCacheFile = "/tmp/krb5cc_0" // /tmp/krb5cc_0
)
func getClient() *webhdfs.Client {
c, err := webhdfs.New(webHdfsEndpoint, webhdfs.WithDisableSSL(true),
webhdfs.WithKerberosKeytabFile(KerberosUsername, KerberosServicePrincipleName, KerberosRealm, KerberosKeyTabFile, KerberosConfigFile))
if err != nil {
log.Fatalf("create client %s", err)
}
return c
}
func main() {
file := "/data/test/sample.txt"
{ // upload from hdfs
resp, err := getClient().Create(&webhdfs.CreateRequest{
Path: aws.String(file),
Body: strings.NewReader("test_input"),
Overwrite: aws.Bool(true),
})
if err != nil {
log.Fatalf("webhdfs Open failed: %s", err)
}
defer resp.Body.Close()
}
{ // download from hdfs
resp, err := getClient().Open(&webhdfs.OpenRequest{
Path: aws.String(file),
})
if err != nil {
t.Fatalf("webhdfs Open failed: %s", err)
}
defer resp.Body.Close()
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalf("webhdfs Read failed: %s", err)
}
log.Printf("content: %s", string(content))
}
}
TODO
- Improve documentation
- More examples
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewConfig returns a Config struct with the default values.
ParseXAttrNamespaceString retrieves an enum value from the enum constants string name.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
XAttrNamespaceSliceContains reports whether sunEnums is within enums.
XAttrNamespaceSliceContainsAny reports whether any sunEnum is within enums.
XAttrNamespaceValues returns all values of the enum.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
HTTP Query Parameter Dictionary.
HTTP Query Parameter Dictionary.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
raw.
security.
system.
trusted.
user.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Authentication When security is off, the authenticated user is the username specified in the user.name query parameter.
JavaScript syntax is used to define blockLocationProperties so that it can be referred in both BlockLocation and BlockLocations JSON schemas.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#BlockLocations_JSON_Schema.
See:https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#BlockStoragePolicies_JSON_Schema.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#BlockStoragePolicy_JSON_Schema.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#BlockStoragePolicy_Properties.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
go:generate go-option -type "Client".
No description provided by the author
No description provided by the author
No description provided by the author
Config Code borrowed from https://github.com/kubernetes/kubernetes call chains: NewConfig -> Complete -> [Validate] -> New|Apply.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#ContentSummary_JSON_Schema.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Cross-Site_Request_Forgery_Prevention.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#DiffReport_Entries.
A DirectoryListing JSON object represents a batch of directory entries while iteratively listing a directory.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#ECPolicy_JSON_Schema.
No description provided by the author
EmptyClientOption does not alter the configuration.
No description provided by the author
No description provided by the author
https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Error_Responses.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#FileChecksum_JSON_Schema.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#FileStatuses_JSON_Schema.
JavaScript syntax is used to define fileStatusProperties so that it can be referred in both FileStatus and FileStatuses JSON schemas.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
See also: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Get_Delegation_Token.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Proxy_Users.
See also: http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsQuotaAdminGuide.html for more information.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#QuotaUsage_JSON_Schema.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#RemoteException_JSON_Schema.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#SnapshotDiffReport_JSON_Schema.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#SnapshottableDirectoryStatus.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Token_JSON_Schema.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
A ClientOption sets options.
No description provided by the author
No description provided by the author
# Type aliases
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#BlockLocation_JSON_Schema.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Boolean_JSON_Schema.
ClientOptionFunc wraps a function that modifies Client into an implementation of the ClientOption interface.
No description provided by the author
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#FileStatus_JSON_Schema.
No description provided by the author
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Long_JSON_Schema.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Path_JSON_Schema.
The permission of a file/directory.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#SnapshottableDirectoryList_JSON_Schema.
No description provided by the author
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#XAttrNames_JSON_Schema.
XAttr Name The XAttr name of a file/directory.
See: https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#XAttrs_JSON_Schema.
XAttr set flag The XAttr set flag.
The XAttr value encoding.