hyj 发表于 2017-7-21 15:46 弄好了………… 我忘了说了我写的是一个socket…客户端没起…… |
remarkzhao 发表于 2017-7-21 12:23 跑一下官方提供的wordcount例子。看看什么情况。 |
hyj 发表于 2017-7-21 12:17 没有,还是跟没修改前一样 停在那。 |
修改后,提交有什么问题吗 |
sstutu 发表于 2017-7-21 10:43 package org.apache.spark.examples.streaming import java.io.{PrintWriter} import java.net.ServerSocket import scala.io.Source object DataSourceSocket { def index(length: Int) = { val rdm = new java.util.Random rdm.nextInt(length) } def main(args: Array[String]) { val fileName = "/root/tools/spark/mycode/streaming/word.txt" val lines = Source.fromFile(fileName).getLines.toList val rowCount = lines.length val listener = new ServerSocket(9999) while (true) { val socket = listener.accept() new Thread() { override def run = { println("Got client connected from: " + socket.getInetAddress) val out = new PrintWriter(socket.getOutputStream(), true) while (true) { Thread.sleep(1000) val content = lines(index(rowCount)) println(content) out.write(content + '\n') out.flush() } socket.close() } }.start() } } } 改过后的代码。 |
sstutu 发表于 2017-7-21 10:43 如果是local模式 为什么要master?我认为只有集群才会有需要啊。。一个是管理的 另几个是worker |
remarkzhao 发表于 2017-7-21 10:33 最好上图,另外一点漏掉了master。即使本地模式,也需要master。还有类,是否有空格,加引号的作用是什么。 |
sstutu 发表于 2017-7-21 10:15 [root@hadoop001 streaming]# spark-submit --class "org.apache.spark.examples.streaming.DataSourceSocket" /root/tools/spark/mycode/streaming/target/scala-2.11/simple-project_2.11-1.0.jar ^C[root@hadoop001 streaming]spark-submit --class "org.apache.spark.examples.streaming.DataSourceSocket" --master local[3] /root/tools/spark/mycode/streaming/target/scala-2.11/simple-project_2.11-1.0.jar 还是这个样子。。。 |