2016-10-02 24 views
0

我正在运行一个简单的SparkStreaming应用程序,该应用程序包括通过套接字服务器将消息发送到SparkStreaming上下文并打印它们。 这是我的代码,我在的IntelliJ IDE中运行:Spark Streaming:输入已收到但未处理

SparkConf sparkConfiguration= new SparkConf().setAppName("DataAnalysis").setMaster("spark://IP:7077"); 
    JavaStreamingContext sparkStrContext=new JavaStreamingContext(sparkConfiguration, Durations.seconds(1)); 
    JavaReceiverInputDStream<String> receiveData=sparkStrContext.socketTextStream("localhost",5554); 

我运行在一个独立的集群模式,该应用程序,用一个工人(Ubuntu的VM)和一个主(我的Windows主机)。 这是问题:当我运行应用程序,我看到它成功地连接到主,但它并没有打印任何行:

enter image description here

它只是停留永久这种方式。 如果我去星火UI,我发现SparkStreaming上下文正在接收的投入,但他们没有被处理:

enter image description here

enter image description here

有人能帮助我吗?非常感谢。

+0

你是如何启动您的应用程序?客户端模式还是集群模式? –

回答

0

您需要执行以下操作。

sparkStrContext.start();    // Start the computation 
sparkStrContext.awaitTermination(); // Wait for the computation to terminate 

一旦你做到这一点,你需要在端口5554来发布消息,这首先需要使用运行Netcat的(在大多数类Unix系统中发现一个小工具)作为数据服务器和开始推送流。

例如,您需要像下面这样做。

1号航站楼:

# Running Netcat 

$ nc -lk 5554 

hello world 

2号航站楼:运行你的流节目

------------------------------------------- 
Time: 1357008430000 ms 
------------------------------------------- 
hello world 
... 



    ... 

您可以检查类似的例子here

+0

谢谢,但我已经开始了火花流传输环境,只是选择不写它,因为我认为这很明显。这不是我的第一个火花项目。 –

+0

你正在运行哪种模式? –

+0

我正在集群模式下运行。在本地模式下,一切运行良好,但不是在集群模式下 –

相关问题