我试图在我的星火应用程序中使用多个(通过包含) Typesafe配置文件,这是我在集群模式下提交给纱线队列的尝试。我基本上有两个配置文件,文件布局如下:
以上两个文件都在我的application.jar外部,所以我使用“--文件”(见下文)将它们传递给纱线。
我正在使用Typesafe配置库来解析我的"application-main.conf“,在这个主conf中,我试图通过替换使用env.properties文件中的一个属性,但是变量名没有得到解析:(我不知道为什么。
env.properties
txn.hdfs.fs.home=hdfs://dev/1234/data
申请-txn.conf:
# application-txn.conf
include required(file("env.properties"))
app {
raw-data-location = "${txn.hdfs.fs.home}/input/txn-raw"
}
火花应用程序代码:
//propFile in the below block maps to "application-txn.conf" from the app's main method
def main {
val config = loadConfig("application-txn.conf")
val spark = SparkSession.builkder.getOrCreate()
//Code fails here:
val inputDF = spark.read.parquet(config.getString("app.raw-data-location"))
}
def loadConf(propFile:String): Config = {
ConfigFactory.load()
val cnf = ConfigFactory.parseResources(propFile)
cnf.resolve()
}
火花提交代码(从shell脚本调用):
spark-submit --class com.nic.cage.app.Transaction \
--master yarn \
--queue QUEUE_1 \
--deploy-mode cluster \
--name MyTestApp \
--files application-txn.conf,env.properties \
--jars #Typesafe config 1.3.3 and my app.jar go here \
--executor-memory 2g \
--executor-cores 2 \
app.jar application-txn.conf
当我运行上面的文件时,我可以解析配置文件,但是我的应用程序在尝试从HDFS读取文件时失败了,因为它找不到一个名为${txn.hdfs.fs.home}/input/txn raw的目录。
我相信配置实际上能够读取两个files...or --否则会因为“必需”关键字而失败。我通过添加另一个带有虚拟文件名的include语句来验证这一点,而应用程序在解析配置时失败了。真不知道现在发生了什么。
有什么想法可以导致这个决议失败呢?如果有帮助:当我使用多个配置文件在本地运行时,解决方案可以正常工作。
发布于 2019-05-03 00:51:58
application-txn.conf的语法是错误的。
变量应该在字符串之外,如下所示:
raw-data-location = ${txn.hdfs.fs.home}"/input/txn-raw"
https://stackoverflow.com/questions/55961600
复制