我正在尝试打印一个简单的 DStream,但没有成功。请参阅下面的代码。我在 Azure 中使用 Databricks 笔记本。
import org.apache.spark.streaming.{ StreamingContext, Seconds }
val ssc = new StreamingContext(sc, batchDuration = Seconds(5))
ssc.checkpoint(".")
val rdd = sc.parallelize(0 to 3)
import org.apache.spark.streaming.dstream.ConstantInputDStream
val stream = new ConstantInputDStream(ssc, rdd)
println("start")
stream.print()
ssc.start()
输出是:
start
warning: there was one feature warning; re-run with -feature for details
import org.apache.spark.streaming.{StreamingContext, Seconds}
ssc: org.apache.spark.streaming.StreamingContext = org.apache.spark.streaming.StreamingContext@4d01c7b1
rdd: org.apache.spark.rdd.RDD[Int] = MapPartitionsRDD[1] at map at command-3696830887613521:7
import org.apache.spark.streaming.dstream.ConstantInputDStream
stream: org.apache.spark.streaming.dstream.ConstantInputDStream[Int] = org.apache.spark.streaming.dstream.ConstantInputDStream@12b9db22
我期待以一种或另一种方式看到 0,1,2。
我也试过添加
ssc.awaitTermination()