public class TestEnvironment extends ExecutionEnvironment
ExecutionEnvironment
implementation which executes its jobs on a
LocalFlinkMiniCluster
.jobID, lastJobExecutionResult, LOG, sessionTimeout
Constructor and Description |
---|
TestEnvironment(JobExecutor executor,
int parallelism,
boolean isObjectReuseEnabled) |
TestEnvironment(JobExecutor jobExecutor,
int parallelism,
boolean isObjectReuseEnabled,
Collection<Path> jarFiles,
Collection<URL> classPaths) |
Modifier and Type | Method and Description |
---|---|
JobExecutionResult |
execute(String jobName)
Triggers the program execution.
|
String |
getExecutionPlan()
Creates the plan with which the system will execute the program, and returns it as
a String using a JSON representation of the execution data flow graph.
|
JobExecutionResult |
getLastJobExecutionResult()
Returns the
JobExecutionResult of the last executed job. |
void |
setAsContext() |
static void |
setAsContext(JobExecutor jobExecutor,
int parallelism)
Sets the current
ExecutionEnvironment to be a TestEnvironment . |
static void |
setAsContext(JobExecutor jobExecutor,
int parallelism,
Collection<Path> jarFiles,
Collection<URL> classPaths)
Sets the current
ExecutionEnvironment to be a TestEnvironment . |
void |
startNewSession()
Starts a new session, discarding the previous data flow and all of its intermediate results.
|
static void |
unsetAsContext() |
addDefaultKryoSerializer, addDefaultKryoSerializer, areExplicitEnvironmentsAllowed, createCollectionsEnvironment, createInput, createInput, createLocalEnvironment, createLocalEnvironment, createLocalEnvironment, createLocalEnvironmentWithWebUI, createProgramPlan, createProgramPlan, createProgramPlan, createRemoteEnvironment, createRemoteEnvironment, createRemoteEnvironment, execute, fromCollection, fromCollection, fromCollection, fromCollection, fromElements, fromElements, fromParallelCollection, fromParallelCollection, generateSequence, getConfig, getDefaultLocalParallelism, getExecutionEnvironment, getId, getIdString, getNumberOfExecutionRetries, getParallelism, getRestartStrategy, getSessionTimeout, initializeContextEnvironment, readCsvFile, readFile, readFileOfPrimitives, readFileOfPrimitives, readTextFile, readTextFile, readTextFileWithValue, readTextFileWithValue, registerCachedFile, registerCachedFile, registerCachedFilesWithPlan, registerType, registerTypeWithKryoSerializer, registerTypeWithKryoSerializer, resetContextEnvironment, setDefaultLocalParallelism, setNumberOfExecutionRetries, setParallelism, setRestartStrategy, setSessionTimeout
public TestEnvironment(JobExecutor jobExecutor, int parallelism, boolean isObjectReuseEnabled, Collection<Path> jarFiles, Collection<URL> classPaths)
public TestEnvironment(JobExecutor executor, int parallelism, boolean isObjectReuseEnabled)
public JobExecutionResult getLastJobExecutionResult()
ExecutionEnvironment
JobExecutionResult
of the last executed job.getLastJobExecutionResult
in class ExecutionEnvironment
public void startNewSession() throws Exception
ExecutionEnvironment
startNewSession
in class ExecutionEnvironment
Exception
public JobExecutionResult execute(String jobName) throws Exception
ExecutionEnvironment
DataSet.print()
,
writing results (e.g. DataSet.writeAsText(String)
,
DataSet.write(org.apache.flink.api.common.io.FileOutputFormat, String)
, or other generic
data sinks created with DataSet.output(org.apache.flink.api.common.io.OutputFormat)
.
The program execution will be logged and displayed with the given job name.
execute
in class ExecutionEnvironment
Exception
- Thrown, if the program executions fails.public String getExecutionPlan() throws Exception
ExecutionEnvironment
getExecutionPlan
in class ExecutionEnvironment
Exception
- Thrown, if the compiler could not be instantiated, or the master could not
be contacted to retrieve information relevant to the execution planning.public void setAsContext()
public static void setAsContext(JobExecutor jobExecutor, int parallelism, Collection<Path> jarFiles, Collection<URL> classPaths)
ExecutionEnvironment
to be a TestEnvironment
. The test
environment executes the given jobs on a Flink mini cluster with the given default
parallelism and the additional jar files and class paths.jobExecutor
- The executor to run the jobs onparallelism
- The default parallelismjarFiles
- Additional jar files to execute the job withclassPaths
- Additional class paths to execute the job withpublic static void setAsContext(JobExecutor jobExecutor, int parallelism)
ExecutionEnvironment
to be a TestEnvironment
. The test
environment executes the given jobs on a Flink mini cluster with the given default
parallelism and the additional jar files and class paths.jobExecutor
- The executor to run the jobs onparallelism
- The default parallelismpublic static void unsetAsContext()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.