Apache Spark流媒体 - Timeout长期运行批处理

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

我正在设置Apache Spark长时间运行的流作业,以使用InputDStream执行(非并行化)流式传输。

我想要实现的是,当队列中的批处理花费太长时间(基于用户定义的超时)时,我希望能够跳过批处理并完全放弃它 - 并继续执行其余的操作。

我无法在spark API或在线中找到这个问题的解决方案 - 我研究了使用StreamingContext awaitTerminationOrTimeout,但这会在超时时杀死整个StreamingContext,而我想要做的就是跳过/杀死当前批处理。

我也考虑过使用mapWithState,但这似乎不适用于这个用例。最后,我正在考虑设置StreamingListener并在批处理启动时启动计时器,然后在达到某个超时阈值时停止/跳过/终止批处理,但似乎仍然没有办法杀死批处理。

谢谢!

apache-spark timeout streaming spark-streaming dstream
1个回答
0
投票

我从yelp中看到了一些文档,但我自己没有这样做过。

使用UpdateStateByKey(update_func)mapWithState(stateSpec)

  1. 首次看到事件并初始化状态时附加超时
  2. 如果状态到期则删除状态 def update_function(new_events, current_state): if current_state is None: current_state = init_state() attach_expire_datetime(new_events) ...... if is_expired(current_state): return None //current_state drops? if new_events: apply_business_logic(new_events, current_state)

这看起来结构化流水印也会在超时时丢弃事件,如果这可能适用于您的作业/阶段超时下降。

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