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

data-transfer-objects.mddocs/

Data Transfer Objects

Comprehensive request and response body classes for all API operations. These classes provide type-safe data exchange between client and server, ensuring consistent JSON serialization and validation across the Flink web interface.

Capabilities

Request Body Classes

JAR Request Body (Base Class)

Abstract base class for all JAR operation requests.

/**
 * Abstract base class for JAR operation request bodies.
 * Provides common properties for JAR execution and plan generation.
 */
public abstract class JarRequestBody implements RequestBody {
    /**
     * Default constructor for JAR request body.
     */
    protected JarRequestBody();
    
    /**
     * Create a JAR request body with specified parameters.
     * 
     * @param entryClassName Entry class (main class) name for the JAR
     * @param programArguments Program arguments as a single string
     * @param programArgumentsList Program arguments as a list of strings
     * @param parallelism Parallelism setting for the job
     * @param jobId Job ID for the operation
     */
    protected JarRequestBody(
        String entryClassName,
        String programArguments,
        List<String> programArgumentsList,
        Integer parallelism,
        JobID jobId
    );
    
    /**
     * Get the entry class (main class) name for the JAR.
     * 
     * @return The fully qualified entry class name, or null if not specified
     */
    public String getEntryClassName();
    
    
    /**
     * Get the program arguments as a single string.
     * 
     * @return Program arguments as a string, or null if none specified
     */
    public String getProgramArguments();
    
    /**
     * Get the program arguments as a list of strings.
     * 
     * @return List of program arguments, or null if none specified
     */
    public List<String> getProgramArgumentsList();
    
    /**
     * Get the parallelism setting for the job.
     * 
     * @return The parallelism value, or null to use default
     */
    public Integer getParallelism();
    
    /**
     * Get the job ID for the operation.
     * 
     * @return The job ID, or null if not specified
     */
    public JobID getJobId();
}

JAR Run Request Body

Request body for JAR execution operations with savepoint support.

/**
 * Request body for JAR execution operations.
 * Extends base JAR request with savepoint-specific options.
 */
public class JarRunRequestBody extends JarRequestBody {
    /**
     * Default constructor for JAR run request body.
     */
    public JarRunRequestBody();
    
    /**
     * Create a JAR run request body with specified parameters.
     * 
     * @param entryClassName Entry class (main class) name for the JAR
     * @param programArguments Program arguments as a single string
     * @param programArgumentsList Program arguments as a list of strings
     * @param parallelism Parallelism setting for the job
     * @param jobId Job ID for the operation
     * @param allowNonRestoredState Whether to allow non-restored state when restoring from savepoint
     * @param savepointPath Path to savepoint file for job restoration
     */
    public JarRunRequestBody(
        String entryClassName,
        String programArguments,
        List<String> programArgumentsList,
        Integer parallelism,
        JobID jobId,
        Boolean allowNonRestoredState,
        String savepointPath
    );
    
    /**
     * Get whether to allow non-restored state when restoring from savepoint.
     * 
     * @return true to allow non-restored state, false to require exact match, null for default
     */
    public Boolean getAllowNonRestoredState();
    
    /**
     * Get the savepoint path for job restoration.
     * 
     * @return Path to savepoint file, or null if not restoring from savepoint
     */
    public String getSavepointPath();
}

JAR Plan Request Body

Request body for execution plan generation.

/**
 * Request body for JAR execution plan generation.
 * Uses base JAR request properties without savepoint options.
 */
public class JarPlanRequestBody extends JarRequestBody {
    // Inherits all properties from JarRequestBody
    // No additional properties specific to plan generation
}

Response Body Classes

JAR Upload Response Body

Response for JAR upload operations.

/**
 * Response body for JAR upload operations.
 * Contains upload status and file information.
 */
public class JarUploadResponseBody implements ResponseBody {
    /**
     * Create a JAR upload response.
     * 
     * @param filename Name of the uploaded JAR file
     */
    public JarUploadResponseBody(String filename);
    
    /**
     * Get the upload status.
     * 
     * @return Status string (typically "success")
     */
    public String getStatus();
    
