Package org.vast.process
Class ExecutableChainImpl
java.lang.Object
org.vast.process.ExecutableProcessImpl
org.vast.process.ExecutableChainImpl
- All Implemented Interfaces:
IProcessChainExec
,IProcessExec
Implementation of an executable process chain.
This class can be associated with an
AggregateProcess
to provide
execution capability, but this will only work if all components
of the aggregate also have an executable implementation associated
to them.
- Since:
- Feb 28, 2015
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
static final ProcessInfo
protected Map<String,
DataConnectionList> protected Map<String,
DataConnectionList> protected Map<String,
DataConnectionList> protected boolean
protected List<IProcessExec>
protected Map<String,
IProcessExec> protected ExecutorService
protected boolean
Fields inherited from class org.vast.process.ExecutableProcessImpl
EXEC_ERROR_MSG, execFuture, INIT_ERROR_MSG, initialized, inputConnections, inputData, instanceName, IO_ERROR_MSG, outputConnections, outputData, paramConnections, paramData, processInfo, started, usingOutputQueues
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddProcess
(String name, IProcessExec process) Adds a child process to this process chainvoid
void
protected void
combineOutputBlocks
(String outputName) connect
(IProcessExec srcProcess, DataComponent srcComponent, IProcessExec destProcess, DataComponent destComponent) Create connection between ports of two child processesvoid
connectInternal
(DataComponent component, IDataConnection connection) protected void
disconnect
(DataComponent parentPort, IDataConnection connection) void
dispose()
Override to dispose of all resources allocated for the process (stop threads, OS resources, etc...)void
execute()
Execute contains the logic to transform input/parameter values into output values.protected Map<String,
DataConnectionList> findInternalConnectionGroup
(DataComponent parentPort) void
init()
Initialize the process and its internal variables (fixed parameters).boolean
boolean
needSync()
void
removeInternalConnection
(IDataConnection connection) Completely remove an internal connection between two child processes or between a chain internal port and a child processvoid
removeProcess
(String name) Removes a process from the chain and all connections to/from itprotected void
setNeededInputs
(Map<String, DataConnectionList> externalConnections, Map<String, DataConnectionList> internalConnections) protected void
setNeededOutputs
(Map<String, DataConnectionList> externalConnections, Map<String, DataConnectionList> internalConnections) void
setOutputNeeded
(String outputName, boolean needed) Indicates if data from the specified output is needed or notvoid
setParentLogger
(org.slf4j.Logger log) Set the parent logger for this process.
The parent logger is used to group log events occuring in all processes that are part of the same processing component (e.g.void
setUseChildrenThreads
(boolean useThreads) void
start
(ExecutorService threadPool, Consumer<Throwable> onError) Start process using threads from the given thread poolvoid
Start process in its own threadprotected void
protected void
startChildrenThreads
(ExecutorService threadPool, Consumer<Throwable> onError) void
stop()
Stop process thread gracefullytoString()
protected void
transferInputData
(Map<String, DataConnectionList> externalConnections, Map<String, DataConnectionList> internalConnections) Methods inherited from class org.vast.process.ExecutableProcessImpl
canRun, checkAvailability, checkAvailability, checkInitialized, connect, connect, consumeData, consumeInputData, consumeParamData, disconnect, finalize, findConnectionGroup, getInputConnections, getInputList, getInstanceName, getLogger, getOutputConnections, getOutputList, getParamConnections, getParameterList, getProcessInfo, initPortData, initPortData, notifyParamChange, publishData, publishData, renewOutputData, reportError, reportError, run, setInstanceName
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.vast.process.IProcessExec
canRun, connect, disconnect, getInputConnections, getInputList, getInstanceName, getOutputConnections, getOutputList, getParamConnections, getParameterList, getProcessInfo, notifyParamChange, run, setInstanceName
-
Field Details
-
INFO
-
internalInputConnections
-
internalOutputConnections
-
internalParamConnections
-
processTable
-
processExecList
-
useChildrenThreads
protected boolean useChildrenThreads -
needSync
protected boolean needSync -
childrenThreadsStarted
protected boolean childrenThreadsStarted -
threadPool
-
-
Constructor Details
-
ExecutableChainImpl
public ExecutableChainImpl() -
ExecutableChainImpl
public ExecutableChainImpl(boolean childrenThreadsOn)
-
-
Method Details
-
getChildProcesses
- Specified by:
getChildProcesses
in interfaceIProcessChainExec
- Returns:
- Read-only map of processes included in this chain
-
addProcess
Description copied from interface:IProcessChainExec
Adds a child process to this process chain- Specified by:
addProcess
in interfaceIProcessChainExec
- Returns:
- the added process
-
removeProcess
Description copied from interface:IProcessChainExec
Removes a process from the chain and all connections to/from it- Specified by:
removeProcess
in interfaceIProcessChainExec
-
getInternalConnections
- Specified by:
getInternalConnections
in interfaceIProcessChainExec
- Returns:
- Read-only list of all connections between child processes
-
connect
public IDataConnection connect(IProcessExec srcProcess, DataComponent srcComponent, IProcessExec destProcess, DataComponent destComponent) throws ProcessException Description copied from interface:IProcessChainExec
Create connection between ports of two child processes- Specified by:
connect
in interfaceIProcessChainExec
- Throws:
ProcessException
-
connectInternal
public void connectInternal(DataComponent component, IDataConnection connection) throws ProcessException - Throws:
ProcessException
-
findInternalConnectionGroup
-
removeInternalConnection
Description copied from interface:IProcessChainExec
Completely remove an internal connection between two child processes or between a chain internal port and a child process- Specified by:
removeInternalConnection
in interfaceIProcessChainExec
-
disconnect
- Overrides:
disconnect
in classExecutableProcessImpl
-
init
Description copied from interface:IProcessExec
Initialize the process and its internal variables (fixed parameters). This is called only once before the process is executed.- Specified by:
init
in interfaceIProcessExec
- Overrides:
init
in classExecutableProcessImpl
- Throws:
ProcessException
-
execute
Description copied from interface:IProcessExec
Execute contains the logic to transform input/parameter values into output values. This method should be optimized as much as possible.- Specified by:
execute
in interfaceIProcessExec
- Throws:
ProcessException
-
transferInputData
protected void transferInputData(Map<String, DataConnectionList> externalConnections, Map<String, throws InterruptedExceptionDataConnectionList> internalConnections) - Throws:
InterruptedException
-
setNeededInputs
protected void setNeededInputs(Map<String, DataConnectionList> externalConnections, Map<String, DataConnectionList> internalConnections) -
setNeededOutputs
protected void setNeededOutputs(Map<String, DataConnectionList> externalConnections, Map<String, DataConnectionList> internalConnections) -
start
Description copied from interface:IProcessExec
Start process in its own thread- Specified by:
start
in interfaceIProcessExec
- Overrides:
start
in classExecutableProcessImpl
- Parameters:
onError
- Called when the process ends with an unrecoverable error- Throws:
ProcessException
-
start
Description copied from interface:IProcessExec
Start process using threads from the given thread pool- Specified by:
start
in interfaceIProcessExec
- Overrides:
start
in classExecutableProcessImpl
onError
- Called when the process ends with an unrecoverable error- Throws:
ProcessException
-
startChildrenThreads
- Throws:
ProcessException
-
startChildrenThreads
protected void startChildrenThreads(ExecutorService threadPool, Consumer<Throwable> onError) throws ProcessException - Throws:
ProcessException
-
stop
public void stop()Description copied from interface:IProcessExec
Stop process thread gracefully- Specified by:
stop
in interfaceIProcessExec
- Overrides:
stop
in classExecutableProcessImpl
-
combineInputBlocks
public void combineInputBlocks() -
combineOutputBlocks
public void combineOutputBlocks() -
combineOutputBlocks
-
isUseChildrenThreads
public boolean isUseChildrenThreads() -
setUseChildrenThreads
public void setUseChildrenThreads(boolean useThreads) -
needSync
public boolean needSync()- Specified by:
needSync
in interfaceIProcessExec
- Overrides:
needSync
in classExecutableProcessImpl
- Returns:
- True if this process is asynchronous (i.e. outputs are not generated everytime inputs are read) and thus need synchronization with other processes in the chain
-
setOutputNeeded
Description copied from interface:IProcessChainExec
Indicates if data from the specified output is needed or not- Specified by:
setOutputNeeded
in interfaceIProcessChainExec
-
dispose
public void dispose()Description copied from interface:IProcessExec
Override to dispose of all resources allocated for the process (stop threads, OS resources, etc...)- Specified by:
dispose
in interfaceIProcessExec
- Overrides:
dispose
in classExecutableProcessImpl
-
toString
- Overrides:
toString
in classExecutableProcessImpl
-
setParentLogger
public void setParentLogger(org.slf4j.Logger log) Description copied from interface:IProcessExec
Set the parent logger for this process.
The parent logger is used to group log events occuring in all processes that are part of the same processing component (e.g. a process chain for instance) while still allowing to differentiate the actual process instance that issued the log.- Specified by:
setParentLogger
in interfaceIProcessExec
- Overrides:
setParentLogger
in classExecutableProcessImpl
-