public class FlowRunner extends java.lang.Object implements FlowExecutor, CommandlineRunnable
| Modifier and Type | Class and Description |
|---|---|
static class |
FlowRunner.SimpleLogger
A simple logging implementation that writes to standard out
|
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<ExecutionFinishedCallback> |
m_callbacks
Callback to notify when execution completes
|
protected BaseExecutionEnvironment |
m_execEnv
The execution environment
|
protected Flow |
m_flow
The flow to execute
|
protected Logger |
m_log
The log to use
|
protected LoggingLevel |
m_loggingLevel
The level to at which to log at
|
protected LogManager |
m_logHandler
Local log handler for FlowRunner-specific logging
|
protected int |
m_numThreads
Number of worker threads to use in the step executor service
|
protected int |
m_resourceIntensiveNumThreads
Number of worker threads to use in the resource intensive executor service
|
protected boolean |
m_startSequentially
Invoke start points sequentially?
|
protected boolean |
m_wasStopped
Gets set to true if the stopProcessing() method is called
|
| Constructor and Description |
|---|
FlowRunner()
Constructor
|
FlowRunner(Settings settings)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExecutionFinishedCallback(ExecutionFinishedCallback callback)
Set a callback to notify when flow execution finishes
|
boolean |
flowBusy()
Checks to see if any step(s) are doing work
|
BaseExecutionEnvironment |
getExecutionEnvironment()
Return the execution environment object for this flow executor
|
Flow |
getFlow()
Get the flow to execute
|
boolean |
getLaunchStartPointsSequentially()
Get whether to launch start points sequentially
|
Logger |
getLogger()
Get the log to use
|
LoggingLevel |
getLoggingLevel()
Get the logging level to use
|
Settings |
getSettings()
Get the settings in use when executing the Flow
|
protected void |
init(Settings settings) |
protected java.util.List<StepManagerImpl> |
initializeFlow()
Initialize the flow ready for execution
|
protected void |
launchExecutorShutdownThread()
Launch a thread to monitor the progress of the flow, and then shutdown the
executor service once all steps have completed.
|
static void |
main(java.lang.String[] args)
Main method for executing the FlowRunner
|
void |
postExecution()
Perform any teardown stuff that might need to happen after execution.
|
void |
preExecution()
Perform any setup stuff that might need to happen before execution.
|
void |
removeExecutionFinishedCallback(ExecutionFinishedCallback callback)
Remove a callback
|
void |
run()
Execute the flow
|
void |
run(java.lang.Object toRun,
java.lang.String[] args)
Run a FlowRunner object
|
void |
runParallel()
Run the flow by launching start points in parallel
|
protected void |
runParallel(java.util.List<StepManagerImpl> startPoints)
Execute the flow by launching start points in parallel
|
void |
runSequentially()
Run the flow by launching start points sequentially.
|
protected void |
runSequentially(java.util.List<StepManagerImpl> startPoints)
Execute the flow by launching start points sequentially
|
void |
setExecutionEnvironment(BaseExecutionEnvironment env)
Set the execution environment to use
|
void |
setFlow(Flow flow)
Set the flow to execute
|
void |
setLaunchStartPointsSequentially(boolean s)
Set whether to launch start points sequentially
|
void |
setLogger(Logger logger)
Set the log to use
|
void |
setLoggingLevel(LoggingLevel level)
Set the logging level to use
|
void |
setSettings(Settings settings)
Set the settings to use when executing the Flow
|
void |
stopProcessing()
Attempt to stop processing in all steps
|
void |
waitUntilFinished()
Wait until all the steps are no longer busy
|
boolean |
wasStopped()
Returns true if execution was stopped via the stopProcessing() method
|
protected Flow m_flow
protected transient BaseExecutionEnvironment m_execEnv
protected transient Logger m_log
protected transient LogManager m_logHandler
protected LoggingLevel m_loggingLevel
protected boolean m_startSequentially
protected int m_numThreads
protected int m_resourceIntensiveNumThreads
protected java.util.List<ExecutionFinishedCallback> m_callbacks
protected boolean m_wasStopped
public FlowRunner()
public FlowRunner(Settings settings)
protected void init(Settings settings)
public void setSettings(Settings settings)
setSettings in interface FlowExecutorsettings - the settings to usepublic Settings getSettings()
getSettings in interface FlowExecutorpublic static void main(java.lang.String[] args)
args - command line argumentspublic void run(java.lang.Object toRun,
java.lang.String[] args)
throws java.lang.Exception
run in interface CommandlineRunnabletoRun - the FlowRunner object to executeargs - the command line argumentsjava.lang.Exception - if a problem occurspublic void addExecutionFinishedCallback(ExecutionFinishedCallback callback)
addExecutionFinishedCallback in interface FlowExecutorcallback - the callback to notifypublic void removeExecutionFinishedCallback(ExecutionFinishedCallback callback)
removeExecutionFinishedCallback in interface FlowExecutorcallback - the callback to removepublic Flow getFlow()
getFlow in interface FlowExecutorpublic void setFlow(Flow flow)
setFlow in interface FlowExecutorflow - the flow to executepublic Logger getLogger()
getLogger in interface FlowExecutorpublic void setLogger(Logger logger)
setLogger in interface FlowExecutorlogger - the log to usepublic LoggingLevel getLoggingLevel()
getLoggingLevel in interface FlowExecutorpublic void setLoggingLevel(LoggingLevel level)
setLoggingLevel in interface FlowExecutorlevel - the logging level to usepublic boolean getLaunchStartPointsSequentially()
public void setLaunchStartPointsSequentially(boolean s)
s - true if start points are to be launched sequentiallypublic BaseExecutionEnvironment getExecutionEnvironment()
FlowExecutorgetExecutionEnvironment in interface FlowExecutorpublic void setExecutionEnvironment(BaseExecutionEnvironment env)
setExecutionEnvironment in interface FlowExecutorenv - the execution environment to usepublic void run()
throws WekaException
WekaException - if a problem occursprotected java.util.List<StepManagerImpl> initializeFlow() throws WekaException
WekaException - if a problem occurs during initializationpublic void runSequentially()
throws WekaException
runSequentially in interface FlowExecutorWekaException - if a problem occurspublic void runParallel()
throws WekaException
runParallel in interface FlowExecutorWekaException - if a problem occursprotected void runSequentially(java.util.List<StepManagerImpl> startPoints) throws WekaException
startPoints - the list of potential start pointsWekaException - if a problem occursprotected void runParallel(java.util.List<StepManagerImpl> startPoints) throws WekaException
startPoints - the list of potential start points to executeWekaException - if a problem occursprotected void launchExecutorShutdownThread()
public void waitUntilFinished()
waitUntilFinished in interface FlowExecutorpublic boolean flowBusy()
public void stopProcessing()
stopProcessing in interface FlowExecutorpublic boolean wasStopped()
wasStopped in interface FlowExecutorpublic void preExecution()
throws java.lang.Exception
CommandlineRunnablepreExecution in interface CommandlineRunnablejava.lang.Exception - if a problem occurs during setuppublic void postExecution()
throws java.lang.Exception
CommandlineRunnablepostExecution in interface CommandlineRunnablejava.lang.Exception - if a problem occurs during teardown