co-webhdfs-plus
A webhdfs client in co style.
NOTE:
- Node verion should >= 0.11.0
- For more information about co, take a look at document for co
- For more information about webhdfs, take a look at document for webhdfs
WHY
其实就是
hdfs restful client
读写文件时,webHDFS会307重定向一次,但是此时返回的是datanode域名,由于业务需要 我把域名转换成了事先对应的ip地址。
e.g.
转换成
Install:
npm install co-webhdfs-plus
Usage:
var _ = co = LineReader = LineReader Writer = Writer WebHdfsClient = ; ;
kerberos SPNEGO
Authentication using Hadoop delegation token when security is on:
// e.g. http://<HOST>:<PORT>/webhdfs/v1/<PATH>?delegation=<TOKEN>&op=...var client = token: 'kerberos_token' ... ;
or
var client = ... ;client;...// cookies访问是有时效性的,所以client后续操作返回401响应,则让用户重新登录获取cookies
API
Constructor
options: user: user name default 'hadoop' namenode_host: ip/hotname of namenode default 'localhost' namenode_port: port of webhdfa default 50070
Create and Write to a File
createWriteStream: function *(path, hdfsoptions) path: path of file data: data to write hdfsoptions: overwrite: <true|false> replication: <SHORT>] blocksize: <LONG> permission: <OCTAL> buffersize: <INT>
Append to a File
createAppendStream: function *(path, hdfsoptions) path: path of file data: data to write hdfsoptions: buffersize: <INT>
Open and Read a File
createReadStream: function *(path, hdfsoptions) path: path of file hdfsoptions: buffersize: <INT> offset:<LONG> length:<LONG>
Make a Directory
path: path of file hdfsoptions: permission: <OCTAL>
Rename a File/Directory
Delete a File/Directory
Status of a File/Directory
List a Directory
Get Content Summary of a Directory
Get File Checksum
Get Home Directory