scala - 为什么流式查询在 StreamingQueryManager.awaitAnyTermination 之后仍然启动并运行?
问题描述
我想在特定时间后终止火花映射。我正在sqlContext.streams.awaitAnyTermination(long timeoutMs)
为此使用。但是在给定的超时之后映射并没有停止。
我尝试从 azure 事件中心读取数据并提供 2 分钟(120000 毫秒)作为 awaitAnyTermination 方法的超时时间。但映射并没有在 azure databricks 集群上停止。
下面是我的代码。我正在阅读 azure eventthub 并写入控制台和 120000 毫秒来 awaitAnyTermination。
import org.apache.spark.eventhubs._
// Event hub configurations
// Replace values below with yours
import org.apache.spark.eventhubs.ConnectionStringBuilder
val connStr = ConnectionStringBuilder()
.setNamespaceName("iisqaeventhub")
.setEventHubName("devsource")
.setSasKeyName("RootManageSharedAccessKey")
.setSasKey("saskey")
.build
val customEventhubParameters = EventHubsConf(connStr).setMaxEventsPerTrigger(5).setStartingPosition(EventPosition.fromEndOfStream)
// reading from the Azure event hub
val incomingStream = spark.readStream.format("eventhubs").options(customEventhubParameters.toMap).load()
// write to console
val query = incomingStream.writeStream
.outputMode("append")
.format("console")
.start()
// awaitAnyTermination for shutting down the query
sqlContext.streams.awaitAnyTermination(120000)
我期望映射应该在超时后结束。没有错误,但映射没有停止。
解决方案
tl;博士按设计工作。
从官方文档:
awaitAnyTermination(timeoutMs: Long): 布尔值
返回任何查询是否已终止(多个可能已终止)。
换句话说,timeoutMs
除非有异常或stop
.
推荐阅读
- reactjs - 键入“更改事件”
' 不可分配给类型 'ChangeEvent ' 在 React js 中? - database - 警告:无法打开统计文件“pg_stat_tmp/global.stat”:过时的文件句柄
- autodesk-forge - 在 Autodesk Forge 中创建新面板
- android - 我的 Android 工作室可绘制资源文件夹以非常拥挤的方式导入
- angular - 当 aot=true(生产)时 Angular 10 吨构建错误
- javascript - Javascript - 从嵌套数组中删除对象
- flutter - 如何使用 JSON 数据制作表单
- leaflet - 将鼠标悬停在传单中的任何特征上时触发多个特征的事件
- javascript - 如何使用 Selenium Python 在新选项卡中打开 JavaScript 链接?
- apache-spark - hadoop yarn UI中的“队列百分比”指的是什么