【发布时间】:2017-11-22 00:13:43
【问题描述】:
我正在尝试在 Zeppelin 中运行 Twitter 流媒体示例。在我四处搜索之后,我在 Spark Interpreter 中添加了“org.apache.bahir:spark-streaming-twitter_2.11:2.0.0”。所以我可以让第一部分工作,如:
Apache Zeppelin 0.6.1: Run Spark 2.0 Twitter Stream App
现在我尝试将后半部分添加为:
case class Tweet(createdAt:Long, text:String, screenName:String)
twt.map(status=>
Tweet(status.getCreatedAt().getTime()/1000, status.getText(), status.getUser().getScreenName())
).foreachRDD(rdd=>
rdd.toDF().registerTempTable("tweets")
)
现在我得到了错误:
<console>:56: error: not found: type StreamingContext
val ssc = new StreamingContext(sc, Seconds(2))
^
<console>:56: error: not found: value Seconds
val ssc = new StreamingContext(sc, Seconds(2))
^
<console>:61: error: not found: value Seconds
val twt = tweets.window(Seconds(60))
实际上我添加了案例行,我得到了上述错误。我真的不知道这里发生了什么。
这里有人知道吗?
这里有详细信息 火花:2.0.0 齐柏林飞艇:0.6.2
非常感谢。
================================================ =======================
// All codes for your reference:
import org.apache.spark.streaming.twitter
import org.apache.spark.streaming._
import org.apache.spark.storage.StorageLevel
import scala.io.Source
import scala.collection.mutable.HashMap
import java.io.File
import org.apache.log4j.Logger
import org.apache.log4j.Level
import sys.process.stringSeqToProcess
import org.apache.spark.SparkConf
// ********************************* Configures the Oauth Credentials for accessing Twitter ****************************
def configureTwitterCredentials(apiKey: String, apiSecret: String, accessToken: String, accessTokenSecret: String) {...}
// ***************************************** Configure Twitter credentials ********************************************
val apiKey = ...
val apiSecret = ...
val accessToken = ...
val accessTokenSecret = ...
configureTwitterCredentials(apiKey, apiSecret, accessToken, accessTokenSecret)
// ************************************************* The logic itself *************************************************
val ssc = new StreamingContext(sc, Seconds(2))
val tweets = TwitterUtils.createStream(ssc, None)
val twt = tweets.window(Seconds(60))
twt.print
// above codes work correctly
// If added the following line, it failed with the above error
case class Tweet(createdAt:Long, text:String, screenName:String)
【问题讨论】:
标签: twitter spark-streaming apache-zeppelin