我遇到了一个问题,我试图寻找一个解决方案,但无法达到任何目标,并希望得到任何*指针。
所以我正在尝试将Spark结构化流媒体与Apache Kudu集成,我正在阅读来自Kafka的流并进行一些处理,现在应该写入Kudu表,问题是spark结构化流媒体并不能提供支持一个Kudu接收器(我知道吗?),我正在使用foreach编写器但是只要尝试在" ForeachWriter.process()"中创建一个数据帧。它只是挂起而永远不会继续前进
import org.apache.spark.sql.ForeachWriter
val foreachWriter = new ForeachWriter[Row] {
override def open(partitionId: Long,version: Long): Boolean = {
val mySchema = StructType(Array(
StructField("id", IntegerType),
StructField("value", DoubleType),
StructField("EventTimestamp", TimestampType)
))
true
}
override def process(value: Row): Unit = {
println("values\n------------------")
val spark = SparkSession.builder.appName("Spark-Kafka-Integrations").master("local").getOrCreate()
val valRDD=spark.sparkContext.parallelize(value.toSeq)
val valRDF=valRDD.map(x=>x.toString.split(",").to[List])
println(value)
val valDF=spark.createDataFrame(valRDF)
valDF.show()
println("End values\n///////////////////")
//shoud insert into kudu here
}
override def close(errorOrNull: Throwable): Unit = {
}
}
//count is a Dstream/streaming dataframe
count.writeStream.foreach(foreachWriter).outputMode("complete") .option("truncate", "false").start().awaitTermination()