Package org.vast.process
Class ExecutableProcessImpl
java.lang.Object
org.vast.process.ExecutableProcessImpl
- All Implemented Interfaces:
 IProcessExec
- Direct Known Subclasses:
 ExecutableChainImpl
Abstract base for all executable process implementations.
- Since:
 - Feb 28, 2015
 
- 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected Future<?>protected static final Stringprotected booleanprotected Map<String,DataConnectionList> protected IOPropertyListprotected Stringprotected static final Stringprotected Map<String,DataConnectionList> protected IOPropertyListprotected Map<String,DataConnectionList> protected IOPropertyListprotected ProcessInfoprotected booleanprotected boolean - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionbooleancanRun()Check that all needed connections are ready for the process to runprotected booleancheckAvailability(Map<String, DataConnectionList> connectionGroup, boolean availability) protected booleancheckAvailability(DataConnectionList connectionList, boolean availability) protected voidprotected voidconnect(String portName, DataComponent component, boolean isSource, IDataConnection connection, Map<String, DataConnectionList> connectionGroup) voidconnect(DataComponent component, IDataConnection connection) Connects one of this process ports with the given connectionprotected voidconsumeData(Map<String, DataConnectionList> connectionGroup, boolean block) protected voidConsume data from input ports.
The default implementation waits for data to be available from all connected inputsprotected voidConsume data from parameter ports.
The default implementation tries to fetch data from all connected parameters but will not wait if data is not available.protected voiddisconnect(DataComponent parentPort, IDataConnection connection) voiddisconnect(IDataConnection connection) Detach connection from this process input, output or parametervoiddispose()Override to dispose of all resources allocated for the process (stop threads, OS resources, etc...)protected voidfinalize()protected Map<String,DataConnectionList> findConnectionGroup(DataComponent parentPort) protected org.slf4j.Loggervoidinit()Initialize the process and its internal variables (fixed parameters).protected voidprotected voidinitPortData(DataComponent port) booleanneedSync()voidNotifies the process that one or more parameter values have changed before or during executionprotected voidprotected voidpublishData(String outputName) protected voidrenewOutputData(String outputName) voidreportError(String msg) Helper method to log an error on the logger attached to this process and throw a ProcessExceptionvoidreportError(String msg, Throwable e) Helper method to log an error on the logger attached to this process and throw a ProcessExceptionvoidrun()Runs the process which includes fetching input data, calling execute and producing output datavoidsetInstanceName(String name) Sets the name of this process instancevoidsetParentLogger(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.voidstart(ExecutorService threadPool, Consumer<Throwable> onError) Start process using threads from the given thread poolvoidStart process in its own threadvoidstop()Stop process thread gracefullytoString()Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.vast.process.IProcessExec
execute 
- 
Field Details
- 
IO_ERROR_MSG
- See Also:
 
 - 
INIT_ERROR_MSG
- See Also:
 
 - 
EXEC_ERROR_MSG
- See Also:
 
 - 
inputData
 - 
outputData
 - 
paramData
 - 
inputConnections
 - 
outputConnections
 - 
paramConnections
 - 
processInfo
 - 
instanceName
 - 
initialized
protected volatile boolean initialized - 
started
protected volatile boolean started - 
usingOutputQueues
protected boolean usingOutputQueues - 
execFuture
 
 - 
 - 
Constructor Details
- 
ExecutableProcessImpl
 
 - 
 - 
Method Details
- 
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- Throws:
 ProcessException
 - 
initPortData
protected void initPortData() - 
initPortData
 - 
checkInitialized
protected void checkInitialized() - 
canRun
public boolean canRun()Description copied from interface:IProcessExecCheck that all needed connections are ready for the process to run- Specified by:
 canRunin interfaceIProcessExec- Returns:
 - true if so and false if at least one connection is not ready.
 
 - 
checkAvailability
protected boolean checkAvailability(Map<String, DataConnectionList> connectionGroup, boolean availability)  - 
checkAvailability
 - 
run
Description copied from interface:IProcessExecRuns the process which includes fetching input data, calling execute and producing output data- Specified by:
 runin interfaceIProcessExec- Throws:
 ProcessException
 - 
start
Description copied from interface:IProcessExecStart process in its own thread- Specified by:
 startin interfaceIProcessExec- 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 interfaceIProcessExeconError- Called when the process ends with an unrecoverable error- Throws:
 ProcessException
 - 
stop
public void stop()Description copied from interface:IProcessExecStop process thread gracefully- Specified by:
 stopin interfaceIProcessExec
 - 
consumeInputData
Consume data from input ports.
The default implementation waits for data to be available from all connected inputs- Throws:
 InterruptedException
 - 
consumeParamData
Consume data from parameter ports.
The default implementation tries to fetch data from all connected parameters but will not wait if data is not available. connected inputs- Throws:
 InterruptedException
 - 
consumeData
protected void consumeData(Map<String, DataConnectionList> connectionGroup, boolean block) throws InterruptedException- Throws:
 InterruptedException
 - 
publishData
- Throws:
 InterruptedException
 - 
publishData
- Throws:
 InterruptedException
 - 
renewOutputData
 - 
needSync
public boolean needSync()- Specified by:
 needSyncin interfaceIProcessExec- 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
 
 - 
getInputConnections
- Specified by:
 getInputConnectionsin interfaceIProcessExec- Returns:
 - Read-only list of connections input ports
 
 - 
getOutputConnections
- Specified by:
 getOutputConnectionsin interfaceIProcessExec- Returns:
 - Read-only list of connections output ports
 
 - 
getParamConnections
- Specified by:
 getParamConnectionsin interfaceIProcessExec- Returns:
 - Read-only list of connections parameter ports
 
 - 
connect
Description copied from interface:IProcessExecConnects one of this process ports with the given connection- Specified by:
 connectin interfaceIProcessExec- Parameters:
 component- input, parameter or output component to connectconnection- connection object to use- Throws:
 ProcessException- if connection cannot be validated (this usually happens because source and destination components are not compatible)
 - 
findConnectionGroup
 - 
connect
protected void connect(String portName, DataComponent component, boolean isSource, IDataConnection connection, Map<String, DataConnectionList> connectionGroup) throws ProcessException- Throws:
 ProcessException
 - 
disconnect
Description copied from interface:IProcessExecDetach connection from this process input, output or parameter- Specified by:
 disconnectin interfaceIProcessExec
 - 
disconnect
 - 
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
 - 
setInstanceName
Description copied from interface:IProcessExecSets the name of this process instance- Specified by:
 setInstanceNamein interfaceIProcessExec
 - 
getLogger
protected org.slf4j.Logger getLogger() - 
getInstanceName
- Specified by:
 getInstanceNamein interfaceIProcessExec- Returns:
 - name of this process instance
 
 - 
getProcessInfo
- Specified by:
 getProcessInfoin interfaceIProcessExec- Returns:
 - all process information (name, UID, etc.)
 
 - 
getInputList
- Specified by:
 getInputListin interfaceIProcessExec- Returns:
 - List of inputs
 
 - 
getOutputList
- Specified by:
 getOutputListin interfaceIProcessExec- Returns:
 - List of outputs
 
 - 
getParameterList
- Specified by:
 getParameterListin interfaceIProcessExec- Returns:
 - List of parameters
 
 - 
notifyParamChange
public void notifyParamChange()Description copied from interface:IProcessExecNotifies the process that one or more parameter values have changed before or during execution- Specified by:
 notifyParamChangein interfaceIProcessExec
 - 
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
 - 
finalize
 - 
toString
 - 
reportError
Helper method to log an error on the logger attached to this process and throw a ProcessException- Parameters:
 msg-- Throws:
 ProcessException
 - 
reportError
Helper method to log an error on the logger attached to this process and throw a ProcessException- Parameters:
 msg-e-- Throws:
 ProcessException
 
 -