Cucumber-Hadoop:如何从HDFS位置读取黄瓜功能文件?

时间:2018-10-16 10:10:01

标签: hadoop cucumber hdfs spark-submit

我正在使用import cucumber.api.cli.Main方法来调用黄瓜主方法,例如

Main.main(
    Array(glue,gluePath,tag,tagName,plugin,pluginNameAndPath,
        "hdfs:///user/test/hdfs.feature"))

是否可以从HDFS位置读取要素文件,因为它正在使用本地路径?

读取hdfs路径的方法是

val fs = FileSystem.get(new Configuration());
val fsDataInputStream = fs.open(new Path("/user/test/hdfs.feature"))

我也可以将其转换为Input流,但是问题是Array()仅接受字符串,而hdfs阅读器返回输入流以及FileSystem。 这个问题有解决办法吗?

更多参考- 当我使用“ spark-submit --master yarn --deploy-mode cluster ”时,会出现此问题。

对于“火花提交-母纱-部署模式客户端”来说效果很好。

1 个答案:

答案 0 :(得分:0)

这是我的问题的答案 使用--ps这样的文件提供所有功能文件

spark-submit --master yarn --deploy-mode cluster --queue cbi_ops --driver-memory 10G 
--executor-memory 5G --executor-cores 5 --num-executors 5 \
--jars $jars_path \
--files $files_path \
--driver-class-path xx.jar \
--class RunnerMain \
xx.jar \
"-g" "xx.stepdefinitions" \
"-t" "@functional-test,@regression-test" \

使用以下代码添加代码中的所有文件

sqlContext.sparkContext.addFile(x)

然后通过SparkFiles.get在数组中使用:

Array(glue,gluePath,tag,tagName,plugin,pluginNameAndPath,plugin,pluginNameAndPathJson,
            SparkFiles.get("ingestion-mc-ris-r2d-inc.feature"))
相关问题