Pass JVM option (-Dconfig.file) per job in standalone mode?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Pass JVM option (-Dconfig.file) per job in standalone mode?

Chang Liu
Dear all,

I would like to know is there a way to pass JVM options (for example, -Dconfig.file=application.conf) for each submitted flink job? I am using the Config library from lightbend.

./bin/flink run examples/Example.jar -Dconfig.file=/path/application.conf

Best regards/祝好,

Chang Liu 刘畅


Reply | Threaded
Open this post in threaded view
|

Re: Pass JVM option (-Dconfig.file) per job in standalone mode?

Chang Liu
Hi Dominik,

Thanks for your reply. I thought so as well. But I am having some problems with passing program args.

Currently, i have the following:

object Configs {

  lazy val CONFIG: Config = ConfigFactory.load()

  lazy val config1: String = CONFIG.getString("key1")
  lazy val config2: String = CONFIG.getString("key2")
  lazy val config3: String = CONFIG.getString("key3")
  ...


}

If I pass the application.conf as program args, it will be like this:


object Configs {

  def setup(file: String): Unit = CONFIG = ConfigFactory.parseFile(new File(file))

  var CONFIG: Config = _

  lazy val config1: String = CONFIG.getString("key1")
  lazy val config2: String = CONFIG.getString("key2")
  lazy val config3: String = CONFIG.getString("key3")
  ...


}


This Scala code is not looking good I think. 
  • The CONFG is var instead of val
  • I have to call setup every time
  • I have some other object or vals which initialised depending on the parameters. If the parameters are passed in as program args instead of from JVM option, these object vals cannot be initialised properly.


And ideas about it?  Many Thanks :)


Best regards/祝好,

Chang Liu 刘畅


On 31 Jul 2018, at 14:15, Dominik Wosiński <[hidden email]> wrote:

Hey, 
I don't think that it's possible per job. You can pass only program arguments but not JVM options. 

Regards,
Dominik.

2018-07-31 13:59 GMT+02:00 Chang Liu <[hidden email]>:
Dear all,

I would like to know is there a way to pass JVM options (for example, -Dconfig.file=application.conf) for each submitted flink job? I am using the Config library from lightbend.

./bin/flink run examples/Example.jar -Dconfig.file=/path/application.conf

Best regards/祝好,

Chang Liu 刘畅