我使用webhdfs库将文件移动到hdfs(hadoop文件系统),如:
var hdfsConnector = WebHDFS.createClient(this.config());
var localFileStream = fs.createReadStream(sourcePath);
var remoteFileStream = hdfsConnector.createWriteStream(destinationPath);
localFileStream.pipe(remoteFileStream);
remoteFileStream.on('error', function onError (err) {
//On error
});
remoteFileStream.on('finish', function onFinish () {
//On finish
});
问题是在每种情况下都会触发完成回调,即错误和成功,所以我如何识别成功。