Apache的文档说
Similar to posix fsync, flush out the data in client's user buffer
all the way to the disk device (but the disk may have it in its cache).
这很容易理解,但是当我在代码中使用它时,我却不明白出现以下行为的原因。
cat
或tail
时,我在文件中看到该事件。但是,在再编写2或3个事件之后,我看不到它们。我必须关闭流以查看那些数据被刷新到文件中。 谁能解释这个现象的原因?希望我的描述清楚。
最佳答案
Hsync操作是非常昂贵的IO操作,它将数据从os缓冲区写入磁盘。每次写入后,您必须调用hflush而不是hsync。
有关更详细的解释,请在下面浏览我的帖子
https://medium.com/@kiran.palaka/how-hflush-works-in-hdfs-hadoop-52d782ed92d3
关于hadoop - hsync()如何在HDFS中工作?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33257397/