flink 是否总是为相同的键值返回相同的分区状态对象?

问题描述 投票:0回答:1

如果我们在 KeyedStream#process 的 KeyedProcessFunction 中填充状态对象,例如

    new KeyedProcessFunction<String, Rule, Rule>() {
                  private MapState<String, ArrayList<Rule>> rulesState;
                  @Override
                  public void open(Configuration parameters) throws Exception {
                    super.open(parameters);
                    rulesState = getRuntimeContext().getMapState(Descriptors.rulesPerCustomerDescriptor);
                  }
                  @Override
                  public void processElement(Rule value, KeyedProcessFunction<String, Rule, Rule>.Context ctx, Collector<Rule> out) throws Exception {
                    out.collect(value);
                    rulesState.put();
                  }
                });

如果另一个 KeyedStream#process 方法都使用相同的键进行分区,我们会从另一个 KeyedStream#process 方法中获得相同的状态对象吗?

apache-flink flink-streaming
1个回答
0
投票

不。状态对于建立状态的特定运营商而言是本地的。无法从其他任何地方访问它。

© www.soinside.com 2019 - 2024. All rights reserved.