漫画HDFS+翻译(1)

1 写文件入HDFS

在这里插入图片描述
从上面的图,我们获得以下信息:

  • 数据存HDFS之前是要被切分的
  • 切分成多大是我们定的,然后客户端去执行
  • 假设我们定数据块大小为128MB,那么200MB的就会被切分成128MB和72MB。

在这里插入图片描述
从上面的图,我们获得以下信息:

  • 客户端可以把原文件切分成数据块
  • 客户端存数据之前要跟NameNode报备一下,由NameNode去调度数据节点来做具体的事情。
    应该是计算一下,哪些节点比较空闲吧。另外NameNode提到了数据节点离客户端的远近。
    说明客户端并不是固定的。
  • 客户端传数据就给第一个数据节点传,然后下面就是流水线式的操作。

在这里插入图片描述
看完上面的图,我基本搞懂了HDFS写数据的流程。
但是也有一个最大的疑问:

客户端是个啥!!!

从目前看,它有以下功能:

  • 拆分原文件为数据块
  • 上传数据(也就是说可以执行hdfs命令)
    从stackoverflow上找到了一段描述很恰当的话:

Client in Hadoop refers to the Interface used to communicate with the Hadoop Filesystem. There are different type of Clients available with Hadoop to perform different tasks.
The basic filesystem client hdfs dfs is used to connect to a Hadoop Filesystem and perform basic file related tasks. It uses the ClientProtocol to communicate with a NameNode daemon, and connects directly to DataNodes to read/write block data. To perform administrative tasks on HDFS, there is hdfs dfsadmin. For HA related tasks, hdfs haadmin. There are similar clients available for performing YARN related tasks.
These Clients can be invoked using their respective CLI commands from a node where Hadoop is installed and has the necessary configurations and libraries required to connect to a Hadoop Filesystem. Such nodes are often referred as Hadoop Clients.
For example, if I just write an hdfs command on the Terminal, is it still a “client” ?
Technically, Yes. If you are able to access the FS using the hdfs command, then the node has the configurations and libraries required to be a Hadoop Client.

PS: APIs are also available to create these Clients programmatically.

总结一下,客户端的含义两句话:

  1. 可以使用hdfs dfs命令的机器,一般是datanode。
  2. 利用API和HDFS进行交互的也可以创建客户端。(API创建客户端的时候好像也得先创建一个连接应该也是和某台datanode创建连接)
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值