안녕하세요 저는 스파크와 스칼라에 처음이에요.트위터를위한 스파크 실행 스트리밍
object TwitterStreaming {
def main(args: Array[String]): Unit = {
if (args.length < 1) {
System.err.println("WrongUsage: PropertiesFile, [<filters>]")
System.exit(-1)
}
StreamingExamples.setStreaningLogLevels()
val myConfigFile = args(0)
val batchInterval_s = 1
val fileConfig = ConfigFactory.parseFile(new File(myConfigFile))
val appConf = ConfigFactory.load(fileConfig)
// Set the system properties so that Twitter4j library used by twitter stream
// can use them to generate OAuth credentials
System.setProperty("twitter4j.oauth.consumerKey", appConf.getString("consumerKey"))
System.setProperty("twitter4j.oauth.consumerSecret", appConf.getString("consumerSecret"))
System.setProperty("twitter4j.oauth.accessToken", appConf.getString("accessToken"))
System.setProperty("twitter4j.oauth.accessTokenSecret", appConf.getString("accessTokenSecret"))
val sparkConf = new SparkConf().setAppName("TwitterStreaming").setMaster(appConf.getString("SPARK_MASTER"))//local[2]
val ssc = new StreamingContext(sparkConf, Seconds(batchInterval_s)) // creating spark streaming context
val stream = TwitterUtils.createStream(ssc, None)
val tweet_data = stream.map(status => TweetData(status.getId, "@" + status.getUser.getScreenName, status.getText.trim()))
tweet_data.foreachRDD(rdd => {
println(s"A sample of tweets I gathered over ${batchInterval_s}s: ${rdd.take(10).mkString(" ")} (total tweets fetched: ${rdd.count()})")
})
}
}
case class TweetData(id: BigInt, author: String, tweetText: String)
내 오류 : 내가 잘못 곳
Exception in thread "main" com.typesafe.config.ConfigException$WrongType:/WorkSpace/InputFiles/application.conf: 5: Cannot concatenate object or list with a non-object-or-list, ConfigString("local") and SimpleConfigList([2]) are not compatible
at com.typesafe.config.impl.ConfigConcatenation.join(ConfigConcatenation.java:116)
어느 한이 코드를 확인하고 말해 줄 수 나는 스파크를 통해 일부 트윗은 다음 코드로 스트리밍 스트리밍하기 위해 노력하고있어?
@gsamaras ... 어떤 일이 그렇게 잘못인가? – Anji
나에 따르면 오류가 SPARK_MASTER로 "local [2]"을 전달하는 중입니다. SPARK_MASTER를 설정하는 방법이있는 경우 – Anji
설정 파일 (SPARK_MASTER가있는 설정 파일)에 관련 줄을 표시하십시오. 형식을 위반 한 것으로 보입니다 'typesafe.config'에 의해 예상됩니다. 파일의 내용과 설정 파일을로드하는 두 줄의 코드 만 포함하도록 질문 범위를 좁힐 수 있습니다. 예외가있는 곳에서 나머지 부분은 필요 없습니다. –