1.0.0 • Published 4 years ago

hdfs247 v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

NPM HDFS module

Build Status

This is node.js interface to communicating with web HDFS interface.

How to use

Installing

Before we can use this module we need to install it first

$ npm install --save hdfs247

Using on Unsecure Cluster

var Hdfs = require('hdfs'),
  localpath = '/tmp/filetest.txt',
  remotepath = '/user/apps/filetest.txt';

var hdfs = new Hdfs({
  protocol: 'http',
  hostname: '192.168.1.225',
  port: 50070
});

hdfs.upload({
  'user.name': 'apps',
  overwrite: true,
  localpath: localpath,
  path: remotepath
}, function(error, response, body) {
  console.log(error);    // Error will be null if upload process is succeed.
  console.log(response); // Raw response from node.js request.
  console.log(body);     // Body of request result.
});

Using on Secure Cluster (Kerberized/SPNego)

var Hdfs = require('hdfs'),
  localpath = '/tmp/filetest.txt',
  remotepath = '/user/apps/filetest.txt';

var hdfs = new Hdfs({
  protocol: 'http',
  hostname: '192.168.1.225',
  port: 50070
});

hdfs.upload({
  'user.name': 'apps',
  overwrite: true,
  localpath: localpath,
  spnego_token: result.token,
  principal: spnego_principal,
  keytab: keytab,
  realm: realm,
  krb_fqdn: krb_fqdn,
  path: remotepath
}, function(error, response, body) {
  console.log(error);    // Error will be null if upload process is succeed.
  console.log(response); // Raw response from node.js request.
  console.log(body);     // Body of request result.
});

Functions

cekpath(param) ⇒ Object

Check the parameter, return path if there is path in parameter, and return / if no path in parameter.

Kind: global function
Returns: Object - Object with only path in it.

ParamTypeDescription
paramObjectParameter from user

prepvar(param) ⇒ Object

Prepare parameter, separate request option and request parameter, set default option, and explicitly set path.

Kind: global function
Returns: Object - Clean ready to use request parameter.

ParamTypeDescription
paramObjectMixed request parameter.

Hdfs(data)

Hdfs class constructor

Kind: global function

ParamTypeDescription
dataObjectObject data seed.

hdfs.getfilestatus(param, callback)

Get file status from HDFS Possible properties of param is :

namepresencetypedefaultdescription
pathoptionalString/Path status that will be taken

Kind: instance method of Hdfs

ParamTypeDescription
paramObjectRequest parameter for get file status endpoint
callbackfunctionCallback function to return the result

hdfs.liststatus(param, callback)

List status of file and directory under specified directory

namepresencetypedefaultdescription
pathoptionalString/Path status that will be taken

Kind: instance method of Hdfs

ParamTypeDescription
paramObjectRequest parameter for get list of status file
callbackfunctionCallback function to return the result

hdfs.download(param, callback)

Download file from HDFS with without buffering.

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Open_and_Read_a_File

Param properties :

namepresencetypedefaultvalid valuedescription
pathoptionalString/An absolute FileSystem path without scheme and authority.Path status that will be taken
offsetoptionalLong0>=0The starting byte position
lengthoptionalLongnull>=0 or nullThe number of bytes to be processed. null means the entire file
buffersizeoptionalIntSpecified in hadoop configuration>0The size of the buffer used in transferring data.
ParamTypeDescription
paramObjectRequest parameter for download file from HDFS
callbackfunctionCallback function to return the result

hdfs.upload(param, callback)

Upload file to HDFS without buffering.

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Create_and_Write_to_a_File

Param properties :

namepresencetypedefaultvalid valuedescription
pathoptionalString/An absolute FileSystem path without scheme and authority.Path status that will be taken
overwriteoptionalBooleanfalsetrue or falseIf a file already exists, should it be overwritten?
blocksizeoptionalLongSpecified in hadoop configuration>0The block size of a file.
replicationoptionalShortSpecified in hadoop configuration>0The number of replications of a file.
permissionoptionaloctal7550 - 1777The permission of a file/directory.
buffersizeoptionalIntSpecified in hadoop configuration>0The size of the buffer used in transferring data.
ParamTypeDescription
paramObjectRequest parameter for upload file from HDFS
callbackfunctionCallback function to return the result

hdfs.open(param, callback)

Open file from HDFS, this function will buffer content file in memory

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Open_and_Read_a_File

Param properties :

namepresencetypedefaultvalid valuedescription
pathoptionalString/An absolute FileSystem path without scheme and authority.Path status that will be taken
offsetoptionalLong0>=0The starting byte position
lengthoptionalLongnull>=0 or nullThe number of bytes to be processed. null means the entire file
buffersizeoptionalIntSpecified in hadoop configuration>0The size of the buffer used in transferring data.
ParamTypeDescription
paramObjectRequest parameter for open file from HDFS
callbackfunctionCallback function to return the result

hdfs.gethomedirectory(param, callback)

Get home directory of current accessing user.

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Get_Home_Directory

ParamTypeDescription
paramObjectRequest parameter for getting home directory.
callbackfunctionCallback function to return the result

hdfs.getcontentsummary(param, callback)

Get summary of content

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Get_Content_Summary_of_a_Directory

namepresencetypedefaultvalid valuedescription
pathoptionalString/An absolute FileSystem path without scheme and authority.Path status that will be taken
ParamTypeDescription
paramObjectRequest parameter for getting home directory.
callbackfunctionCallback function to return the result

hdfs.getfilechecksum(param, callback)

Get checksum of file

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Get_File_Checksum

