检测连接火花失去流 [英] detecting connection lost in spark streaming

查看:135
本文介绍了检测连接火花失去流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在与Apache的火花流工作。我想知道如何检测连接是否丢失或无法与外部数据源,所以我们可能会停止流并重新启动连接到数据源。

I am currently working with apache spark streaming. I want to know how to detect whether the connection has lost or not with the external data source, so that we may stop streaming and restart connecting to data source.

在此先感谢您的帮助。

推荐答案

侦听器添加到您的接收器,当接收器已经停止停止流上下文。

Add a listener to the receiver you have and stop the streaming context when the receiver has stopped.

例如:

streamContext.addStreamingListener(new StreamingListener() {

        @Override
        public void onReceiverStopped(StreamingListenerReceiverStopped arg0) {
            streamContext.stop(true, true);
        }
}

这篇关于检测连接火花失去流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