Hi!
I am using a library that depends on a certain environment variable set
(mandatorily). Now, I've exported this variable in my environment but
somehow it's not being read by the task manager. Following is the exception
I get when I try to run the job:
Caused by: com.example.MyCustomException: Env token is null
at com.example.AerospikeSink.open(AerospikeSink.java:47)
at
org.apache.flink.api.common.functions.util.FunctionUtils.openFunction(FunctionUtils.java:36)
at
org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator.open(AbstractUdfStreamOperator.java:102)
at
org.apache.flink.streaming.api.operators.StreamSink.open(StreamSink.java:48)
at
org.apache.flink.streaming.runtime.tasks.StreamTask.openAllOperators(StreamTask.java:424)
at
org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:290)
at org.apache.flink.runtime.taskmanager.Task.run(Task.java:711)
at java.lang.Thread.run(Thread.java:745)
Here's the code that throws this exception:
@Override
public void open(Configuration config) throws Exception {
if (System.getenv("API_TOKEN") == null) {
throw new MyCustomException("Env token is null");
}
}
My question: Is there an alternative to System.getenv() that I can use to
access environment variables inside of flink task?
( P.S. I've only copied relevant code snippet to avoid confusion. I do
intend to use API_TOKEN later on. )
--
Warm Regards,
Abhishek Jain