- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
环境:Hadoop 0.20.2-cdh3u5
我正在尝试使用使用 SequenceFile.Writer 的自定义工具将日志数据 (10G) 上传到 HDFS。
SequenceFile.Writer w = SequenceFile.createWriter(
hdfs,
conf,
p,
LongWritable.class,
Text.class,
4096,
hdfs.getDefaultReplication(),
hdfs.getDefaultBlockSize(),
compressionType,
codec,
null,
new Metadata());
在上传过程中,如果工具崩溃(没有显式调用close()方法),已经上传的日志会丢失吗?
我应该及时调用sync()还是syncFs(),这两个方法是什么意思?
最佳答案
是的,可能吧。
sync()
创建一个同步点。正如 Tom White (Cloudera) 在《Hadoop - 权威指南》一书中所述
a sync point is a point in the stream which can used by to resynchronize with a record boundary if the reader is "lost" - for example after seeking to an arbitrary position on the stream.
现在 syncFS()
的实现非常简单:
public void syncFs() throws IOException {
if (out != null) {
out.sync(); // flush contents to file system
}
}
其中 out
是一个 FSDataOutputStream
。同样,在同一本书中指出:
HDFS provides a method for forcing all buffers to be synchronized to the datanodes via the
sync()
method onFSDataOutputStream
. After a successful call return fromsync()
HDFS garantees that the data written up to that point in the file is persisted and visible to all readers. In the event of a crash (of the client or HDFS), the data will not be lost.
但是一个脚注警告要查看 bug HDFS-200 , 因为上面提到的可见性并不总是总是受到尊重。
关于hadoop - SequenceFile.Writer的sync和syncFs是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12558401/
我有一个函数可以将数据写入任何实现接口(interface)的对象,该接口(interface)使用 Write(b []byte) (n int, err error) 方法。现在在我的程序中,我写
我继承了一些 Java。我对其他类似 C 的语言有很多经验,但我对 Java 还是很陌生。在一个函数中,我的前任同时使用了 write()和 append() Writer 的方法类,但我不明白为什么
我继承了一些 Java。我对其他类似 C 的语言有很多经验,但我对 Java 还是很陌生。在一个函数中,我的前任同时使用了 write()和 append() Writer 的方法类,但我不明白为什么
假设这里唯一的区别是二进制读取器/写入器对字符串使用固定长度编码,因此可能效率较低,是否正确? 最佳答案 不存在大量其他差异,例如读取和写入行、编码...基本上是与文本相关的“帮助器”函数的负载。 关
在将有效负载发送到 Web 服务之前尝试将有效负载转换为 xml 时,我在 mule 独立版本 3.8.1 中遇到错误。 我的流程配置是这样的:
似乎有两种方法可以将 JSON 对象的内容写入编写器。我可以做 myWriter.write(myJSONObj.toString()); 或者 myJSONObj.write(myWriter);
这个问题已经有答案了: Should one call .close() on HttpServletResponse.getOutputStream()/.getWriter()? (6 个回答)
初始化记录器后: var Logger *log.Logger f, err := os.OpenFile("somefile", os.O_WRONLY|os.O_CREATE|os.O_APPEN
我正在开发一个网站,除其他外,它通过 Metaweblog API 提供博客。我已经让 API 与几个博客客户端一起工作得很好,但 Windows Live Writer 正在扼杀我。 我已经完成了网
我有一个在启动后异步运行的方法,使用 OutputStream 或 Writer 作为参数。 它充当 OutputStream 或 Writer 的记录适配器(这是我无法更改的第三方 API)。 如何
我正在使用 ruby version 1.9.3 并且在启动 thin server 时出现错误 /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.1
我编辑了一个来自客户的文档,其中有一些亮点,然后决定删除评论中的亮点。 无论出于何种原因,该文档突出显示了许多项目符号和编号列表部分,当我尝试选择整个文档并将突出显示更改为“无填充”时,我无法还原这些
我正在读取 URL 的内容并将其写入文件,这按预期工作,但即使程序控制台显示多行,它也只写入一次。 代码: PrintWriter writer = new PrintWriter("the-file
在调用 XslCompiledTransform.Transform() 方法时出现此异常: The Writer is closed or in error state. 谁知道这是什么意思? 最佳
我试图制作一个系统,用于将 lua 编译脚本存储在内存中。问题是我不能做一个“lua_Writer”,变量字节码是空的。我使用 Luajit。在我的代码下方。 typedef struct {
我想将一些字符串写入文件。所以,我使用了 BufferedWriter 类。由于许多线程倾向于写入该文件,我想知道 write 和 writeLine 方法是否是原子的。 此外,我希望程序将输出写入多
我有一个套接字,我可以在其中写入一些字符数据和一些原始字节数据。对于字符数据,使用PrintWriter 更容易。对于原始字节数据,直接写入 OutputStream 会更容易。所以在我的代码中,我有
在 Golang 中是否可以将 string 转换为 io.Writer 类型? 我将在 fmt.Fprintf() 中使用此字符串,但我无法转换类型。 最佳答案 你不能写入 string,strin
我正在将数据框拧到 Excel 中。也许我做得不对, 当我使用此代码时: from datetime import datetime import numpy as np import pandas
我尝试导入 Control.Monad.Writer像这样的模块: import Control.Monad.Writer ghc版本 7.4.1 给出以下错误: Ambiguous module n
我是一名优秀的程序员,十分优秀!