Running web ui in Flink 1.16 idea intellij

  1. Add flink-runtime-web dependency in pom.xml file

<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-runtime-web</artifactId>
<version>1.16.1</version>
<scope>provided</scope>
</dependency>
  1. Add the rest.port item to the configuration passed in when the execution environment is initialized

public static void main(String[] args) throws Exception { //
Get Flink's operating environment
Configuration conf = new Configuration(); conf.setInteger(RestOptions.PORT , 0);//Set to 0 and the port will not be activated every time You can also set a fixed port such as 8081 StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment ( conf); //checkpoint configuration env.enableCheckpointing(5000); env.getCheckpointConfig().setCheckpointingMode(CheckpointingMode.EXACTLY_ONCE ) ; env.get CheckpointConfig(). setMinPauseBetweenCheckpoints(500); env.getCheckpointConfig().setCheckpointTimeout(60000); env.getCheckpointConfig().setMaxConcurrentCheckpoints(1);







After starting, you can see the web ui link in the log:

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

Visit the corresponding link in the browser to see the web ui

Flink 1.16.1 pro-test is available, previous versions may also need to use

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

However, the code needs to be changed when publishing and running in this way. In the code of 1.16.1, look at the createLocalEnvironmentWithWebUI method:

What I do is nothing more than adding a rest.port to the configuration item.

So just set this parameter directly when calling getExecutionEnvironment (conf), and you don't need to modify the code when you need to publish the runtime.

Guess you like

Origin blog.csdn.net/tianlangstudio/article/details/129557341