【发布时间】:2018-10-26 21:07:34
【问题描述】:
我有一个 Flink 流应用程序,它需要能够在特定键控流上“暂停”和“取消暂停”处理。 “处理”意味着只对流执行一些简单的异常检测。
我们正在考虑的流程是这样的:
命令流,ProcessCommand、PauseCommand 或 ResumeCommand,每个命令都有一个用于 KeyBy 的 id。
ProcessCommands 会在处理之前检查密钥是否暂停,如果没有则缓冲。
PauseCommands 将暂停密钥的处理。
ResumeCommands 将取消暂停键的处理并刷新缓冲区。
这个流程看起来合理吗?如果是,我可以使用split 运算符之类的东西来实现吗?
示例流,省略了单个记录时间戳:
[{command: process, id: 1}, {command: pause, id: 1}, {command: process, id: 1}, {command: resume, id: 1}, {command: process, id: 1}]
Flow:
=>
{command: process, id: 1} # Sent downstream for analysis
=>
{command: pause, id: 1} # Starts the buffer for id 1
=>
{command: process, id: 1} # Buffered into another output stream
=>
{command: resume, id: 1} # Turns off buffering, flushes [{command: process, id: 1}] downstream
=>
{command: process, id: 1} # Sent downstream for processing as the buffering has been toggled off
【问题讨论】:
-
那么,您的实际流(包含记录以及
id)将接收命令作为记录的一部分,并且将使用这些命令控制流处理对吗? -
是的,完全正确@shriyog。每条记录都有一个
id和一个command。 -
process和pause命令有什么区别?您能否举一个展示输入命令流和预期行为的示例? -
@shriyog,这些编辑是否能更好地解释?感谢您的帮助!
标签: apache-flink flink-streaming