1

我能够将结构化流式传输的结果写入 Parquet 文件。问题是这些文件在本地文件系统中,现在我想将它们写入 Hadoop 文件系统。有没有办法做到这一点?

StreamingQuery query = result //.orderBy("window")
            .repartition(1)
            .writeStream()
            .outputMode(OutputMode.Append())
            .format("parquet")
            .option("checkpointLocation", "hdfs://localhost:19000/data/checkpoints")
            .start("hdfs://localhost:19000/data/total");

我使用了这段代码,但它说:

Exception in thread "main" java.lang.IllegalArgumentException: Wrong FS: hdfs://localhost:19000/data/checkpoints/metadata, expected: file:///
at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:649)
at org.apache.hadoop.fs.RawLocalFileSystem.pathToFile(RawLocalFileSystem.java:82)
at org.apache.hadoop.fs.RawLocalFileSystem.deprecatedGetFileStatus(RawLocalFileSystem.java:606)
at org.apache.hadoop.fs.RawLocalFileSystem.getFileLinkStatusInternal(RawLocalFileSystem.java:824)
at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:601)
at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:421)
at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1426)
at org.apache.spark.sql.execution.streaming.StreamMetadata$.read(StreamMetadata.scala:51)
at org.apache.spark.sql.execution.streaming.StreamExecution.<init>(StreamExecution.scala:100)
at org.apache.spark.sql.streaming.StreamingQueryManager.createQuery(StreamingQueryManager.scala:232)
at org.apache.spark.sql.streaming.StreamingQueryManager.startQuery(StreamingQueryManager.scala:269)
at org.apache.spark.sql.streaming.DataStreamWriter.start(DataStreamWriter.scala:262)
at org.apache.spark.sql.streaming.DataStreamWriter.start(DataStreamWriter.scala:206)

谢谢

4

2 回答 2

1

这是一个已知问题:https ://issues.apache.org/jira/browse/SPARK-19407

应该在下一个版本中修复。--conf spark.hadoop.fs.defaultFS=hdfs://localhost:19000作为一种解决方法,您可以将默认文件系统设置为 s3 。

于 2017-03-01T05:31:53.297 回答
1

这对我有用,所以火花升级可能解决了这个问题:

option("checkpointLocation", "hdfs:///project/dz/collab/stream/hdfs/chk_ucra").trigger(Trigger.ProcessingTime("300 seconds")).start("/project/dz/collab/stream/hdfs/ucra")
于 2019-05-16T14:03:01.467 回答