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 booleanstatic final ProcessInfoprotected Map<String,DataConnectionList> protected Map<String,DataConnectionList> protected Map<String,DataConnectionList> protected booleanprotected List<IProcessExec>protected Map<String,IProcessExec> protected ExecutorServiceprotected booleanFields 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 chainvoidvoidprotected voidcombineOutputBlocks(String outputName) connect(IProcessExec srcProcess, DataComponent srcComponent, IProcessExec destProcess, DataComponent destComponent) Create connection between ports of two child processesvoidconnectInternal(DataComponent component, IDataConnection connection) protected voiddisconnect(DataComponent parentPort, IDataConnection connection) voiddispose()Override to dispose of all resources allocated for the process (stop threads, OS resources, etc...)voidexecute()Execute contains the logic to transform input/parameter values into output values.protected Map<String,DataConnectionList> findInternalConnectionGroup(DataComponent parentPort) voidinit()Initialize the process and its internal variables (fixed parameters).booleanbooleanneedSync()voidremoveInternalConnection(IDataConnection connection) Completely remove an internal connection between two child processes or between a chain internal port and a child processvoidremoveProcess(String name) Removes a process from the chain and all connections to/from itprotected voidsetNeededInputs(Map<String, DataConnectionList> externalConnections, Map<String, DataConnectionList> internalConnections) protected voidsetNeededOutputs(Map<String, DataConnectionList> externalConnections, Map<String, DataConnectionList> internalConnections) voidsetOutputNeeded(String outputName, boolean needed) Indicates if data from the specified output is needed or notvoidsetParentLogger(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.voidsetUseChildrenThreads(boolean useThreads) voidstart(ExecutorService threadPool, Consumer<Throwable> onError) Start process using threads from the given thread poolvoidStart process in its own threadprotected voidprotected voidstartChildrenThreads(ExecutorService threadPool, Consumer<Throwable> onError) voidstop()Stop process thread gracefullytoString()protected voidtransferInputData(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, setInstanceNameMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
getChildProcessesin interfaceIProcessChainExec- Returns:
- Read-only map of processes included in this chain
-
addProcess
Description copied from interface:IProcessChainExecAdds a child process to this process chain- Specified by:
addProcessin interfaceIProcessChainExec- Returns:
- the added process
-
removeProcess
Description copied from interface:IProcessChainExecRemoves a process from the chain and all connections to/from it- Specified by:
removeProcessin interfaceIProcessChainExec
-
getInternalConnections
- Specified by:
getInternalConnectionsin 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:IProcessChainExecCreate connection between ports of two child processes- Specified by:
connectin interfaceIProcessChainExec- Throws:
ProcessException
-
connectInternal
public void connectInternal(DataComponent component, IDataConnection connection) throws ProcessException - Throws:
ProcessException
-
findInternalConnectionGroup
-
removeInternalConnection
Description copied from interface:IProcessChainExecCompletely remove an internal connection between two child processes or between a chain internal port and a child process- Specified by:
removeInternalConnectionin interfaceIProcessChainExec
-
disconnect
- Overrides:
disconnectin classExecutableProcessImpl
-
init
Description copied from interface:IProcessExecInitialize the process and its internal variables (fixed parameters). This is called only once before the process is executed.- Specified by:
initin interfaceIProcessExec- Overrides:
initin classExecutableProcessImpl- Throws:
ProcessException
-
execute
Description copied from interface:IProcessExecExecute contains the logic to transform input/parameter values into output values. This method should be optimized as much as possible.- Specified by:
executein 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:IProcessExecStart process in its own thread- Specified by:
startin interfaceIProcessExec- Overrides:
startin classExecutableProcessImpl- Parameters:
onError- Called when the process ends with an unrecoverable error- Throws:
ProcessException
-
start
Description copied from interface:IProcessExecStart process using threads from the given thread pool- Specified by:
startin interfaceIProcessExec- Overrides:
startin classExecutableProcessImplonError- 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:IProcessExecStop process thread gracefully- Specified by:
stopin interfaceIProcessExec- Overrides:
stopin 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:
needSyncin interfaceIProcessExec- Overrides:
needSyncin 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:IProcessChainExecIndicates if data from the specified output is needed or not- Specified by:
setOutputNeededin interfaceIProcessChainExec
-
dispose
public void dispose()Description copied from interface:IProcessExecOverride to dispose of all resources allocated for the process (stop threads, OS resources, etc...)- Specified by:
disposein interfaceIProcessExec- Overrides:
disposein classExecutableProcessImpl
-
toString
- Overrides:
toStringin classExecutableProcessImpl
-
setParentLogger
public void setParentLogger(org.slf4j.Logger log) Description copied from interface:IProcessExecSet 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:
setParentLoggerin interfaceIProcessExec- Overrides:
setParentLoggerin classExecutableProcessImpl
-