    /**
     * Get the filename of the uploaded JAR.
     * 
     * @return The JAR filename
     */
    public String getFilename();
    
    /**
     * Set the upload status.
     * 
     * @param status Status string
     */
    public void setStatus(String status);
    
    /**
     * Set the filename of the uploaded JAR.
     * 
     * @param filename The JAR filename
     */
    public void setFilename(String filename);
}

JAR Run Response Body

Response for JAR execution operations.

/**
 * Response body for JAR execution operations.
 * Contains the job ID of the submitted job.
 */
public class JarRunResponseBody implements ResponseBody {
    /**
     * Create a JAR run response.
     * 
     * @param jobId The ID of the submitted job
     */
    public JarRunResponseBody(JobID jobId);
    
    /**
     * Get the job ID of the submitted job.
     * 
     * @return The job ID
     */
    public JobID getJobId();
    
    /**
     * Set the job ID.
     * 
     * @param jobId The job ID
     */
    public void setJobId(JobID jobId);
}

JAR List Response Body

Complex response for JAR listing operations with nested information classes.

/**
 * Response body for JAR listing operations.
 * Contains comprehensive information about all uploaded JARs.
 */
public class JarListInfo implements ResponseBody {
    /**
     * Create a JAR list response.
     * 
     * @param address Server address information
     * @param jarFileInfos List of JAR file information
     */
    public JarListInfo(String address, List<JarFileInfo> jarFileInfos);
    
    /**
     * Get the server address.
     * 
     * @return Server address string
     */
    public String getAddress();
    
    /**
     * Get the list of JAR file information.
     * 
     * @return List of JarFileInfo objects
     */
    public List<JarFileInfo> getFiles();
    
    /**
     * Information about an individual JAR file.
     * Contains file metadata and available entry points.
     */
    public static class JarFileInfo {
        /**
         * Create JAR file information.
         * 
         * @param id Unique identifier for the JAR
         * @param name Original filename of the JAR
         * @param uploaded Timestamp when JAR was uploaded
         * @param entry List of available entry points
         */
        public JarFileInfo(String id, String name, long uploaded, List<JarEntryInfo> entry);
        
        /**
         * Get the JAR ID.
         * 
         * @return Unique JAR identifier
         */
        public String getId();
        
        /**
         * Get the JAR filename.
         * 
         * @return Original filename
         */
        public String getName();
        
        /**
         * Get the upload timestamp.
         * 
         * @return Timestamp in milliseconds
         */
        public long getUploaded();
        
        /**
         * Get the list of available entry points.
         * 
         * @return List of JarEntryInfo objects
         */
        public List<JarEntryInfo> getEntry();
    }
    
    /**
     * Information about a JAR entry point (main class).
     * Contains class name and description.
     */
    public static class JarEntryInfo {
        /**
         * Create JAR entry information.
         * 
         * @param name Fully qualified class name
         * @param description Description of the entry point
         */
        public JarEntryInfo(String name, String description);
        
        /**
         * Get the entry class name.
         * 
         * @return Fully qualified class name
         */
        public String getName();
        
        /**
         * Get the entry description.
         * 
         * @return Description string
         */
        public String getDescription();
    }
}

Usage Examples

Creating Request Bodies

import org.apache.flink.runtime.webmonitor.handlers.*;
import org.apache.flink.api.common.JobID;
import java.util.Arrays;

// Create JAR run request with constructor
JarRunRequestBody runRequest = new JarRunRequestBody(
    "com.example.MyFlinkJob",                           // entryClassName
    null,                                               // programArguments (string)
    Arrays.asList("--input", "/path/to/input", "--output", "/path/to/output"), // programArgumentsList
    4,                                                  // parallelism
    JobID.generate(),                                   // jobId
    true,                                               // allowNonRestoredState
    "/path/to/savepoint"                               // savepointPath
);

// Create JAR plan request
JarPlanRequestBody planRequest = new JarPlanRequestBody(
    "com.example.MyFlinkJob",                          // entryClassName
    null,                                              // programArguments (string)
    Arrays.asList("--mode", "plan"),                   // programArgumentsList
    null,                                              // parallelism
    null                                               // jobId
);

