Package adams.flow.control
Class LaunchTee
-
- All Implemented Interfaces:
AdditionalInformationHandler,CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,OptionalThreadLimiter,Pausable,QuickInfoSupporter,ShallowCopySupporter<Actor>,SizeOfHandler,Stoppable,StoppableWithFeedback,ThreadLimiter,VariablesInspectionHandler,FlowPauseStateListener,VariableChangeListener,Actor,ActorHandler,ControlActor,ErrorHandler,Flushable,InputConsumer,MutableActorHandler,SubFlowWrapUp,Serializable,Comparable
public class LaunchTee extends AbstractControlActor implements InputConsumer, MutableActorHandler, OptionalThreadLimiter
Launches the sub-flow in a separate thread each time a token arrives.
Internally, a adams.flow.control.LocalScopeTee is used to manage the scope and forward the token.
However, when imposing thread limits, a job gets created with the sub-actors and placed into a job runner for execution.
Input/output:
- accepts:
adams.flow.core.Unknown
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING min-user-mode: Expert
-name <java.lang.String> (property: name) The name of the actor. default: LaunchTee
-annotation <adams.core.base.BaseAnnotation> (property: annotations) The annotations to attach to this actor. default:
-skip <boolean> (property: skip) If set to true, transformation is skipped and the input token is just forwarded as it is. default: false
-stop-flow-on-error <boolean> (property: stopFlowOnError) If set to true, the flow execution at this level gets stopped in case this actor encounters an error; the error gets propagated; useful for critical actors. default: false min-user-mode: Expert
-silent <boolean> (property: silent) If enabled, then no errors are output in the console; Note: the enclosing actor handler must have this enabled as well. default: false min-user-mode: Expert
-actors <adams.flow.core.Actor> [-actors ...] (property: actors) The actors to launch with the incoming tokens. default:
-scope-handling-variables <EMPTY|COPY|SHARE> (property: scopeHandlingVariables) Defines how variables are handled in the local scope; whether to start with empty set, a copy of the outer scope variables or share variables with the outer scope. default: EMPTY
-variables-filter <adams.core.base.BaseRegExp> (property: variablesFilter) The regular expression that variable names must match in order to get into the local scope (when using COPY). default: .* more: https://docs.oracle.com/javase/tutorial/essential/regex/ https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html
-scope-handling-storage <EMPTY|COPY|SHARE> (property: scopeHandlingStorage) Defines how storage is handled in the local scope; whether to start with empty set, a (deep) copy of the outer scope storage or share the storage with the outer scope. default: EMPTY
-storage-filter <adams.core.base.BaseRegExp> (property: storageFilter) The regular expression that storage item names must match in order to get into the local scope (when using COPY). default: .* more: https://docs.oracle.com/javase/tutorial/essential/regex/ https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html
-impose-thread-limits <boolean> (property: imposeThreadLimits) If enabled, imposes the specified limit on threads. default: false
-num-threads <int> (property: numThreads) The number of threads to use for parallel execution; > 0: specific number of cores to use (capped by actual number of cores available, 1 = sequential execution); = 0: number of cores; < 0: number of free cores (eg -2 means 2 free cores; minimum of one core is used) default: -1
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLaunchTee.LaunchJob
-
Field Summary
Fields Modifier and Type Field Description static StringBACKUP_INPUTthe key for storing the input token in the backup.protected Teem_Actorsthe sub-flow to launch.protected booleanm_ImposeThreadLimitswhether to limit the number of threads.protected Tokenm_InputTokenthe input token.protected JobRunnerm_JobRunnerthe job runner.protected List<LocalScopeTee>m_Launchedthe launched sub-flows.protected intm_NumThreadsthe number of threads to use for parallel execution.protected ScopeHandler.ScopeHandlingm_ScopeHandlingStoragehow to handle the storage.protected ScopeHandler.ScopeHandlingm_ScopeHandlingVariableshow to handle the variables.protected BaseRegExpm_StorageFilterthe regular expression of the storage items to allow into the local scope.protected BaseRegExpm_VariablesFilterthe regular expression of the variables to allow into the local scope.-
Fields inherited from class adams.flow.control.AbstractControlActor
m_Compatibility, m_PauseStateManager, m_SetUpSubActors
-
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
-
-
Constructor Summary
Constructors Constructor Description LaunchTee()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class[]accepts()Returns the class that the consumer accepts.StringactorsTipText()Returns the tip text for this property.Stringadd(int index, Actor actor)Inserts the actor at the given position.Stringadd(Actor actor)Inserts the actor at the end.Stringcheck()Performs checks on the "sub-actors".protected StringcheckSubActor(int index, Actor actor)Checks the sub actor before it is set.protected StringcheckSubActors(Actor[] actors)Checks the tee actors before they are set via the setSubActors method.voidcleanUp()Cleans up after the execution has finished.TokencurrentInput()Returns the current input token, if any.voiddefineOptions()Adds options to the internal list of options.protected StringdoExecute()Executes the flow item.Actorget(int index)Returns the actor at the given position.ActorHandlerInfogetActorHandlerInfo()Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.Actor[]getActors()Returns the actors to launch.booleangetImposeThreadLimits()Returns whether to limit the number of threads to use.intgetNumThreads()Returns the number of threads to use for parallel execution of threads.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.ScopeHandler.ScopeHandlinggetScopeHandlingStorage()Returns how storage is handled in the local scope.ScopeHandler.ScopeHandlinggetScopeHandlingVariables()Returns how variables are handled in the local scope.BaseRegExpgetStorageFilter()Returns the regular expression that storage item names must match to get into the local scope.BaseRegExpgetVariablesFilter()Returns the regular expression that variable names must match to get into the local scope.StringglobalInfo()Returns a string describing the object.booleanhasInput()Returns whether an input token is currently present.StringimposeThreadLimitsTipText()Returns the tip text for this property.intindexOf(String actor)Returns the index of the actor.protected voidinitialize()Initializes the members.voidinput(Token token)The method that accepts the input token and then processes it.StringnumThreadsTipText()Returns the tip text for this property.Actorremove(int index)Removes the actor at the given position and returns the removed object.voidremoveAll()Removes all actors.StringscopeHandlingStorageTipText()Returns the tip text for this property.StringscopeHandlingVariablesTipText()Returns the tip text for this property.Stringset(int index, Actor actor)Sets the actor at the given position.voidsetActors(Actor[] value)Sets the actor to launch.voidsetImposeThreadLimits(boolean value)Sets whether to limit the number of threads to use.voidsetLoggingLevel(LoggingLevel value)Sets the logging level.voidsetNumThreads(int value)Sets the number of threads to use for parallel execution of threads.voidsetScopeHandlingStorage(ScopeHandler.ScopeHandling value)Sets how to handle storage in the local scope.voidsetScopeHandlingVariables(ScopeHandler.ScopeHandling value)Sets how to handle variables into the local scope.voidsetSkip(boolean value)Sets whether the transformation is skipped or not.voidsetStorageFilter(BaseRegExp value)Sets the regular expression that storage item names must match to get into the local scope.StringsetUp()Initializes the item for flow execution.voidsetVariablesFilter(BaseRegExp value)Sets the regular expression that variable names must match to get into the local scope.intsize()Returns the size of the group.voidstopExecution()Stops the execution.StringstorageFilterTipText()Returns the tip text for this property.StringvariablesFilterTipText()Returns the tip text for this property.voidwrapUp()Finishes up the execution.-
Methods inherited from class adams.flow.control.AbstractControlActor
active, canInspectOptions, destroy, firstActive, firstInputConsumer, flowPauseStateChanged, flushExecution, forceVariables, isPaused, isSubFlowWrappedUp, lastActive, pauseExecution, preExecute, reset, resumeExecution, setParent, setUpSubActors, updateParent, wrapUpSubFlow
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canPerformSetUpCheck, compareTo, configureLogger, equals, execute, finalUpdateVariables, findVariables, findVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, pruneBackup, pruneBackup, restoreState, setAnnotations, setErrorHandler, setName, setSilent, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.flow.core.Actor
compareTo, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.flow.core.ActorHandler
firstActive, flushExecution, lastActive
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.logging.LoggingSupporter
getLogger, isLoggingEnabled
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
-
Methods inherited from interface adams.core.VariablesInspectionHandler
canInspectOptions
-
-
-
-
Field Detail
-
BACKUP_INPUT
public static final String BACKUP_INPUT
the key for storing the input token in the backup.- See Also:
- Constant Field Values
-
m_ScopeHandlingVariables
protected ScopeHandler.ScopeHandling m_ScopeHandlingVariables
how to handle the variables.
-
m_VariablesFilter
protected BaseRegExp m_VariablesFilter
the regular expression of the variables to allow into the local scope.
-
m_ScopeHandlingStorage
protected ScopeHandler.ScopeHandling m_ScopeHandlingStorage
how to handle the storage.
-
m_StorageFilter
protected BaseRegExp m_StorageFilter
the regular expression of the storage items to allow into the local scope.
-
m_Actors
protected Tee m_Actors
the sub-flow to launch.
-
m_ImposeThreadLimits
protected boolean m_ImposeThreadLimits
whether to limit the number of threads.
-
m_NumThreads
protected int m_NumThreads
the number of threads to use for parallel execution.
-
m_JobRunner
protected transient JobRunner m_JobRunner
the job runner.
-
m_Launched
protected transient List<LocalScopeTee> m_Launched
the launched sub-flows.
-
m_InputToken
protected transient Token m_InputToken
the input token.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractActor
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classAbstractControlActor
-
setLoggingLevel
public void setLoggingLevel(LoggingLevel value)
Sets the logging level.- Specified by:
setLoggingLevelin interfaceLoggingLevelHandler- Overrides:
setLoggingLevelin classAbstractOptionHandler- Parameters:
value- the level
-
setSkip
public void setSkip(boolean value)
Sets whether the transformation is skipped or not.- Specified by:
setSkipin interfaceActor- Overrides:
setSkipin classAbstractActor- Parameters:
value- true if transformation is to be skipped
-
getActorHandlerInfo
public ActorHandlerInfo getActorHandlerInfo()
Returns some information about the actor handler, e.g., whether it can contain standalones and the actor execution.- Specified by:
getActorHandlerInfoin interfaceActorHandler- Specified by:
getActorHandlerInfoin classAbstractControlActor- Returns:
- the info
-
size
public int size()
Returns the size of the group.- Specified by:
sizein interfaceActorHandler- Specified by:
sizein classAbstractControlActor- Returns:
- the size
-
get
public Actor get(int index)
Returns the actor at the given position.- Specified by:
getin interfaceActorHandler- Specified by:
getin classAbstractControlActor- Parameters:
index- the position- Returns:
- the actor
-
set
public String set(int index, Actor actor)
Sets the actor at the given position.- Specified by:
setin interfaceActorHandler- Specified by:
setin classAbstractControlActor- Parameters:
index- the positionactor- the actor to set at this position- Returns:
- null if successful, otherwise error message
-
indexOf
public int indexOf(String actor)
Returns the index of the actor.- Specified by:
indexOfin interfaceActorHandler- Specified by:
indexOfin classAbstractControlActor- Parameters:
actor- the name of the actor to look for- Returns:
- the index of -1 if not found
-
accepts
public Class[] accepts()
Returns the class that the consumer accepts.- Specified by:
acceptsin interfaceInputConsumer- Returns:
- the Class of objects that can be processed
-
input
public void input(Token token)
The method that accepts the input token and then processes it.- Specified by:
inputin interfaceInputConsumer- Parameters:
token- the token to accept and process
-
hasInput
public boolean hasInput()
Returns whether an input token is currently present.- Specified by:
hasInputin interfaceInputConsumer- Returns:
- true if input token present
-
currentInput
public Token currentInput()
Returns the current input token, if any.- Specified by:
currentInputin interfaceInputConsumer- Returns:
- the input token, null if none present
-
add
public String add(Actor actor)
Inserts the actor at the end.- Specified by:
addin interfaceMutableActorHandler- Parameters:
actor- the actor to insert- Returns:
- null if successful, otherwise error message
-
add
public String add(int index, Actor actor)
Inserts the actor at the given position.- Specified by:
addin interfaceMutableActorHandler- Parameters:
index- the positionactor- the actor to insert- Returns:
- null if successful, otherwise error message
-
remove
public Actor remove(int index)
Removes the actor at the given position and returns the removed object.- Specified by:
removein interfaceMutableActorHandler- Parameters:
index- the position- Returns:
- the removed actor
-
removeAll
public void removeAll()
Removes all actors.- Specified by:
removeAllin interfaceMutableActorHandler
-
check
public String check()
Performs checks on the "sub-actors".- Specified by:
checkin interfaceActorHandler- Overrides:
checkin classAbstractControlActor- Returns:
- null if checks passed or null in case of an error
-
checkSubActor
protected String checkSubActor(int index, Actor actor)
Checks the sub actor before it is set. Returns an error message if the actor is not acceptable, null otherwise.- Parameters:
index- the index the actor gets setactor- the actor to check- Returns:
- null if accepted, otherwise error message
-
checkSubActors
protected String checkSubActors(Actor[] actors)
Checks the tee actors before they are set via the setSubActors method. Returns an error message if the actors are not acceptable, null otherwise.- Parameters:
actors- the actors to check- Returns:
- null if accepted, otherwise error message
-
setActors
public void setActors(Actor[] value)
Sets the actor to launch.- Parameters:
value- the actor
-
getActors
public Actor[] getActors()
Returns the actors to launch.- Returns:
- the actors
-
actorsTipText
public String actorsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setScopeHandlingVariables
public void setScopeHandlingVariables(ScopeHandler.ScopeHandling value)
Sets how to handle variables into the local scope.- Parameters:
value- the scope handling
-
getScopeHandlingVariables
public ScopeHandler.ScopeHandling getScopeHandlingVariables()
Returns how variables are handled in the local scope.- Returns:
- the scope handling
-
scopeHandlingVariablesTipText
public String scopeHandlingVariablesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setVariablesFilter
public void setVariablesFilter(BaseRegExp value)
Sets the regular expression that variable names must match to get into the local scope.- Parameters:
value- the expression
-
getVariablesFilter
public BaseRegExp getVariablesFilter()
Returns the regular expression that variable names must match to get into the local scope.- Returns:
- the expression
-
variablesFilterTipText
public String variablesFilterTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setScopeHandlingStorage
public void setScopeHandlingStorage(ScopeHandler.ScopeHandling value)
Sets how to handle storage in the local scope.- Parameters:
value- the scope handling
-
getScopeHandlingStorage
public ScopeHandler.ScopeHandling getScopeHandlingStorage()
Returns how storage is handled in the local scope.- Returns:
- the scope handling
-
scopeHandlingStorageTipText
public String scopeHandlingStorageTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setStorageFilter
public void setStorageFilter(BaseRegExp value)
Sets the regular expression that storage item names must match to get into the local scope.- Parameters:
value- the expression
-
getStorageFilter
public BaseRegExp getStorageFilter()
Returns the regular expression that storage item names must match to get into the local scope.- Returns:
- the expression
-
storageFilterTipText
public String storageFilterTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setImposeThreadLimits
public void setImposeThreadLimits(boolean value)
Sets whether to limit the number of threads to use.- Specified by:
setImposeThreadLimitsin interfaceOptionalThreadLimiter- Parameters:
value- true if to limit
-
getImposeThreadLimits
public boolean getImposeThreadLimits()
Returns whether to limit the number of threads to use.- Specified by:
getImposeThreadLimitsin interfaceOptionalThreadLimiter- Returns:
- true if to limit
-
imposeThreadLimitsTipText
public String imposeThreadLimitsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNumThreads
public void setNumThreads(int value)
Sets the number of threads to use for parallel execution of threads.- Specified by:
setNumThreadsin interfaceThreadLimiter- Parameters:
value- the number of threads: -1 = # of CPUs/cores; 0/1 = sequential execution
-
getNumThreads
public int getNumThreads()
Returns the number of threads to use for parallel execution of threads.- Specified by:
getNumThreadsin interfaceThreadLimiter- Returns:
- the number of threads: -1 = # of CPUs/cores; 0/1 = sequential execution
-
numThreadsTipText
public String numThreadsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfoin interfaceActor- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin classAbstractActor- Returns:
- null if no info available, otherwise short string
-
setUp
public String setUp()
Initializes the item for flow execution.- Specified by:
setUpin interfaceActor- Overrides:
setUpin classAbstractControlActor- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
doExecute
protected String doExecute()
Executes the flow item.- Specified by:
doExecutein classAbstractActor- Returns:
- null if everything is fine, otherwise error message
-
stopExecution
public void stopExecution()
Stops the execution. No message set.- Specified by:
stopExecutionin interfaceActor- Specified by:
stopExecutionin interfaceStoppable- Overrides:
stopExecutionin classAbstractControlActor
-
wrapUp
public void wrapUp()
Finishes up the execution.- Specified by:
wrapUpin interfaceActor- Overrides:
wrapUpin classAbstractControlActor
-
cleanUp
public void cleanUp()
Cleans up after the execution has finished. Also removes graphical components.- Specified by:
cleanUpin interfaceActor- Specified by:
cleanUpin interfaceCleanUpHandler- Overrides:
cleanUpin classAbstractControlActor
-
-