apache-flink - 如何在 KeyedStream 中获取槽分布
问题描述
我使用 flink 版本 1.13.0。
出于某种原因,我需要在 taskmanager 中跟踪指定键的日志,但我不知道该键将分配给哪个 taskmanager。
所以我想知道当我使用 keyBy 函数时将分配给哪个插槽,是否有一些分区算法可以通过键计算插槽 id?
解决方案
这发生在几个步骤中。键映射到键组,键组分配给槽。您将在org.apache.flink.runtime.state.KeyGroupRangeAssignment
. 从这里开始:
/**
* Assigns the given key to a parallel operator index.
*
* @param key the key to assign
* @param maxParallelism the maximum supported parallelism, aka the number of key-groups.
* @param parallelism the current parallelism of the operator
* @return the index of the parallel operator to which the given key should be routed.
*/
public static int assignKeyToParallelOperator(Object key, int maxParallelism, int parallelism) {
Preconditions.checkNotNull(key, "Assigned key must not be null!");
return computeOperatorIndexForKeyGroup(
maxParallelism, parallelism, assignToKeyGroup(key, maxParallelism));
}
推荐阅读
- reactjs - 反应钩子形式:materail ui:Textfield:onSubmit,未在数据中传递Filelist
- jquery - 根据jquery中的总销售额显示佣金步骤
- react-native - 在视图中滚动时禁用滚动反应本机
- c++ - 如何实现创建递归 lambda 并返回它的方法
- algorithm - 所有 O(n) 算法也是 O(n²) 吗?
- reactjs - MUI Datagrid:将标题和网格主体分开为不同的组件
- python - 在 python 的生成器函数中引发的 StopIteration 异常处理
- java - 如何有效地从列表中删除
- javascript - 调整 iframe 大小以适应父 div
- typescript - 从 TypeScript 中的模板文字类型中删除字符串