【问题标题】:Zeppelin Twitter Streaming Example Not WorkingZeppelin Twitter 流媒体示例不起作用
【发布时间】: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


    【解决方案1】:

    我遇到了同样的问题,我不知道为什么在新的 StreamingContext 修复它之前将 import 语句从顶部移动到右侧,但确实如此。

    import org.apache.spark.streaming._  //moved here from top
    import org.apache.spark.streaming.twitter._  //moved here from top
    val ssc = new StreamingContext(sc, Seconds(2))  //existing
    

    【讨论】:

      【解决方案2】:

      我遇到了类似的问题。使用 FQCN 工作正常,所以我最终使用它作为解决方法。

      【讨论】:

        猜你喜欢
        • 2017-06-23
        • 1970-01-01
        • 2016-10-21
        • 1970-01-01
        • 1970-01-01
        • 2016-03-21
        • 1970-01-01
        • 2013-04-05
        • 2013-01-07
        相关资源
        最近更新 更多