0
iam在運行下面的代碼時得到上述錯誤我觀察到有一些可序列化的問題,但我cudn't完全追蹤。任何一個解釋我能在這裏做的。在此先感謝。異常在線程「主」org.apache.spark.SparkException:任務不可序列化「
enter code here
def checkforType(json:String):String={
val parsedjson = parse(json)
val res=(parsedjson \\ "Head" \\ "Type").extract[String]
(res)
}
val dstream = KafkaUtils.createStream(ssc, zkQuorum, group, Map("topic" -> 1)).map(_._2)
val pType = dstream.map(checkforType)
pType.map(rdd => {
val pkt= rdd.toString()
if(pkt.equals("P300")) {
val t300=dstream.map(par300)
t300.print()
}else if(pkt.equals("P30")) {
val t30=dstream.map(par30)
t30.print()
}else if(pkt.equals("P6")) {
val t6=dstream.map(par6)
t6.print()
}
})