Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (23 sloc) 899 Bytes
import java.util.UUID
import org.apache.spark.sql.streaming.ProcessingTime
import util.Boot
object KafkaToHdfsUsingSpark extends Boot {
val checkpointLocation = "/tmp/temporary-" + UUID.randomUUID.toString
val upstream = spark.readStream
.option("kafka.bootstrap.servers", "localhost:9092")
.option("subscribe", "test,Airport,Airports,Carriers,Planedata")
.option("startingOffsets", "earliest")
.selectExpr("topic", "CAST(value AS STRING)")
val downstream = upstream
.partitionBy("topic") // Partition by topic. it will create directory by topic name topic=Airport,topic=Carriers,topic=Planedata etc
.option("path", "/tmp/data")
.option("checkpointLocation", checkpointLocation)
You can’t perform that action at this time.