访问火花映射函数内的HDFS文件时出现问题



我的用例需要从spark map函数内部访问存储在HDFS中的文件。该用例使用不向映射函数提供任何数据的自定义输入格式,而映射函数获得输入拆分并访问数据。我正在使用下面的代码来做这个

val hConf: Configuration = sc.hadoopConfiguration
hConf.set("fs.hdfs.impl", classOf[org.apache.hadoop.hdfs.DistributedFileSystem].getName) 
hConf.set("fs.file.impl",    classOf[org.apache.hadoop.fs.LocalFileSystem].getName)
var job = new Job(hConf)           
    FileInputFormat.setInputPaths(job,new Path("hdfs:///user/bala/MyBinaryFile"));

    var hRDD = new NewHadoopRDD(sc, classOf[RandomAccessInputFormat], 
        classOf[IntWritable], 
        classOf[BytesWritable],
        job.getConfiguration() 
        )    
    val count = hRDD.mapPartitionsWithInputSplit{ (split, iter) => myfuncPart(split, iter)}.collect()

到目前为止,我没有在myfuncPart中做任何事情。这个简单的返回如下的地图

 iter.map { tpl ⇒ (tpl._1, tpl._2.getCapacity) }

当我提交作业和依赖项时,我得到以下错误

15/10/30 11:11:39 WARN scheduler.TaskSetManager: Lost task 0.0 in stage 0.0 (TID 0, 40.221.94.235): java.io.IOException: No FileSystem for scheme: spark
at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2584)
at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2591)
at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:91)

乍一看,这似乎是一个与火花罐有关的小错误,但无法破裂。任何帮助都将不胜感激。

事实证明,我启动作业的方式是一个错误。我使用的命令中没有正确的选项。因此,出现了问题。我使用下面的命令

spark-submit  --class org.myclass --jars myjar spark://myhost:7077 myjob.jar

以下是正确的

spark-submit  --class org.myclass --jars myjar --master spark://myhost:7077 myjob.jar

这是一个小错误,但不知何故我错过了。现在它正在上运行

最新更新