namepresencetypedefaultvalid valuedescription
pathoptionalString/An absolute FileSystem path without scheme and authority.Path status that will be taken
ParamTypeDescription
paramObjectRequest parameter for get checksum of file.
callbackfunctionCallback function to return the result

hdfs.concat(param, callback)

Concatenating file to another one. Warning : It's still experimental. We warn you.

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Concat_Files

namepresencetypedefaultvalid valuedescription
pathMandatoryString/An absolute FileSystem path without scheme and authority.Path status that will be taken
sourcesMandatoryStringA list of comma seperated absolute FileSystem paths without scheme and authority.A list of source paths.
ParamTypeDescription
paramObjectRequest parameter for concatenating file.
callbackfunctionCallback function to return the result

hdfs.append(param, callback)

Append data to another file in HDFS

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Append_to_a_File

Param properties :

namepresencetypedefaultvalid valuedescription
pathMandatoryString/An absolute FileSystem path without scheme and authority.Path status that will be taken
buffersizeoptionalIntSpecified in hadoop configuration>0The size of the buffer used in transferring data.
ParamTypeDescription
paramObjectRequest parameter for upload file from HDFS
callbackfunctionCallback function to return the result

hdfs.create(param, callback)

Create file in HDFS.

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Create_and_Write_to_a_File

Param properties :

namepresencetypedefaultvalid valuedescription
pathMandatoryString/An absolute FileSystem path without scheme and authority.Path status that will be taken
overwriteoptionalBooleanfalsetrue or falseIf a file already exists, should it be overwritten?
blocksizeoptionalLongSpecified in hadoop configuration>0The block size of a file.
replicationoptionalShortSpecified in hadoop configuration>0The number of replications of a file.
permissionoptionaloctal7550 - 1777The permission of a file/directory.
buffersizeoptionalIntSpecified in hadoop configuration>0The size of the buffer used in transferring data.
ParamTypeDescription
paramObjectRequest parameter for upload file from HDFS
callbackfunctionCallback function to return the result

hdfs.rename(param, callback)

Rename file or directory in HDFS

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Rename_a_FileDirectory

Param properties :

namepresencetypedefaultvalid valuedescription
pathMandatoryString/An absolute FileSystem path without scheme and authority.Path status that will be taken
destinationMandatoryString (an invalid path)An absolute FileSystem path without scheme and authority.The destination path.
ParamTypeDescription
paramObjectRequest parameter for rename file or directory.
callbackfunctionCallback function to return the result

hdfs.mkdirs(param, callback)

Make directory in Hdfs

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Make_a_Directory

Param properties :

namepresencetypedefaultvalid valuedescription
pathoptionalString/An absolute FileSystem path without scheme and authority.Path status that will be taken
permissionoptionaloctal7550 - 1777The permission of a file/directory.
ParamTypeDescription
paramObjectRequest parameter for make directory in HDFS
callbackfunctionCallback function to return the result

hdfs.setpermission(param, callback)

Set permission of file in HDFS

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Set_Permission

Param properties :

namepresencetypedefaultvalid valuedescription
pathMandatoryString/An absolute FileSystem path without scheme and authority.Path status that will be taken
permissionMandatoryoctal7550 - 1777The permission of a file/directory.
ParamTypeDescription
paramObjectRequest parameter for set permission of file and directory in HDFS
callbackfunctionCallback function to return the result

hdfs.setowner(param, callback)

Set owner of file or directory

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Set_Owner

Param properties :

namepresencetypedefaultvalid valuedescription
pathMandatoryString/An absolute FileSystem path without scheme and authority.Path status that will be taken
ownerOptionalString (means keeping it unchanged)Any valid username.The username who is the owner of a file/directory.
groupOptionalString (means keeping it unchanged)Any valid group name.The name of a group.
ParamTypeDescription
paramObjectRequest parameter for set owner in HDFS
callbackfunctionCallback function to return the result

hdfs.setreplication(param, callback)

Set replication factor of file.

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Set_Replication_Factor

Param properties :

namepresencetypedefaultvalid valuedescription
pathMandatoryString/An absolute FileSystem path without scheme and authority.Path status that will be taken
replicationOptionalShortSpecified in the configuration.>0The number of replications of a file.
ParamTypeDescription
paramObjectRequest parameter for set replication file.
callbackfunctionCallback function to return the result

hdfs.settimes(param, callback)

Set time and date of file in HDFS

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Set_Access_or_Modification_Time

Param properties :

namepresencetypedefaultvalid valuedescription
pathMandatoryString/An absolute FileSystem path without scheme and authority.Path status that will be taken
modificationtimeOptionalLong-1 (means keeping it unchanged)-1 or a timestampThe modification time of a file/directory.
accesstimeOptionalLong-1 (means keeping it unchanged)-1 or a timestampThe access time of a file/directory.
ParamTypeDescription
paramObjectRequest parameter for setting time and date of file.
callbackfunctionCallback function to return the result

hdfs.delete(param, callback)

Delete file or directory in HDFS

Kind: instance method of Hdfs
See: https://hadoop.apache.org/docs/r2.7.0/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Delete_a_FileDirectory

Param properties :

namepresencetypedefaultvalid valuedescription
pathMandatoryString/An absolute FileSystem path without scheme and authority.Path status that will be taken
recursiveOptionalBooleanfalsetrue or falseShould the operation act on the content in the subdirectories?
ParamTypeDescription
paramObjectRequest parameter for deleting file and or directory.
callbackfunctionCallback function to return the result
1.0.0

4 years ago

0.0.9

7 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago