Documentation ¶
Index ¶
- Constants
- Variables
- func GetErrFromBody(response *http.Response) error
- type Client
- func (c *Client) Append(path string, bufferSize uint, data []byte) error
- func (c *Client) Create(path string, data []byte) error
- func (c *Client) CreateFile(path string, overwrite bool, blockSize uint64, perm os.FileMode, ...) error
- func (c *Client) CreateFileWithGoodBlock(path string, data []byte) error
- func (c *Client) GetContentSummary(dirname string) (*ContentSummary, error)
- func (c *Client) GetFileChecksum(path string) (*FileChecksum, error)
- func (c *Client) GetFileStatus(path string) (*FileStatus, error)
- func (c *Client) ListStatus(path string) ([]FileStatus, error)
- func (c *Client) Mkdir(dirname string, perm os.FileMode) error
- func (c *Client) MkdirAll(dirname string, perm os.FileMode) error
- func (c *Client) Read(path string) ([]byte, error)
- func (c *Client) ReadFile(path string, offset, length uint64, bufferSize uint) ([]byte, error)
- func (c *Client) RemoveAll(path string) error
- func (c *Client) Walk(path string, callback func(prefixPath string, status FileStatus)) error
- type ContentSummary
- type FileChecksum
- type FileStatus
- type Option
- func HostOption(host string) Option
- func MinBlockSizeOption(blockSize uint64) Option
- func PortOption(port int) Option
- func ReplicationOption(replication int) Option
- func SSLOption(SSL bool) Option
- func TimeoutOption(timeout time.Duration) Option
- func TransportOption(transport *http.Transport) Option
- func UserOption(user string) Option
Constants ¶
View Source
const ( DefaultUser = "root" //默认用户 DefaultReplication = 1 //默认复制数量 DefaultProtocol = "http" DefaultHost = "127.0.0.1:14000" DefaultPort = 14000 DefaultBlockSize = 1024 * 1024 * 128 //默认块大小 )
View Source
const ( MkdirPathFormat = "%s/webhdfs/v1%s?op=MKDIRS&permission=%s&user.name=%s" GetContentSummaryFormat = "%s/webhdfs/v1%s?op=GETCONTENTSUMMARY&user.name=%s" )
View Source
const ( ReadFileFormat = "%s/webhdfs/v1%s?op=OPEN&length=%d&offset=%d&buffersize=%d&user.name=%s" DefaultReadFileFormat = "%s/webhdfs/v1%s?op=OPEN&user.name=%s" DefaultReadLength = 4096 )
View Source
const ( ListStatusFormat = "%s/webhdfs/v1%s?op=LISTSTATUS&user.name=%s" GetFileStatusFormat = "%s/webhdfs/v1%s?op=GETFILESTATUS&user.name=%s" GetFileChecksumFormat = "%s/webhdfs/v1%s?op=GETFILECHECKSUM&user.name=%s" TypeFile = "FILE" TypeDir = "DIRECTORY" )
View Source
const ( DefaultCreateFileFormat = "%s/webhdfs/v1%s?op=CREATE&overwrite=false&permission=644&buffersize=4096&replication=%d&user.name=%s" CreateFileFormat = "%s/webhdfs/v1%s?op=CREATE&overwrite=%v&blocksize=%d&permission=%s&buffersize=%d&replication=%d&user.name=%s" AppendFileFormat = "%s/webhdfs/v1%s?op=APPEND&buffersize=%d&user.name=%s" DefaultBufferSize = 4096 DefaultFilePerm = 0644 ContentTypeKey = "Content-Type" ContentTypeValue = "application/octet-stream" )
View Source
const MB = 1024 * 1024
View Source
const (
RemoveAllFormat = "%s/webhdfs/v1%s?op=DELETE&user.name=%s"
)
Variables ¶
View Source
var ( DefaultTransport = &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 3 * time.Second, KeepAlive: 30 * time.Second, }).DialContext, ForceAttemptHTTP2: true, MaxIdleConns: 100, IdleConnTimeout: 90 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, }, } )
View Source
var (
ErrPathIsNotDirectory = fmt.Errorf("传入路径不是目录")
)
Functions ¶
func GetErrFromBody ¶
Types ¶
type Client ¶
func (*Client) CreateFile ¶
func (c *Client) CreateFile(path string, overwrite bool, blockSize uint64, perm os.FileMode, bufferSize uint, replication uint16, data []byte) error
CreateFile 自定义配置创建文件
func (*Client) CreateFileWithGoodBlock ¶ added in v1.0.1
CreateFileWithGoodBlock 使用合适的块大小存放数据
func (*Client) GetContentSummary ¶
func (c *Client) GetContentSummary(dirname string) (*ContentSummary, error)
GetContentSummary 获取目录的内容摘要
func (*Client) GetFileChecksum ¶
func (c *Client) GetFileChecksum(path string) (*FileChecksum, error)
GetFileChecksum 获取指定文件的md5值
func (*Client) GetFileStatus ¶
func (c *Client) GetFileStatus(path string) (*FileStatus, error)
GetFileStatus 获取指定文件的信息
func (*Client) ListStatus ¶
func (c *Client) ListStatus(path string) ([]FileStatus, error)
ListStatus 获取指定路径下列表
type ContentSummary ¶
type FileChecksum ¶
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 }
func (FileStatus) IsDir ¶
func (f FileStatus) IsDir() bool
type Option ¶
type Option func(client *Client)
func MinBlockSizeOption ¶ added in v1.0.1
MinBlockSizeOption 设置最小块大小 单位字节
Click to show internal directories.
Click to hide internal directories.