2
Spark 2.0とZeppelin 0.6.1がインストールされたクラスタがあります。 TwitterUtils.scala
クラスはSparkプロジェクトからApache Bahirに移行しているので、私のZeppelinノートブックでTwitterUtilsを使用することはできません。Apache Zeppelin 0.6.1:Spark 2.0を実行するTwitter Stream App
ここに私のノートの抜粋:
依存関係のロード:
%dep
z.reset
z.load("org.apache.bahir:spark-streaming-twitter_2.11:2.0.0")
DepInterpreter(%dep) deprecated. Remove dependencies and repositories through GUI interpreter menu instead.
DepInterpreter(%dep) deprecated. Load dependency through GUI interpreter menu instead.
res1: org.apache.zeppelin.dep.Dependency = [email protected]
スパーク一部:
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))
私はインポートした後、ノートブックのスパーク一部を実行しようとすると依存関係、私は次の例外が発生します:
<console>:44: error: object twitter is not a member of package org.apache.spark.streaming
import org.apache.spark.streaming.twitter
私はここで間違っていますか? Bahirのドキュメントでもコマンドが使用されています。http://bahir.apache.org/docs/spark/2.0.0/spark-streaming-twitter/
いやああ、トリックをした:あなたはインタプリタの設定に依存関係を追加することができますどちらもスパークやツェッペリンの設定ファイルを変更することはありませんない場合(私は明確にするためのプロパティを省略しました)。私はまだSparkインタプリタの依存関係のセクションを見つけていません!それは今、完璧に動作します、ありがとう! –
「SparkやZeppelinの設定ファイルを変更しないでください」とはどういう意味ですか?これらの依存関係を追加するために変更するために、これらの設定ファイルを正確に見つけることができます。 –
このサイトはあなたにとって役に立ちます。https://zeppelin.apache.org/docs/0.6を使って依存関係を追加する方法を説明します。 1/manual/dependencymanagement.html 「インタプリタへの依存関係のロード」を参照してください。 –