Flink 1.16 idea intellij中运行web ui
创始人
2025-05-28 15:01:59
0

  1. 在pom.xml文件中添加flink-runtime-web依赖


org.apache.flink
flink-runtime-web
1.16.1
provided
  1. 在初始化执行环境时传入的配置中添加rest.port项

public static void main(String[] args) throws Exception {
//获取Flink的运行环境
Configuration conf = new Configuration();
conf.setInteger(RestOptions.PORT, 0);//设置为0 每次启动端口都不一样 也可以设置一个固定的端口 如8081
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
//checkpoint配置
env.enableCheckpointing(5000);
env.getCheckpointConfig().setCheckpointingMode(CheckpointingMode.EXACTLY_ONCE);
env.getCheckpointConfig().setMinPauseBetweenCheckpoints(500);
env.getCheckpointConfig().setCheckpointTimeout(60000);
env.getCheckpointConfig().setMaxConcurrentCheckpoints(1);

这样启动后就可以在日志中看到web ui的链接了:

15:26:07.833 [main] INFO org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - Web frontend listening at http://localhost:40673.15:26:07.833 [mini-cluster-io-thread-1] INFO org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - http://localhost:40673 was granted leadership with leaderSessionID=f08dd1d9-359f-4403-84af-79d2e7e41c9b15:26:07.834 [mini-cluster-io-thread-1] INFO org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedLeaderService - Received confirmation of leadership for leader http://localhost:40673 , session=f08dd1d9-359f-4403-84af-79d2e7e41c9b15:26:07.843 [main] INFO org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedLeaderService - Proposing leadership to contender LeaderContender: DefaultDispatcherRunner15:26:07.844 [main] INFO org.apache.flink.runtime.resourcemanager.ResourceManagerServiceImpl - Starting resource manager service.15:26:07.844 [main] INFO org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedLeaderService - Proposing leadership to contender LeaderContender: ResourceManagerServiceImpl15:26:07.844 [mini-cluster-io-thread-2] INFO org.apache.flink.runtime.dispatcher.runner.DefaultDispatcherRunner - DefaultDispatcherRunner was granted leadership with leader id 07b5356f-c8c9-4b20-99b0-7491f48c89b4. Creating new DispatcherLeaderProcess.15:26:07.845 [pool-3-thread-1] INFO

在浏览器中访问对应链接就可以看到web ui了

Flink 1.16.1亲测可用, 先前的版本可能还需要使用

Configurationconf=newConfiguration();env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(conf);

但这样发布运行时还需要改下代码,1.16.1的代码里看了下createLocalEnvironmentWithWebUI方法:

做的事情也无非就时往配置项里添加了个rest.port.

所以调用getExecutionEnvironment(conf) 时直接设置下这个参数就行了,需要发布运行时也不用再修改代码。

相关内容

热门资讯

Redis(十):主从模式 前言 上一篇介绍了 Redis 应对并发问题的方案。这节开始介绍 Redis 的主从模式。 由于 R...
C指针:程序员的望远镜 C指针:程序员的望远镜一、什么是指针1.1 指针的定义1.2 指针和普通变量的区别1....
牛客网Java面试题及答案整理... 学习如逆水行舟,尤其是 IT 行业有着日新月异的节奏,我们更要抓紧每一次...
江西宜春智慧停车欠费清缴享7折... 极目新闻记者 杜光然 近日,江西网友发视频称,宜春智慧停车公司开启了端午缴费特惠活动,车主享停车费7...
律数科技申请基于区块链的小额金... 金融界2025年5月31日消息,国家知识产权局信息显示,北京律数科技有限公司申请一项名为“一种基于区...
好用的5款国产低代码平台介绍 一、云程低代码平台 云程低代码平台是一款基于springboot、vue.js技术的企业级低代码...
【数据结构第三章】- 队列 目录 一、队列的定义和特点 二、循环队列 2.1 - CircularQueue.h 2.2 - C...
如何将pdf文件压缩?pdf压... PDF是一种常见的文档格式,因为包括文本格式和图像,我们往往采用这种格式...
0X30数学知识 - 质数 定义: 若一个正整数无法被除了1和它自身之外的任何自然数整除,则称该数...
中方代表:俄乌冲突战场上武器数... 当地时间5月30日,中国常驻联合国副代表耿爽在安理会审议向乌克兰提供武器问题时发言指出,战场上武器数...