带附加功能的 HDFS 是如何工作的

发布于 2025-01-02 12:46:12 字数 268 浏览 6 评论 0原文

假设一个文件使用默认块大小 (128 MB),并且有一个文件使用 130 MB;因此使用 1 个全尺寸块和 1 个 2 MB 块。然后需要将 20 MB 附加到文件中(现在总计应为 150 MB)。会发生什么?

HDFS 实际上是否将最后一个块的大小从 2MB 调整为 22MB?或者创建一个新块?

向 HDFS 中的文件追加内容如何处理并发性? 是否存在数据丢失的风险?

HDFS是否创建第三个块,将20+2MB放入其中,并删除2MB的块。如果是,它是如何同时工作的?

Let's assume one is using default block size (128 MB), and there is a file using 130 MB ; so using one full size block and one block with 2 MB. Then 20 MB needs to be appended to the file (total should be now of 150 MB). What happens?

Does HDFS actually resize the size of the last block from 2MB to 22MB? Or create a new block?

How does appending to a file in HDFS deal with conccurency?
Is there risk of dataloss ?

Does HDFS create a third block put the 20+2 MB in it, and delete the block with 2MB. If yes, how does this work concurrently?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

并安 2025-01-09 12:46:12

根据最新设计文档中的Jira 问题 前面提到,我们找到您问题的以下答案:

  1. HDFS 将附加到最后一个块,< em>不创建一个新块并从旧的最后一个块复制数据。这并不困难,因为 HDFS 只是使用普通文件系统将这些块文件作为普通文件写入。普通文件系统具有附加新数据的机制。当然,如果你填满了最后一个区块,你就会创建一个新的区块。
  2. HDFS 中只允许同时对任何文件进行一次写入或追加,因此无需处理并发。这是由名称节点管理的。如果您希望其他人开始写入文件,则需要关闭该文件。
  3. 如果文件中的最后一个块没有被复制,追加将会失败。追加被写入单个副本,该副本将其通过管道传输到副本,类似于正常写入。在我看来,与正常写入相比,不存在额外的数据丢失风险。

According to the latest design document in the Jira issue mentioned before, we find the following answers to your question:

  1. HDFS will append to the last block, not create a new block and copy the data from the old last block. This is not difficult because HDFS just uses a normal filesystem to write these block-files as normal files. Normal file systems have mechanisms for appending new data. Of course, if you fill up the last block, you will create a new block.
  2. Only one single write or append to any file is allowed at the same time in HDFS, so there is no concurrency to handle. This is managed by the namenode. You need to close a file if you want someone else to begin writing to it.
  3. If the last block in a file is not replicated, the append will fail. The append is written to a single replica, who pipelines it to the replicas, similar to a normal write. It seems to me like there is no extra risk of dataloss as compared to a normal write.
内心激荡 2025-01-09 12:46:12

这是一个非常全面的关于追加的设计文档,它包含并发性问题。

当前的 HDFS 文档给出了链接到该文档,因此我们可以假设它是最新的。 (文档日期为 2009 年)

以及相关的问题

Here is a very comprehensive design document about append and it contains concurrency issues.

Current HDFS docs gives a link to that document, so we can assume that it is the recent one. (Document date is 2009)

And the related issue.

飘逸的'云 2025-01-09 12:46:12

Hadoop 分布式文件系统支持附加到文件,在这种情况下,它应该将 20 MB 添加到示例中的第二个块(最初包含 2 MB 的块)。这样您最终将得到两个块,一个具有 128 MB,另一个具有 22 MB。

This是HDFS附加java文档的参考。

Hadoop Distributed File System supports appends to files, and in this case it should add the 20 MB to the 2nd block in your example (the one with 2 MB in it initially). That way you will end up with two blocks, one with 128 MB and one with 22 MB.

This is the reference to the append java docs for HDFS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文