Python 如何捕获pyspark foreachPartition的日志输出?
皮斯帕克 当我在foreachRdd方法中使用print()时,它就工作了Python 如何捕获pyspark foreachPartition的日志输出?,python,pyspark,spark-streaming,Python,Pyspark,Spark Streaming,皮斯帕克 当我在foreachRdd方法中使用print()时,它就工作了 def echo(data): print data .... lines = MQTTUtils.createStream(ssc, brokerUrl, topics) topic_rdd = lines.map(lambda x: get_topic_rdd(x)).filter(lambda x: x[0]!= None) topic_rdd.foreachRDD(lambda x: echo(x)) 我可
def echo(data):
print data
....
lines = MQTTUtils.createStream(ssc, brokerUrl, topics)
topic_rdd = lines.map(lambda x: get_topic_rdd(x)).filter(lambda x: x[0]!= None)
topic_rdd.foreachRDD(lambda x: echo(x))
我可以看到登录控制台上有火花
但是如果我使用foreachPartition方法,它就看不到print()的任何日志
如果我想查看日志,我需要输入不同的分区来查看日志?我可以在单控制台中查看日志吗?顺便说一下,我可以在单控制台中使用scala而不是python查看日志。rdd.foreachRDD运行在驱动程序节点上,该节点将消息发送到终端 rdd.foreachPartition正在worker节点上运行,该节点将消息发送到worker的终端,您看不到这一点 如果您想查看日志,只需将它们另存为文件
topic_rdd = lines.map(lambda x: get_topic_rdd(x)).filter(lambda x: x[0]!= None)
topic_rdd.foreachRDD(lambda x: x.foreachPartition(lambda y: echo(y)))