0
点赞
收藏
分享

微信扫一扫

Flink系列之:Scala代码实现DataStream,并使用dashboard的Web UI页面查看任务状态



Flink系列之:Scala代码实现DataStream,并使用dashboard的Web UI页面查看任务状态

  • 一、flink dashboard Web UI
  • 二、Scala代码实现DataStream
  • 三、开启终端产生数据
  • 四、Web UI页面详细查看任务状态


一、flink dashboard Web UI

Flink系列之:Scala代码实现DataStream,并使用dashboard的Web UI页面查看任务状态_Web UI页面查看任务状态

二、Scala代码实现DataStream

import org.apache.flink.configuration.Configuration
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment

object WordCountStreamingByScala {
  def main(args: Array[String]): Unit = {
    //获取环境
    val env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration())

    //获取数据源
    val source = env.socketTextStream("localhost", 18888)

    //开始转换
    import org.apache.flink.api.scala._;

    source.flatMap(_.split(" ")).map((_,1)).keyBy(0).sum(1).print()

    //开启流式处理
    env.execute("WordCountStreamingByScala" + System.currentTimeMillis())

  }

}

三、开启终端产生数据

nc -l 18888
hi hello
hello red yellow green black

程序输出如下所示:

5> (hi,1)
4> (hello,1)
8> (yellow,1)
11> (red,1)
8> (green,1)
4> (hello,2)
11> (black,1)

四、Web UI页面详细查看任务状态

Flink系列之:Scala代码实现DataStream,并使用dashboard的Web UI页面查看任务状态_Flink系列_02


举报

相关推荐

0 条评论