CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-apache-flink--flink-java

Apache Flink Java API - Core Java APIs for Apache Flink's batch and stream processing framework

Pending
Overview
Eval results
Files

execution-environments.mddocs/

Execution Environments

Execution environments provide the central context for Flink batch program execution, offering methods to create data sources, configure execution parameters, and trigger program execution.

Capabilities

ExecutionEnvironment

The abstract base class for all execution environments, providing the primary entry point for Flink batch programs.

/**
 * Get the default execution environment (auto-detects local vs remote)
 * @return ExecutionEnvironment instance
 */
public static ExecutionEnvironment getExecutionEnvironment();

/**
 * Create a local execution environment
 * @return LocalEnvironment for local execution
 */
public static LocalEnvironment createLocalEnvironment();

/**
 * Create a local execution environment with specific parallelism
 * @param parallelism the parallelism for the local environment
 * @return LocalEnvironment for local execution
 */
public static LocalEnvironment createLocalEnvironment(int parallelism);

/**
 * Create a remote execution environment
 * @param host hostname of the JobManager
 * @param port port of the JobManager
 * @param jarFiles JAR files to be sent to the cluster
 * @return RemoteEnvironment for remote execution
 */
public static RemoteEnvironment createRemoteEnvironment(String host, int port, String... jarFiles);

Usage Examples:

// Auto-detect environment (local when running in IDE, remote when submitted to cluster)
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

// Force local execution with default parallelism
LocalEnvironment localEnv = ExecutionEnvironment.createLocalEnvironment();

// Local execution with specific parallelism
LocalEnvironment localEnvParallel = ExecutionEnvironment.createLocalEnvironment(4);

// Remote execution
RemoteEnvironment remoteEnv = ExecutionEnvironment.createRemoteEnvironment(
    "localhost", 8081, "/path/to/your-job.jar");

Data Source Creation

Methods for creating DataSets from various data sources.

/**
 * Create a DataSet from a Java collection
 * @param data the collection to create the DataSet from
 * @return DataSet containing the collection elements
 */
public <T> DataSet<T> fromCollection(Collection<T> data);

/**
 * Create a DataSet from individual elements
 * @param data the elements to create the DataSet from
 * @return DataSet containing the specified elements
 */
@SafeVarargs
public final <T> DataSet<T> fromElements(T... data);

/**
 * Read a text file and create a DataSet of Strings
 * @param filePath path to the text file
 * @return DataSet of lines from the file
 */
public DataSet<String> readTextFile(String filePath);

/**
 * Read a text file with specific character encoding
 * @param filePath path to the text file
 * @param charsetName the charset name for decoding the file
 * @return DataSet of lines from the file
 */
public DataSet<String> readTextFile(String filePath, String charsetName);

/**
 * Read text file as StringValue objects
 * @param filePath path to the text file
 * @return DataSource where each element is a StringValue from the file
 */
public DataSource<StringValue> readTextFileWithValue(String filePath);

/**
 * Read text file as StringValue objects with charset and error handling
 * @param filePath path to the text file
 * @param charsetName the charset name for decoding the file
 * @param skipInvalidLines whether to skip lines that cannot be decoded
 * @return DataSource where each element is a StringValue from the file
 */
public DataSource<StringValue> readTextFileWithValue(String filePath, String charsetName, boolean skipInvalidLines);

/**
 * Read file containing primitive values
 * @param filePath path to the file
 * @param typeClass the class of the primitive type
 * @return DataSource with elements of the primitive type
 */
public <X> DataSource<X> readFileOfPrimitives(String filePath, Class<X> typeClass);

/**
 * Read file containing primitive values with custom delimiter
 * @param filePath path to the file
 * @param delimiter the delimiter separating values
 * @param typeClass the class of the primitive type
 * @return DataSource with elements of the primitive type
 */
public <X> DataSource<X> readFileOfPrimitives(String filePath, String delimiter, Class<X> typeClass);

/**
 * Read a file with a custom input format
 * @param inputFormat the input format to use
 * @param filePath path to the file
 * @return DataSet with elements read by the input format
 */
public <T> DataSet<T> readFile(FileInputFormat<T> inputFormat, String filePath);

/**
 * Create a CSV reader for structured data
 * @param filePath path to the CSV file
 * @return CsvReader for configuration and DataSet creation
 */
public CsvReader readCsvFile(String filePath);

/**
 * Generate a sequence of numbers
 * @param from starting number (inclusive)
 * @param to ending number (inclusive)
 * @return DataSet containing the number sequence
 */
public DataSet<Long> generateSequence(long from, long to);

Execution Control

Methods for configuring and executing Flink programs.

/**
 * Execute the program with a generated job name
 * @return JobExecutionResult containing execution statistics
 * @throws Exception if execution fails
 */
public JobExecutionResult execute() throws Exception;

/**
 * Execute the program with a specific job name
 * @param jobName name for the job
 * @return JobExecutionResult containing execution statistics
 * @throws Exception if execution fails
 */
public JobExecutionResult execute(String jobName) throws Exception;

/**
 * Get the execution plan as JSON without executing
 * @return JSON representation of the execution plan
 * @throws Exception if plan generation fails
 */
public String getExecutionPlan() throws Exception;

/**
 * Set the default parallelism for all operations
 * @param parallelism the parallelism level
 */
public void setParallelism(int parallelism);

/**
 * Get the current default parallelism
 * @return the current parallelism level
 */
public int getParallelism();

/**
 * Get the execution configuration
 * @return ExecutionConfig for advanced configuration
 */
public ExecutionConfig getConfig();

LocalEnvironment

Specialized execution environment for local execution in the current JVM.

/**
 * LocalEnvironment for local execution
 * Inherits all methods from ExecutionEnvironment
 * Executes programs in the current JVM process
 */
public class LocalEnvironment extends ExecutionEnvironment {
    // Additional local-specific configuration methods available
}

RemoteEnvironment

Specialized execution environment for remote execution on a Flink cluster.

/**
 * RemoteEnvironment for remote cluster execution
 * Inherits all methods from ExecutionEnvironment
 * Submits programs to a remote Flink cluster
 */
public class RemoteEnvironment extends ExecutionEnvironment {
    // Additional remote-specific configuration methods available
}

CollectionEnvironment

Specialized execution environment for collection-based execution (primarily for testing).

/**
 * CollectionEnvironment for collection-based execution
 * Inherits all methods from ExecutionEnvironment
 * Executes programs using Java collections (useful for testing)
 */
public class CollectionEnvironment extends ExecutionEnvironment {
    // Collection-based execution methods
}

ExecutionEnvironmentFactory

Factory interface for creating custom execution environments.

/**
 * Factory interface for creating custom ExecutionEnvironments
 */
public interface ExecutionEnvironmentFactory {
    /**
     * Create a custom execution environment
     * @return ExecutionEnvironment instance
     */
    ExecutionEnvironment createExecutionEnvironment();
}

Types

import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.LocalEnvironment;
import org.apache.flink.api.java.RemoteEnvironment;
import org.apache.flink.api.java.CollectionEnvironment;
import org.apache.flink.api.java.ExecutionEnvironmentFactory;
import org.apache.flink.api.java.operators.DataSource;
import org.apache.flink.api.common.JobExecutionResult;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.core.execution.JobClient;
import org.apache.flink.types.StringValue;

Install with Tessl CLI

npx tessl i tessl/maven-org-apache-flink--flink-java

docs

aggregation-grouping.md

data-input-output.md

dataset-operations.md

execution-environments.md

index.md

iteration-operations.md

join-cogroup-operations.md

utility-functions.md

tile.json