apache spark流错误

时间:2017-04-05 09:40:24

标签: apache-spark spark-streaming

我在apche spark(流媒体)下使用maven。并使用scala编程。 事实上,我对以下说明有一个小问题:

val sc= new StreamingContext(conf , Seconds(1))

如果我对指令进行处理,则代码是正确的。

这是我的完整代码(网络字数):

import org.apache.spark.SparkConf 
import org.apache.spark.streaming.{Seconds, StreamingContext} 
import org.apache.spark.storage.StorageLevel 

object WordCountStreaming { 
  def main(args: Array[String]): Unit = { 
    val conf = new SparkConf() .setMaster("local")
           .setAppName("WordCountStreaming") 
           .set("spark.driver.allowMultipleContexts","true"); val sc= new 
    StreamingContext(conf , Seconds(1)) val lines = 
      sc.socketTextStream(args(0), args(1).toInt, 
    StorageLevel.MEMORY_AND_DISK_SER) sc.start() sc.awaitTermination() 
  }
}

1 个答案:

答案 0 :(得分:0)

在这里,您可以尝试给出#34;本地[*]"或者"本地[2]"在master中,因为spark streaming cant适用于单个线程,所以如果你在本地运行它,请在master中使用多个线程进行尝试。

相关问题