出于某种原因,如果我包含一个Twitter接收器并启动流式上下文,我得到以下异常,不知道为什么 如果有人已经遇到过这个问题,或者我做错了什么,有人可以告诉我吗?
java.lang.ArithmeticException: / by zero
at org.apache.spark.streaming.Duration.isMultipleOf(Duration.scala:59)
at org.apache.spark.streaming.dstream.DStream.isTimeValid(DStream.scala:324)
at org.apache.spark.streaming.dstream.DStream$$anonfun$getOrCompute$1.apply(DStream.scala:344)
at org.apache.spark.streaming.dstream.DStream$$anonfun$getOrCompute$1.apply(DStream.scala:344)
at scala.Option.orElse(Option.scala:257)
at org.apache.spark.streaming.dstream.DStream.getOrCompute(DStream.scala:341)
at org.apache.spark.streaming.dstream.ForEachDStream.generateJob(ForEachDStream.scala:47)
at org.apache.spark.streaming.DStreamGraph$$anonfun$1.apply(DStreamGraph.scala:115)
at org.apache.spark.streaming.DStreamGraph$$anonfun$1.apply(DStreamGraph.scala:114)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
at org.apache.spark.streaming.DStreamGraph.generateJobs(DStreamGraph.scala:114)
at org.apache.spark.streaming.scheduler.JobGenerator$$anonfun$3.apply(JobGenerator.scala:248)
at org.apache.spark.streaming.scheduler.JobGenerator$$anonfun$3.apply(JobGenerator.scala:246)
at scala.util.Try$.apply(Try.scala:161)
at org.apache.spark.streaming.scheduler.JobGenerator.generateJobs(JobGenerator.scala:246)
at org.apache.spark.streaming.scheduler.JobGenerator.org$apache$spark$streaming$scheduler$JobGenerator$$processEvent(JobGenerator.scala:181)
at org.apache.spark.streaming.scheduler.JobGenerator$$anon$1.onReceive(JobGenerator.scala:87)
at org.apache.spark.streaming.scheduler.JobGenerator$$anon$1.onReceive(JobGenerator.scala:86)
at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:48)
2016-03-28 10:08:00,112 ERROR [DefaultQuartzScheduler_Worker-8] org.quartz.core.JobRunShell
Job sample_TwitterListener.SocialMedia_sample threw an unhandled Exception:
答案 0 :(得分:0)
最后发现问题是什么,在代码中我正在初始化流上的两个窗口,如下所示
JavaReceiverInputDStream<Status> inputStream = TwitterUtils.createStream(jssc, getAuth());
JavaDStream<String> batchedInput = rawInput.window(new Duration(windowInterval), new Duration(slideInterval));
processStreamData(batchedInput);
private void processStreamData(JavaDStream<String> _input) {
JavaDStream<String> input = _input.window(new Duration(windowInterval), new Duration(slideInterval));
}
因此,第一个窗口流用于获得正确的滑动间隔,但不知何故,第二个窗口的滑动间隔为0毫秒,这导致/零异常。删除第二个窗口操作后,我能够收到推特数据。