Spark手册中推荐使用共享静态资源(例如连接池)在工作代码内。
示例来自manual http://spark.apache.org/docs/latest/streaming-programming-guide.html#design-patterns-for-using-foreachrdd:
dstream.foreachRDD { rdd =>
rdd.foreachPartition { partitionOfRecords =>
// ConnectionPool is a static, lazily initialized pool of connections
val connection = ConnectionPool.getConnection()
partitionOfRecords.foreach(record => connection.send(record))
ConnectionPool.returnConnection(connection) // return to the pool for future reuse
}
}
当出现以下情况时该怎么办静态资源需要在执行器关闭之前释放/关闭?没有地方可以打电话close()
功能。尝试了关闭挂钩,但似乎没有帮助。
实际上目前我的工作进程变成了zombie,因为我使用的共享资源创建了一个非守护线程池(HBase 异步客户端),这意味着 JVM 会永远挂起。
我正在使用 Spark 流优雅关闭呼叫司机:
streamingContext.stop(true, true);
EDIT:
Spark JIRA 中似乎已经存在一个处理相同问题的问题
https://issues.apache.org/jira/browse/SPARK-10911 https://issues.apache.org/jira/browse/SPARK-10911
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)