我已经检查了http://apache-spark-user-list.1001560.n3.nabble.com/RDD-to-DStream-td11145.html,并想在JAVA中做同样的事情。这样做的正确方法是什么?
答案 0 :(得分:2)
根据javadoc你可以这样做。
//Create list
List<SomePojo> somePojoList = ...;
//Create rdd
JavaRDD<SomePojo> rdd = streamingContext.sparkContext().parallelize( somePojoList);
java.util.Queue<JavaRDD<SomePojo>> queue = new LinkedList<JavaRDD<SomePojo>>();
queue.add( rdd );
JavaDStream<SomePojo> machineDataDstream = streamingContext.queueStream( queue );