Bey*_*Gül 2 scala apache-spark spark-streaming
您好,我开始了火花流学习,但我无法运行简单的应用程序我的代码在这里
import org.apache.spark._
import org.apache.spark.streaming._
import org.apache.spark.streaming.StreamingContext._
val conf = new SparkConf().setMaster("spark://beyhan:7077").setAppName("NetworkWordCount")
val ssc = new StreamingContext(conf, Seconds(1))
val lines = ssc.socketTextStream("localhost", 9999)
val words = lines.flatMap(_.split(" "))
Run Code Online (Sandbox Code Playgroud)
我收到如下错误
scala> val newscc = new StreamingContext(conf, Seconds(1))
15/10/21 13:41:18 WARN SparkContext: Another SparkContext is being constructed (or threw an exception in its constructor). This may indicate an error, since only one SparkContext may be running in this JVM (see SPARK-2243). The other SparkContext was created at:
Run Code Online (Sandbox Code Playgroud)
谢谢
如果你正在使用spark-shell,而且看起来你确实这样做了,你不应该StreamingContext使用SparkConf对象实例化,你应该sc直接传递shell-provided。
这意味着:
val conf = new SparkConf().setMaster("spark://beyhan:7077").setAppName("NetworkWordCount")
val ssc = new StreamingContext(conf, Seconds(1))
Run Code Online (Sandbox Code Playgroud)
变成,
val ssc = new StreamingContext(sc, Seconds(1))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7534 次 |
| 最近记录: |