我有一个Spark结构化的流应用程序,需要在运行时对其进行监视。因此,我扩展了StreamingQueryListener
并实现了其抽象方法,如下所示:
override def onQueryStarted(queryStarted: StreamingQueryListener.QueryStartedEvent): Unit = {
println("Query started: " + queryStarted.id)
}
override def onQueryTerminated(queryTerminated: StreamingQueryListener.QueryTerminatedEvent): Unit = {
println("Query terminated: " + queryTerminated.id)
}
override def onQueryProgress(queryProgress: StreamingQueryListener.QueryProgressEvent): Unit = {
println("Query made progress: " + queryProgress.progress)
}
在这里,我可以看到查询的进度,但是不确定流查询是否达到onQueryStarted
和onQueryTerminated
。这些方法何时调用以及如何工作?