detecting connection lost in spark streaming

寵の児 提交于 2019-12-24 02:10:01

问题


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.

Thanks in advance for any help


回答1:


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

example:

streamContext.addStreamingListener(new StreamingListener() {

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


来源:https://stackoverflow.com/questions/27272141/detecting-connection-lost-in-spark-streaming

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!