Documentation ¶
Overview ¶
gowfs is Go bindings for the Hadoop HDFS over its WebHDFS interface. gowfs uses JSON marshalling to expose typed values from HDFS. See https://github.com/vladimirvivien/gowfs.
Index ¶
- Constants
- func Backoff(coef float64) func(time.Duration) time.Duration
- func Retries(tries int, delay time.Duration, backoff func(time.Duration) time.Duration) func() []time.Duration
- type Configuration
- type ContentSummary
- type FileChecksum
- type FileStatus
- type FileStatuses
- type FileSystem
- func (fs *FileSystem) Append(data io.Reader, p Path, buffersize int, contenttype string) (bool, error)
- func (fs *FileSystem) CancelDelegationToken(token string) (bool, error)
- func (fs *FileSystem) Concat(target Path, sources []string) (bool, error)
- func (fs *FileSystem) Create(data io.Reader, p Path, overwrite bool, blocksize uint64, replication uint16, ...) (bool, error)
- func (fs *FileSystem) CreateSymlink(dest Path, link Path, createParent bool) (bool, error)
- func (fs *FileSystem) Delete(path Path, recursive bool) (bool, error)
- func (fs *FileSystem) GetContentSummary(p Path) (ContentSummary, error)
- func (fs *FileSystem) GetDelegationToken(renewer string) (Token, error)
- func (fs *FileSystem) GetDelegationTokens(renewer string) ([]Token, error)
- func (fs *FileSystem) GetFileChecksum(p Path) (FileChecksum, error)
- func (fs *FileSystem) GetFileStatus(p Path) (FileStatus, error)
- func (fs *FileSystem) GetHomeDirectory() (Path, error)
- func (fs *FileSystem) ListStatus(p Path) ([]FileStatus, error)
- func (fs *FileSystem) MkDirs(p Path, fm os.FileMode) (bool, error)
- func (fs *FileSystem) Open(p Path, offset, length int64, buffSize int) (io.ReadCloser, error)
- func (fs *FileSystem) Rename(source Path, destination Path) (bool, error)
- func (fs *FileSystem) RenewDelegationToken(token string) (int64, error)
- func (fs *FileSystem) SetOwner(path Path, owner string, group string) (bool, error)
- func (fs *FileSystem) SetPermission(path Path, permission os.FileMode) (bool, error)
- func (fs *FileSystem) SetReplication(path Path, replication uint16) (bool, error)
- func (fs *FileSystem) SetTimes(path Path, accesstime int64, modificationtime int64) (bool, error)
- type FsShell
- func (shell FsShell) AppendToFile(filePaths []string, hdfsPath string, contenttype string) (bool, error)
- func (shell FsShell) Cat(hdfsPaths []string, writr io.Writer) error
- func (shell FsShell) Chgrp(hdfsPaths []string, grpName string) (bool, error)
- func (shell FsShell) Chmod(hdfsPaths []string, perm os.FileMode) (bool, error)
- func (shell FsShell) Chown(hdfsPaths []string, owner string) (bool, error)
- func (shell FsShell) Exists(hdfsPath string) (bool, error)
- func (shell FsShell) Get(hdfsPath, localFile string) (bool, error)
- func (shell FsShell) MoveFromLocal(localFile, hdfsPath string, overwrite bool) (bool, error)
- func (shell FsShell) MoveToLocal(hdfsPath, localFile string) (bool, error)
- func (shell FsShell) Put(localFile string, hdfsPath string, overwrite bool) (bool, error)
- func (shell FsShell) PutMany(files []string, hdfsPath string, overwrite bool) (bool, error)
- func (shell FsShell) Rm(hdfsPath string) (bool, error)
- type HdfsJsonData
- type Path
- type RemoteException
- type Token
- type Tokens
Constants ¶
const ( OP_OPEN = "OPEN" OP_CREATE = "CREATE" OP_APPEND = "APPEND" OP_CONCAT = "CONCAT" OP_RENAME = "RENAME" OP_DELETE = "DELETE" OP_SETPERMISSION = "SETPERMISSION" OP_SETOWNER = "SETOWNER" OP_SETREPLICATION = "SETREPLICATION" OP_SETTIMES = "SETTIMES" OP_MKDIRS = "MKDIRS" OP_CREATESYMLINK = "CREATESYMLINK" OP_LISTSTATUS = "LISTSTATUS" OP_GETFILESTATUS = "GETFILESTATUS" OP_GETCONTENTSUMMARY = "GETCONTENTSUMMARY" OP_GETFILECHECKSUM = "GETFILECHECKSUM" OP_GETDELEGATIONTOKEN = "GETDELEGATIONTOKEN" OP_GETDELEGATIONTOKENS = "GETDELEGATIONTOKENS" OP_RENEWDELEGATIONTOKEN = "RENEWDELEGATIONTOKEN" OP_CANCELDELEGATIONTOKEN = "CANCELDELEGATIONTOKEN" )
const MAX_DOWN_CHUNK int64 = 500 * (1024 * 1024) // 500 MB
const MAX_UP_CHUNK int64 = 1 * (1024 * 1024) * 1024 // 1 GB.
const WebHdfsVer string = "/webhdfs/v1"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Configuration ¶
type Configuration struct { Addr string // host:port BasePath string // initial base path to be appended User string // user.name to use to connect Password string ConnectionTimeout time.Duration DisableKeepAlives bool DisableCompression bool ResponseHeaderTimeout time.Duration MaxIdleConnsPerHost int UseBaseAuth bool UseHTTPS bool TLSClientSkipSecurity bool Retries func() []time.Duration }
func NewConfiguration ¶
func NewConfiguration() *Configuration
func (*Configuration) GetNameNodeUrl ¶
func (conf *Configuration) GetNameNodeUrl() (*url.URL, error)
type ContentSummary ¶
type ContentSummary struct { DirectoryCount int64 FileCount int64 Length int64 Quota int64 SpaceConsumed int64 SpaceQuota int64 }
Type for HDFS FileSystem content summary (FileSystem.getContentSummary()) See http://hadoop.apache.org/docs/r2.2.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#ContentSummary_JSON_Schema
Example:
{ "ContentSummary": { "directoryCount": 2, "fileCount" : 1, "length" : 24930, "quota" : -1, "spaceConsumed" : 24930, "spaceQuota" : -1 } }
type FileChecksum ¶
Type for HDFS FileSystem.getFileChecksum() See http://hadoop.apache.org/docs/r2.2.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#FileChecksum_JSON_Schema
Example:
{ "FileChecksum": { "algorithm": "MD5-of-1MD5-of-512CRC32", "bytes" : "eadb10de24aa315748930df6e185c0d ...", "length" : 28 } }
type FileStatus ¶
type FileStatus struct { AccesTime int64 BlockSize int64 Group string Length int64 ModificationTime int64 Owner string PathSuffix string Permission string Replication int64 Type string }
Represents HDFS FileStatus (FileSystem.getStatus()) See http://hadoop.apache.org/docs/r2.2.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#FileStatus_JSON_Schema
Example:
{ "FileStatus": { "accessTime" : 0, // integer "blockSize" : 0, // integer "group" : "grp", // string "length" : 0, // integer - zero for directories "modificationTime": 1320173277227, // integer "owner" : "webuser", // string "pathSuffix" : "", // string "permission" : "777", // string "replication" : 0, // integer "type" : "DIRECTORY" // string - enum {FILE, DIRECTORY, SYMLINK} } }
type FileStatuses ¶
type FileStatuses struct {
FileStatus []FileStatus
}
Container type for multiple FileStatus for directory, etc (see HDFS FileSystem.listStatus()) NOTE: the confusing naming and Plurality is to match WebHDFS schema.
type FileSystem ¶
type FileSystem struct { Config Configuration // contains filtered or unexported fields }
This type maps fields and functions to HDFS's FileSystem class.
func NewFileSystem ¶
func NewFileSystem(conf Configuration) (*FileSystem, error)
func (*FileSystem) Append ¶
func (fs *FileSystem) Append(data io.Reader, p Path, buffersize int, contenttype string) (bool, error)
Appends specified data to an existing file. See HDFS FileSystem.append() See http://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Append_to_a_File NOTE: Append() is known to have issues - see https://issues.apache.org/jira/browse/HDFS-4600
func (*FileSystem) CancelDelegationToken ¶
func (fs *FileSystem) CancelDelegationToken(token string) (bool, error)
func (*FileSystem) Concat ¶
func (fs *FileSystem) Concat(target Path, sources []string) (bool, error)
Concatenate (on the server) a list of given files paths to a new file. See HDFS FileSystem.concat()
func (*FileSystem) Create ¶
func (fs *FileSystem) Create( data io.Reader, p Path, overwrite bool, blocksize uint64, replication uint16, permission os.FileMode, buffersize uint, contenttype string) (bool, error)
Creates a new file and stores its content in HDFS. See HDFS FileSystem.create() For detail, http://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Create_and_Write_to_a_File See NOTE section on that page for impl detail.
func (*FileSystem) CreateSymlink ¶
Creates a symlink where link -> destination See HDFS FileSystem.createSymlink() dest - the full path of the original resource link - the symlink path to create createParent - when true, parent dirs are created if they don't exist See http://hadoop.apache.org/docs/r2.2.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#HTTP_Query_Parameter_Dictionary
func (*FileSystem) Delete ¶
func (fs *FileSystem) Delete(path Path, recursive bool) (bool, error)
Deletes the specified path. See HDFS FileSystem.delete()
func (*FileSystem) GetContentSummary ¶
func (fs *FileSystem) GetContentSummary(p Path) (ContentSummary, error)
Returns ContentSummary for the given path. For detail, see HDFS FileSystem.getContentSummary()
func (*FileSystem) GetDelegationToken ¶
func (fs *FileSystem) GetDelegationToken(renewer string) (Token, error)
func (*FileSystem) GetDelegationTokens ¶
func (fs *FileSystem) GetDelegationTokens(renewer string) ([]Token, error)
func (*FileSystem) GetFileChecksum ¶
func (fs *FileSystem) GetFileChecksum(p Path) (FileChecksum, error)
Returns HDFS file checksum. For detail, see HDFS FileSystem.getFileChecksum()
func (*FileSystem) GetFileStatus ¶
func (fs *FileSystem) GetFileStatus(p Path) (FileStatus, error)
Returns status for a given file. The Path must represent a FILE on the remote system. (see HDFS FileSystem.getFileStatus())
func (*FileSystem) GetHomeDirectory ¶
func (fs *FileSystem) GetHomeDirectory() (Path, error)
func (*FileSystem) ListStatus ¶
func (fs *FileSystem) ListStatus(p Path) ([]FileStatus, error)
Returns an array of FileStatus for a given file directory. For details, see HDFS FileSystem.listStatus()
func (*FileSystem) Open ¶
func (fs *FileSystem) Open(p Path, offset, length int64, buffSize int) (io.ReadCloser, error)
Opens the specificed Path and returns its content to be accessed locally. See HDFS WebHdfsFileSystem.open() See http://hadoop.apache.org/docs/r2.2.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#HTTP_Query_Parameter_Dictionary
func (*FileSystem) Rename ¶
func (fs *FileSystem) Rename(source Path, destination Path) (bool, error)
Renames the specified path resource to a new name. See HDFS FileSystem.rename()
func (*FileSystem) RenewDelegationToken ¶
func (fs *FileSystem) RenewDelegationToken(token string) (int64, error)
func (*FileSystem) SetPermission ¶
Sets the permission for the specified path. See FileSystem.setPermission()
func (*FileSystem) SetReplication ¶
func (fs *FileSystem) SetReplication(path Path, replication uint16) (bool, error)
Sets replication factor for given path. See HDFS FileSystem.setReplication()
type FsShell ¶
type FsShell struct { FileSystem *FileSystem WorkingPath string }
func (FsShell) AppendToFile ¶
func (shell FsShell) AppendToFile(filePaths []string, hdfsPath string, contenttype string) (bool, error)
Appends the specified list of local files to the HDFS path.
func (FsShell) MoveFromLocal ¶
Copies local file to remote destination, then local file is removed.
func (FsShell) MoveToLocal ¶
Copies remote HDFS file locally. The remote file is then removed.
func (FsShell) Put ¶
Copies one specified local file to the remote HDFS server. Uses default permission, blocksize, and replication.
type HdfsJsonData ¶
type HdfsJsonData struct { Boolean bool FileStatus FileStatus FileStatuses FileStatuses FileChecksum FileChecksum ContentSummary ContentSummary Token Token Tokens Tokens Long int64 RemoteException RemoteException }
Root level struct for data JSON data from WebHDFS.
type Path ¶
type Path struct { Name string // Relative path representation (/root/leaf) RefererUrl url.URL // URL related to path (http://server:port/root/leaf) }
Represents a remote webHDFS path
type RemoteException ¶
Example:
{ "RemoteException": { "exception" : "FileNotFoundException", "javaClassName": "java.io.FileNotFoundException", "message" : "File does not exist: /foo/a.patch" } }
func (RemoteException) Error ¶
func (re RemoteException) Error() string
Implementation of error type. Returns string representation of RemoteException.