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) 时直接设置下这个参数就行了,需要发布运行时也不用再修改代码。

相关内容

热门资讯

从“纸上政策”到“落地实效” ... 在建湖县高新技术园区,文辰精密科技有限公司的生产车间内机器轰鸣,工人们正忙着赶制新一批订单。这家专注...
跨省办公更便捷!京津冀律师驿站... 11月22日至23日,京津冀律师驿站在北京启动“百千万行动计划”,计划通过建立百家律所联系点,推动千...
梅花生物:因侵害专利权被味之素... 北京商报讯(记者 郭秀娟 王悦彤) 11月23日,北京商报记者获悉,近日梅花生物发布公告称,公司及全...
吉林益豆食品有限公司:依托互市... 珲春地处中、俄、朝三国交界,得天独厚的地理位置,使其成为连接东北亚的“黄金通道”。在这里,吉林益豆食...
北京外国语大学教授宁强在敦煌因... 中新网11月23日电 据“北京外国语大学国新学院”微信公众号消息,11月23日,北京外国语大学国际新...
上海市民建议“推行地铁月票制度... 近日 有网友在人民网“领导留言板”留言 希望上海地铁推出月票制度 上海申通地铁集团有限公司答复表示 ...
原创 中... 近期,日本首相高市早苗首次明确表态,必要时将武力介入台海,这一惊人的言论犹如对历史的挑衅,并直接威胁...
女儿为留学想卖掉其名下的房子,... 父母已离婚多年 很少与父亲见面 一直是姑姑 照顾病重的父亲…… 女儿因求学花销 急需卖房变现 200...
《最高人民法院关于审理建设工程... 为深入贯彻习近平法治思想,认真落实党的二十届四中全会精神,正确审理建设工程施工合同纠纷案件,统一法律...
【金昌】老百姓的“声音”,是这... 编 者 按 人民,是推动经济社会发展的主角;基层,是新闻永不枯竭的源头。为深入学习和践行“四力”要求...