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 String
protected Future<?>
protected static final String
protected boolean
protected Map<String,
DataConnectionList> protected IOPropertyList
protected String
protected static final String
protected Map<String,
DataConnectionList> protected IOPropertyList
protected Map<String,
DataConnectionList> protected IOPropertyList
protected ProcessInfo
protected boolean
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canRun()
Check that all needed connections are ready for the process to runprotected boolean
checkAvailability
(Map<String, DataConnectionList> connectionGroup, boolean availability) protected boolean
checkAvailability
(DataConnectionList connectionList, boolean availability) protected void
protected void
connect
(String portName, DataComponent component, boolean isSource, IDataConnection connection, Map<String, DataConnectionList> connectionGroup) void
connect
(DataComponent component, IDataConnection connection) Connects one of this process ports with the given connectionprotected void
consumeData
(Map<String, DataConnectionList> connectionGroup, boolean block) protected void
Consume data from input ports.
The default implementation waits for data to be available from all connected inputsprotected void
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.protected void
disconnect
(DataComponent parentPort, IDataConnection connection) void
disconnect
(IDataConnection connection) Detach connection from this process input, output or parametervoid
dispose()
Override to dispose of all resources allocated for the process (stop threads, OS resources, etc...)protected void
finalize()
protected Map<String,
DataConnectionList> findConnectionGroup
(DataComponent parentPort) protected org.slf4j.Logger
void
init()
Initialize the process and its internal variables (fixed parameters).protected void
protected void
initPortData
(DataComponent port) boolean
needSync()
void
Notifies the process that one or more parameter values have changed before or during executionprotected void
protected void
publishData
(String outputName) protected void
renewOutputData
(String outputName) void
reportError
(String msg) Helper method to log an error on the logger attached to this process and throw a ProcessExceptionvoid
reportError
(String msg, Throwable e) Helper method to log an error on the logger attached to this process and throw a ProcessExceptionvoid
run()
Runs the process which includes fetching input data, calling execute and producing output datavoid
setInstanceName
(String name) Sets the name of this process instancevoid
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
start
(ExecutorService threadPool, Consumer<Throwable> onError) Start process using threads from the given thread poolvoid
Start process in its own threadvoid
stop()
Stop process thread gracefullytoString()
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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: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
- Throws:
ProcessException
-
initPortData
protected void initPortData() -
initPortData
-
checkInitialized
protected void checkInitialized() -
canRun
public boolean canRun()Description copied from interface:IProcessExec
Check that all needed connections are ready for the process to run- Specified by:
canRun
in 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:IProcessExec
Runs the process which includes fetching input data, calling execute and producing output data- Specified by:
run
in interfaceIProcessExec
- Throws:
ProcessException
-
start
Description copied from interface:IProcessExec
Start process in its own thread- Specified by:
start
in interfaceIProcessExec
- 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
onError
- Called when the process ends with an unrecoverable error- Throws:
ProcessException
-
stop
public void stop()Description copied from interface:IProcessExec
Stop process thread gracefully- Specified by:
stop
in 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:
needSync
in 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:
getInputConnections
in interfaceIProcessExec
- Returns:
- Read-only list of connections input ports
-
getOutputConnections
- Specified by:
getOutputConnections
in interfaceIProcessExec
- Returns:
- Read-only list of connections output ports
-
getParamConnections
- Specified by:
getParamConnections
in interfaceIProcessExec
- Returns:
- Read-only list of connections parameter ports
-
connect
Description copied from interface:IProcessExec
Connects one of this process ports with the given connection- Specified by:
connect
in 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:IProcessExec
Detach connection from this process input, output or parameter- Specified by:
disconnect
in interfaceIProcessExec
-
disconnect
-
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
-
setInstanceName
Description copied from interface:IProcessExec
Sets the name of this process instance- Specified by:
setInstanceName
in interfaceIProcessExec
-
getLogger
protected org.slf4j.Logger getLogger() -
getInstanceName
- Specified by:
getInstanceName
in interfaceIProcessExec
- Returns:
- name of this process instance
-
getProcessInfo
- Specified by:
getProcessInfo
in interfaceIProcessExec
- Returns:
- all process information (name, UID, etc.)
-
getInputList
- Specified by:
getInputList
in interfaceIProcessExec
- Returns:
- List of inputs
-
getOutputList
- Specified by:
getOutputList
in interfaceIProcessExec
- Returns:
- List of outputs
-
getParameterList
- Specified by:
getParameterList
in interfaceIProcessExec
- Returns:
- List of parameters
-
notifyParamChange
public void notifyParamChange()Description copied from interface:IProcessExec
Notifies the process that one or more parameter values have changed before or during execution- Specified by:
notifyParamChange
in interfaceIProcessExec
-
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
-
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
-