Saving Data only if Dstream is not empty

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Saving Data only if Dstream is not empty

Hafiz Mujadid
This post has NOT been accepted by the mailing list yet.
Hi Experts!

I want to save DStream to HDFS only if it is not empty such that it contains some kafka messages to be stored. What is an efficient way to do this.

           var data = KafkaUtils.createStream[Array[Byte], Array[Byte], DefaultDecoder, DefaultDecoder]    (ssc, params, topicMap, StorageLevel.MEMORY_ONLY).map(_._2)


    val streams = data.window(Seconds(interval*4), Seconds(interval*2)).map(x => new String(x))
    //streams.foreachRDD(rdd=>rdd.foreach(println))

//what condition can be applied here to store only non empty DStream
    streams.saveAsTextFiles(sink, "msg")
Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Saving Data only if Dstream is not empty

manasdebashiskar-2
This post has NOT been accepted by the mailing list yet.
CONTENTS DELETED
The author has deleted this message.