我创建了一个流媒体环境的配置,并试图在访问此配置open()的方法RichMapFunction。
例子:
Configuration conf = new Configuration();
conf.setBoolean("a", true);
StreamExecutionEnvironment env =
StreamExecutionEnvironment.createLocalEnvironment(8, conf);
DataStreamSource<Integer> source = env.fromElements(5,5,5,5,5);
source.map(new RichMapFunction<Integer, Integer>() {
@Override
public void open(Configuration parameters) throws Exception {
boolean a = parameters.getBoolean("a", false);
super.open(parameters);
}
@Override
public Integer map(Integer value) throws Exception {
return value;
}
}).print();
env.execute();
Run Code Online (Sandbox Code Playgroud)
但是,在调试该open()方法时,我发现配置为空。
我究竟做错了什么?如何RichFunction在流媒体环境中将配置正确传递给 a ?
apache-flink ×1