>From the extended info, I see that you have a function called
createStreamingContext() in your code. Somehow that is getting referenced
in in the foreach function. Is the whole foreachRDD code inside the
createStreamingContext() function? Did you try marking the ssc field as
transient?
Here is a significantly different approach. Put the whole function to apply
on each item in an object.
object MyFunctions {
def processItem(enable: Boolean)(item: (Int, (Long, Long)) = {
val (key, (oc, dc)) = item
DebugLogger.log("Original event count = " + oc)
DebugLogger.log("Found "+(oc-dc)+" duplicate(s) in "+oc+"
events")
if (enableOpStat) {
try {
val statBody = Array(("batchCount", oc.toString()),
("duplicateCount", (oc-dc).toString()))
OperationalStatProducer.produce(statBody)
} catch { case e: Exception => DebugLogger.report(e) }
}
}
}
}
And then use that
msgCount.join(ddCount).foreachRDD((rdd: RDD[(Int, (Long, Long))]) => {
val enable = enableOptStat
rdd.foreach(MyFunction.processItem(enable) _ )
}
On Thu, Aug 7, 2014 at 11:52 AM, amit <[email protected]> wrote:
> There is one more configuration option called spark.closure.serializer that
> can be used to specify serializer for closures.
>
> Maybe in the the class you have Streaming Context as a field, so when spark
> tries to serialize the whole class it uses the spark.closure.serializer to
> serialize even the streaming context. Classes like StreamingContext may not
> work if serialized and deserialized in a different JVM(?).
>
> So I see two solutions one is to somehow avoid serializing
> StreamingContext,
> other is to override the default serialization method to serialize only the
> params required by streaming context and recreate it in the serialization
> step from the params
>
>
>
> --
> View this message in context:
> http://apache-spark-user-list.1001560.n3.nabble.com/Spark-1-0-1-NotSerialized-exception-a-bit-of-a-head-scratcher-tp11666p11703.html
> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>