【发布时间】:2020-01-01 15:04:59
【问题描述】:
我在我的 scala 代码中使用 lightbend,以便我的 application.properties 文件远离我的 jar。我需要在application.properties 文件中传递当前日期。
Date_read_write = 20190828
如何让它动态拾取,如果是 shell 脚本我可以提及
Date_read_write=`date +%Y%m%d`
如何在application.properties 文件中执行类似的步骤?
时间加法更新
下面是我的application.properties 文件:
hdfs_link = hdfs://XX.XXX.XXX.XX:8080/sessions/data/events
mediaKey = 1234
eventName = media
Date_read_write = 20190815
time = *_W
parts = *
我正在使用上面来生成hdfs://XX.XXX.XXX.XX:8080/sessions/data/events/1234/media/20190815/*_W/*
使用:
val conf = ConfigFactory.load()
val hdfs_path = conf.getString("hdfs_link")+"/"+conf.getString("mediaKey")+"/"+conf.getString("eventName")+"/"+conf.getString("Date_read_write")+"/"+conf.getString("time")+"/"+conf.getString("parts")
但是当我添加时
--driver-java-options -DDate_read_write=`date --date='1 days ago' '+%Y%m%d'`
对于我的 spark 提交命令,我的 URL 是 hdfs://XX.XXX.XXX.XX:8080/sessions/data/events/1234/media/20190828/*/*
我不知道为什么这个添加会改变 time 的值。
下面是我的 spark 提交命令:
nohup spark-submit --master yarn --deploy-mode client --num-executors 20 --executor-cores 6 --driver-memory 10g --executor-memory 10g --class metrics.MasterAggregateTable --files application.properties --driver-java-options -Dconfig.file=application.properties --driver-java-options -DDate_read_write=`date +%Y%m%d`--jars com.datastax.spark_spark-cassandra-connector_2.11-2.3.0.jar UserMetrics.jar &
【问题讨论】:
标签: scala apache-spark config typesafe-config