Package org.apache.flink.streaming.util
Class TestStreamEnvironment
- java.lang.Object
-
- org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
-
- org.apache.flink.streaming.util.TestStreamEnvironment
-
- All Implemented Interfaces:
AutoCloseable
public class TestStreamEnvironment extends StreamExecutionEnvironment
AStreamExecutionEnvironment
that executes its jobs onMiniCluster
.
-
-
Field Summary
-
Fields inherited from class org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
cacheFile, checkpointCfg, config, configuration, transformations
-
-
Constructor Summary
Constructors Constructor Description TestStreamEnvironment(MiniCluster miniCluster, int parallelism)
TestStreamEnvironment(MiniCluster miniCluster, Configuration config, int parallelism, Collection<Path> jarFiles, Collection<URL> classPaths)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JobExecutionResult
execute(String jobName)
Triggers the program execution.JobClient
executeAsync(String jobName)
Triggers the program execution asynchronously.JobExecutionResult
getLastJobExecutionResult()
void
setAsContext()
static void
setAsContext(MiniCluster miniCluster, int parallelism)
Sets the streaming context environment to a TestStreamEnvironment that runs its programs on the given cluster with the given default parallelism.static void
setAsContext(MiniCluster miniCluster, int parallelism, Collection<Path> jarFiles, Collection<URL> classpaths)
Sets the streaming context environment to a TestStreamEnvironment that runs its programs on the given cluster with the given default parallelism and the specified jar files and class paths.static void
unsetAsContext()
Resets the streaming context environment to null.-
Methods inherited from class org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
addOperator, addSource, addSource, addSource, addSource, areExplicitEnvironmentsAllowed, clean, clearJobListeners, close, configure, configure, createInput, createInput, createLocalEnvironment, createLocalEnvironment, createLocalEnvironment, createLocalEnvironment, createLocalEnvironmentWithWebUI, createRemoteEnvironment, createRemoteEnvironment, createRemoteEnvironment, disableOperatorChaining, enableChangelogStateBackend, enableCheckpointing, enableCheckpointing, enableCheckpointing, execute, execute, executeAsync, executeAsync, fromCollection, fromCollection, fromCollection, fromCollection, fromData, fromData, fromData, fromData, fromData, fromElements, fromElements, fromParallelCollection, fromParallelCollection, fromSequence, fromSource, fromSource, generateSequence, generateStreamGraph, getBufferTimeout, getCachedFiles, getCheckpointConfig, getCheckpointingConsistencyMode, getCheckpointingMode, getCheckpointInterval, getConfig, getConfiguration, getDefaultLocalParallelism, getDefaultSavepointDirectory, getExecutionEnvironment, getExecutionEnvironment, getExecutionPlan, getJobListeners, getMaxParallelism, getParallelism, getStreamGraph, getStreamGraph, getTransformations, getUserClassloader, initializeContextEnvironment, invalidateClusterDataset, isChainingEnabled, isChainingOfOperatorsWithDifferentMaxParallelismEnabled, isChangelogStateBackendEnabled, isForceUnalignedCheckpoints, isUnalignedCheckpointsEnabled, listCompletedClusterDatasets, readFile, readFile, readFile, readFile, readFileStream, registerCachedFile, registerCachedFile, registerCacheTransformation, registerCollectIterator, registerJobListener, registerSlotSharingGroup, resetContextEnvironment, setBufferTimeout, setDefaultLocalParallelism, setDefaultSavepointDirectory, setDefaultSavepointDirectory, setDefaultSavepointDirectory, setMaxParallelism, setParallelism, setRuntimeMode, socketTextStream, socketTextStream, socketTextStream, socketTextStream, socketTextStream
-
-
-
-
Constructor Detail
-
TestStreamEnvironment
public TestStreamEnvironment(MiniCluster miniCluster, Configuration config, int parallelism, Collection<Path> jarFiles, Collection<URL> classPaths)
-
TestStreamEnvironment
public TestStreamEnvironment(MiniCluster miniCluster, int parallelism)
-
-
Method Detail
-
setAsContext
public static void setAsContext(MiniCluster miniCluster, int parallelism, Collection<Path> jarFiles, Collection<URL> classpaths)
Sets the streaming context environment to a TestStreamEnvironment that runs its programs on the given cluster with the given default parallelism and the specified jar files and class paths.- Parameters:
miniCluster
- The MiniCluster to execute jobs on.parallelism
- The default parallelism for the test programs.jarFiles
- Additional jar files to execute the job withclasspaths
- Additional class paths to execute the job with
-
setAsContext
public void setAsContext()
-
setAsContext
public static void setAsContext(MiniCluster miniCluster, int parallelism)
Sets the streaming context environment to a TestStreamEnvironment that runs its programs on the given cluster with the given default parallelism.- Parameters:
miniCluster
- The MiniCluster to execute jobs on.parallelism
- The default parallelism for the test programs.
-
unsetAsContext
public static void unsetAsContext()
Resets the streaming context environment to null.
-
execute
public JobExecutionResult execute(String jobName) throws Exception
Description copied from class:StreamExecutionEnvironment
Triggers the program execution. The environment will execute all parts of the program that have resulted in a "sink" operation. Sink operations are for example printing results or forwarding them to a message queue.The program execution will be logged and displayed with the provided name
- Overrides:
execute
in classStreamExecutionEnvironment
- Parameters:
jobName
- Desired name of the job- Returns:
- The result of the job execution, containing elapsed time and accumulators.
- Throws:
Exception
- which occurs during job execution.
-
executeAsync
public JobClient executeAsync(String jobName) throws Exception
Description copied from class:StreamExecutionEnvironment
Triggers the program execution asynchronously. The environment will execute all parts of the program that have resulted in a "sink" operation. Sink operations are for example printing results or forwarding them to a message queue.The program execution will be logged and displayed with the provided name
- Overrides:
executeAsync
in classStreamExecutionEnvironment
- Parameters:
jobName
- desired name of the job- Returns:
- A
JobClient
that can be used to communicate with the submitted job, completed on submission succeeded. - Throws:
Exception
- which occurs during job execution.
-
getLastJobExecutionResult
public JobExecutionResult getLastJobExecutionResult()
-
-