My goal is to pass args to the Main() function of a Flink job via the "Program Arguments" field in the cluster GUI.
And to access them (ideally by key name) in the Main() function some way like so:
public static void main(String[] args) throws Exception {
ParameterTool parameter = ParameterTool.fromArgs(args);
CustomProps props = new CustomProps (DEFAULT_PROPERTIES_FILE);
String kafkaAutoOffsetReset = props.getKafkaAutoOffsetReset();
String cassandraClusterUrl = props.getCassandraClusterUrl();
if (args.length == 1 && args[0] != null) {
cassandraClusterUrl = parameter.get("cassandraClusterUrl");
kafkaAutoOffsetReset = parameter.get("kafkaOffset");
}
//Other code...
}
I have tried the "ParameterTool" but I don't get anything from it, and if I try something like:
kafkaAutoOffsetReset = args[0];
It only works if I only put a single word in the "Program Arguments" field. So if I put:
blah
it says it was set to "blah", but if I try any of these:
-kafkaOffset blah
--kafkaOffset blah
-kafkaOffset:blah
-kafkaOffset=blah
I get nothing. I know in the CLI an example of how you pass args to a jar is:
--input file:///home/user/hamlet.txt --output file:///home/user/wordcount_out
But it seems like there is a different way I am missing to do so with the GUI and I am unsuccessful at hunting down documentation related to it.
TL;DR
What is the proper way to submit multiple args via the "Program Arguments" field in the Flink Cluster GUI and what is the proper way to access them in Main() function?
Thanks for any and all help in advance!
Program arguments should be given in flink as shown below
--custom.key.one custom.value.one --custom.key.two custom.value.two
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.