Processing Response Bodies

// Handle JAR upload response
JarUploadResponseBody uploadResponse = uploadHandler.handleRequest(uploadRequest, gateway).get();
if ("success".equals(uploadResponse.getStatus())) {
    String filename = uploadResponse.getFilename();
    System.out.println("JAR uploaded successfully: " + filename);
}

// Handle JAR run response
JarRunResponseBody runResponse = runHandler.handleRequest(runRequest, gateway).get();
JobID jobId = runResponse.getJobId();
System.out.println("Job submitted with ID: " + jobId);

// Handle JAR list response
JarListInfo listResponse = listHandler.handleRequest(listRequest, gateway).get();
for (JarListInfo.JarFileInfo jarInfo : listResponse.getFiles()) {
    System.out.println("JAR: " + jarInfo.getName() + " (ID: " + jarInfo.getId() + ")");
    for (JarListInfo.JarEntryInfo entryInfo : jarInfo.getEntry()) {
        System.out.println("  Entry: " + entryInfo.getName() + " - " + entryInfo.getDescription());
    }
}

JSON Serialization Examples

The data transfer objects are designed for JSON serialization. Here are examples of the JSON formats:

JAR Run Request JSON

{
  "entryClassName": "com.example.MyFlinkJob",
  "programArguments": ["--input", "/path/to/input", "--output", "/path/to/output"],
  "parallelism": 4,
  "jobId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
  "savepointPath": "/path/to/savepoint",
  "allowNonRestoredState": true
}

JAR Upload Response JSON

{
  "status": "success",
  "filename": "my-flink-job.jar"
}

JAR Run Response JSON

{
  "jobId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
}

JAR List Response JSON

{
  "address": "http://localhost:8081",
  "files": [
    {
      "id": "example-jar_2.12-1.0.jar",
      "name": "example-jar_2.12-1.0.jar",
      "uploaded": 1609459200000,
      "entry": [
        {
          "name": "com.example.WordCount",
          "description": "Word count streaming job"
        },
        {
          "name": "com.example.WindowSum",
          "description": "Windowed sum calculation"
        }
      ]
    }
  ]
}

Validation and Error Handling

Data transfer objects include built-in validation for common scenarios:

// Validation example
JarRunRequestBody request = new JarRunRequestBody();

// Validate required fields
if (request.getEntryClassName() == null || request.getEntryClassName().isEmpty()) {
    throw new BadRequestException("Entry class name is required");
}

// Validate parallelism
Integer parallelism = request.getParallelism();
if (parallelism != null && parallelism <= 0) {
    throw new BadRequestException("Parallelism must be positive");
}

// Validate program arguments
List<String> args = request.getProgramArguments();
if (args != null) {
    for (String arg : args) {
        if (arg == null) {
            throw new BadRequestException("Program arguments cannot contain null values");
        }
    }
}

Builder Pattern Support

For complex request construction, consider using builder patterns:

// Custom builder for complex requests
public class JarRunRequestBuilder {
    private JarRunRequestBody request = new JarRunRequestBody();
    
    public JarRunRequestBuilder entryClass(String className) {
        request.setEntryClassName(className);
        return this;
    }
    
    public JarRunRequestBuilder parallelism(int parallelism) {
        request.setParallelism(parallelism);
        return this;
    }
    
    public JarRunRequestBuilder args(String... args) {
        request.setProgramArguments(Arrays.asList(args));
        return this;
    }
    
    public JarRunRequestBuilder savepoint(String path, boolean allowNonRestored) {
        request.setSavepointPath(path);
        request.setAllowNonRestoredState(allowNonRestored);
        return this;
    }
    
    public JarRunRequestBody build() {
        return request;
    }
}

// Usage
JarRunRequestBody request = new JarRunRequestBuilder()
    .entryClass("com.example.MyJob")
    .parallelism(8)
    .args("--input", "/data/input", "--output", "/data/output")
    .savepoint("/checkpoints/savepoint-123", true)
    .build();

These data transfer objects provide a complete, type-safe foundation for all REST API communication in the Flink web interface.

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