简体   繁体   English

在HDFS上编写Kafka流式传输结果

[英]Writing Kafka Streaming results on HDFS

I wrote a Kafka Streaming application that writes results on local files using the code: 我编写了一个Kafka Streaming应用程序,该应用程序使用以下代码在本地文件上写入结果:

source.mapValues(record -> finall(record)).mapValues(record -> Arrays.deepToString(record))
            .writeAsText(PATH);

Trying to save data on HDFS, using the command: 尝试使用以下命令在HDFS上保存数据:

source.mapValues(record -> finall(record)).mapValues(record -> Arrays.deepToString(record))
            .writeAsText(hdfs://localhost:54310/output);

it errors: 它错误:

Unable to write stream to file at [hdfs://localhost:54310/output] hdfs:/localhost:54310/output (No such file or directory)

Is there any way to write Kafka Streaming results on HDFS? 有什么办法可以在HDFS上写入Kafka Streaming结果吗?

I would avoid this pattern, and instead write from KStreams back to a Kafka topic, and simply stream that topic to HDFS using the Kafka Connect HDFS connector . 我会避免这种模式,而是从KStreams回写到Kafka主题,并使用Kafka Connect HDFS连接器将该主题流式传输到HDFS。 This way you decouple your stream processing from writing the data elsewhere. 这样,您就可以将流处理与将数据写入其他位置分离。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM