Skip to content

Instantly share code, notes, and snippets.

@vinothchandar
Created July 26, 2015 02:40
Show Gist options
  • Save vinothchandar/9483c275818635b413e2 to your computer and use it in GitHub Desktop.
Save vinothchandar/9483c275818635b413e2 to your computer and use it in GitHub Desktop.
import com.uber.hacman.CountingDirectDStream
import org.apache.spark.SparkConf
import org.apache.spark.streaming.{Milliseconds, Seconds, StreamingContext}
/**
*/
object CountingDStreamTest {
def main(args: Array[String]) = {
val sparkConf = new SparkConf().setAppName("CountingDStreamTest").setMaster("local[2]");
val ssc = new StreamingContext(sparkConf, Milliseconds(100))
val countingDStream = new CountingDirectDStream(ssc, 0)
countingDStream.foreachRDD(countRDD => {
countRDD.foreach(count => {
println(s"Received count : ${count}")
})
})
ssc.start()
ssc.awaitTermination()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment