2015-09-04 53 views
3
import org.apache.spark.streaming.{Seconds, StreamingContext} 
import org.apache.spark.streaming.eventhubs.EventHubsUtils 
import sqlContext.implicits._ 

val ehParams = Map[String, String](
    "eventhubs.policyname" -> "Full", 
... 
) 

val ssc = new StreamingContext(sc, Seconds(2)) 
val stream = EventHubsUtils.createUnionStream(ssc, ehParams) 
val cr = stream.window(Seconds(6)) 

case class Message(msg: String) 
stream.map(msg=>Message(new String(msg))).foreachRDD(rdd=>rdd.toDF().registerTempTable("temp")) 

stream.print 
ssc.start 

这上面启动并运行良好,但我似乎无法阻止它。任何对%sql show表格的调用都会冻结。如何停止在Apache中火花的StreamingContext上齐柏林

如何停止上面的StreamingContext?

+0

不知道为什么低于2的答案被低估了......但是你可以用ssc.stop(true)和/或ssc.stop(true,true)或者你选择的是 – sagarthapa

回答

3

ssc.stop也杀死Spark上下文,需要重新启动解释器。

改为使用ssc.stop(stopSparkContext=false, stopGracefully=true)