I am having an scala spark application in which I need to switch between streaming from kafka vs kinesis based on the application configuration.
Both the spark API's for kafka streaming (spark-streaming-kafka-0-10_2.11) and kinesis streaming (spark-streaming-kinesis-asl_2.11) returns an InputDStream
on creating a stream, but the value types are different.
Kafka stream creating returns InputDStream[ConsumerRecord[String, String]]
,
whereas, Kinesis stream creating returns InputDStream[Array[Byte]]
Is there any API
that returns a generic InputDStream
irrespective of kafka or kinesis, so that my stream processing can have a generic implementation, instead of having to write separate code for kafka and kinesis.
I tried assigning both the stream to a InputDStream[Any]
, but that did not work.
Appreciate any idea on how this can be done.