CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-apache-flink--flink-runtime-web-2-12

Apache Flink Web Dashboard - Provides a web-based user interface for monitoring and managing Apache Flink jobs and runtime.

Pending
Overview
Eval results
Files

web-server-bootstrap.mddocs/

Web Server Bootstrap

Core infrastructure for setting up and managing the Netty-based web server that provides the foundation for embedding Flink's web interface in applications. The WebFrontendBootstrap class handles all aspects of server lifecycle management.

Core Imports

import org.apache.flink.runtime.webmonitor.utils.WebFrontendBootstrap;
import org.apache.flink.runtime.rest.handler.router.Router;
import org.apache.flink.runtime.io.network.netty.SSLHandlerFactory;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.shaded.netty4.io.netty.bootstrap.ServerBootstrap;
import org.slf4j.Logger;
import java.io.File;

Capabilities

WebFrontendBootstrap

Main bootstrap class for setting up the Netty-based web server with routing, SSL support, and configuration management.

/**
 * Bootstrap class for the Netty-based web server providing Flink's web interface.
 * Handles server setup, configuration, and lifecycle management.
 */
public class WebFrontendBootstrap {
    /**
     * Create a new web frontend bootstrap with full configuration.
     * 
     * @param router The router for handling HTTP requests
     * @param log Logger instance for server operations
     * @param directory Directory for file uploads (JAR files)
     * @param serverSSLFactory Factory for SSL handlers, null for HTTP-only
     * @param configuredAddress Server bind address (null for auto-detect)
     * @param configuredPort Server port number
     * @param config Flink configuration
     * @throws InterruptedException If server binding is interrupted
     * @throws UnknownHostException If address resolution fails
     */
    public WebFrontendBootstrap(
        Router router,
        Logger log,
        File directory,
        @Nullable SSLHandlerFactory serverSSLFactory,
        String configuredAddress,
        int configuredPort,
        Configuration config
    ) throws InterruptedException, UnknownHostException;
    
    /**
     * Get the underlying Netty ServerBootstrap for advanced configuration.
     * 
     * @return The configured ServerBootstrap instance
     */
    public ServerBootstrap getBootstrap();
    
    /**
     * Get the actual port the server is bound to.
     * May differ from configured port if 0 was specified for auto-assignment.
     * 
     * @return The server port number
     */
    public int getServerPort();
    
    /**
     * Get the REST server address for client connections.
     * 
     * @return The server address as a string
     */
    public String getRestAddress();
    
    /**
     * Gracefully shutdown the web server and release all resources.
     * Blocks until shutdown is complete.
     */
    public void shutdown();
}

Usage Examples:

import org.apache.flink.runtime.webmonitor.utils.WebFrontendBootstrap;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.shaded.netty4.io.netty.handler.logging.LoggingHandler;
import java.io.File;

// Basic HTTP server setup
Configuration config = new Configuration();
File uploadDir = new File("/tmp/flink-uploads");
uploadDir.mkdirs();

WebFrontendBootstrap bootstrap = new WebFrontendBootstrap(
    router,           // Configured router with handlers
    log,              // SLF4J logger instance
    uploadDir,        // Directory for JAR uploads
    null,             // No SSL
    "0.0.0.0",       // Bind to all interfaces
    8081,            // Port number
    config           // Flink configuration
);

// Start server and get actual port
int actualPort = bootstrap.getServerPort();
String address = bootstrap.getRestAddress();
System.out.println("Server running at " + address + ":" + actualPort);

// Shutdown when application terminates
Runtime.getRuntime().addShutdownHook(new Thread(bootstrap::shutdown));
// SSL-enabled server setup
import org.apache.flink.runtime.net.SSLHandlerFactory;

SSLHandlerFactory sslFactory = createSSLHandlerFactory(); // Custom SSL setup
WebFrontendBootstrap sslBootstrap = new WebFrontendBootstrap(
    router,
    log,
    uploadDir,
    sslFactory,      // Enable SSL
    "localhost",
    8443,           // HTTPS port
    config
);

Server Lifecycle Management

The WebFrontendBootstrap handles complete server lifecycle including startup, configuration, and graceful shutdown.

/**
 * Get the actual port the server is bound to.
 * Useful when port 0 is specified for automatic port assignment.
 * 
 * @return The server port number
 */
public int getServerPort();

/**
 * Get the REST server address that clients should connect to.
 * 
 * @return The server address as a string
 */
public String getRestAddress();

/**
 * Gracefully shutdown the web server and release all resources.
 * This method blocks until the shutdown process is complete.
 */
public void shutdown();

Integration with Router

The WebFrontendBootstrap integrates with a Router instance that defines the HTTP request handling logic.

Usage Example:

import org.apache.flink.shaded.netty4.io.netty.handler.codec.http.router.Router;

// Create router with handlers
Router router = new Router();
router.GET("/api/overview", overviewHandler);
router.POST("/jars/upload", jarUploadHandler);
router.GET("/jars", jarListHandler);

// Use router with bootstrap
WebFrontendBootstrap bootstrap = new WebFrontendBootstrap(
    router,    // Configured router
    log,
    uploadDir,
    null,
    "localhost",
    8081,
    config
);

Configuration Integration

The bootstrap accepts a Flink Configuration object for server-wide settings and integrates with Flink's configuration system.

Configuration Examples:

import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.WebOptions;

Configuration config = new Configuration();
config.setString(WebOptions.ADDRESS, "0.0.0.0");
config.setInteger(WebOptions.PORT, 8081);
config.setString(WebOptions.UPLOAD_DIR, "/tmp/flink-web");

WebFrontendBootstrap bootstrap = new WebFrontendBootstrap(
    router,
    log,
    new File(config.getString(WebOptions.UPLOAD_DIR)),
    null,
    config.getString(WebOptions.ADDRESS),
    config.getInteger(WebOptions.PORT),
    config
);

Error Handling

The WebFrontendBootstrap includes built-in error handling for common server setup issues:

  • Port binding failures: Automatic handling of port conflicts
  • SSL configuration errors: Proper error reporting for SSL setup issues
  • Upload directory access: Validation and creation of upload directories
  • Resource cleanup: Guaranteed resource cleanup on shutdown

Install with Tessl CLI

npx tessl i tessl/maven-org-apache-flink--flink-runtime-web-2-12

docs

data-transfer-objects.md

history-server.md

index.md

jar-management.md

rest-api-specifications.md

utilities-extensions.md

web-server-bootstrap.md

tile.json