Package adams.flow.control
Class TimedTee
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,Pausable
,QuickInfoSupporter
,ShallowCopySupporter<Actor>
,SizeOfHandler
,Stoppable
,StoppableWithFeedback
,VariablesInspectionHandler
,FlowPauseStateListener
,VariableChangeListener
,AtomicExecution
,Actor
,ActorHandler
,ActorWithConditionalEquivalent
,ActorWithTimedEquivalent
,CallableActorUser
,ControlActor
,ErrorHandler
,Flushable
,InputConsumer
,MutableActorHandler
,OptionalCallableActor
,OutputProducer
,SubFlowWrapUp
,TimedActor
,Serializable
,Comparable
public class TimedTee extends Tee implements TimedActor
Allows to tap into the flow and tee-off tokens.
Times how long the sub-flow execution takes and sends the time in milli-seconds (as double) in a adams.flow.container.TimingContainer container to the specified callable actor.
Input/output:
- accepts:
adams.flow.core.Unknown
- generates:
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
-name <java.lang.String> (property: name) The name of the actor. default: TimedTee
-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
-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
-finish-before-stopping <boolean> (property: finishBeforeStopping) If enabled, actor first finishes processing all data before stopping. default: false
-asynchronous <boolean> (property: asynchronous) If enabled, the sub-actors get executed asynchronously rather than the flow waiting for them to finish before proceeding with execution. default: false
-tee <adams.flow.core.Actor> [-tee ...] (property: actors) The actors to siphon-off the tokens to. default:
-timing-enabled <boolean> (property: timingEnabled) If enabled, then the actors performs timing on its execution. default: true
-prefix <java.lang.String> (property: prefix) The prefix to store in the timing container; automatically expands variables. default:
-callable <adams.flow.core.CallableActorReference> (property: callableName) The name of the callable actor to use. default: unknown
-optional <boolean> (property: optional) If enabled, then the callable actor is optional, ie no error is raised if not found, merely ignored. default: false
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class adams.flow.control.AbstractTee
AbstractTee.TeeSwingWorker
-
-
Field Summary
Fields Modifier and Type Field Description static String
BACKUP_CALLABLEACTOR
the key for backing up the callable actor.static String
BACKUP_CONFIGURED
the key for backing up the configured state.protected Actor
m_CallableActor
the callable actor.protected CallableActorReference
m_CallableName
the callable name.protected boolean
m_Configured
whether the callable actor has been configured.protected CallableActorHelper
m_Helper
the helper class.protected boolean
m_Optional
whether the callable actor is optional.protected String
m_Prefix
the prefix to use.protected org.apache.commons.lang.time.StopWatch
m_StopWatch
the stopwatch for timing.protected boolean
m_TimingEnabled
whether timing is enabled.-
Fields inherited from class adams.flow.control.AbstractTee
BACKUP_INPUT, m_Actors, m_Asynchronous, m_AsynchronousWorker, m_InputToken, m_MinimumActiveActors, m_OutputToken
-
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 TimedTee()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Hashtable<String,Object>
backupState()
Backs up the current state of the actor before update the variables.String
callableNameTipText()
Returns the tip text for this property.void
cleanUp()
Cleans up after the execution has finished.void
defineOptions()
Adds options to the internal list of options.protected String
doExecute()
Executes the flow item.protected String
executeCallableActor(double msec)
Executes the callable actor.protected Actor
findCallableActor()
Tries to find the callable actor referenced by its callable name.Actor
getCallableActor()
Returns the currently set callable actor.CallableActorReference
getCallableName()
Returns the name of the callable actor in use.Class
getConditionalEquivalent()
Returns the class that is the corresponding conditional equivalent.boolean
getOptional()
Returns whether the callable actor is optional.String
getPrefix()
Returns the prefix to store in the timing container.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.boolean
getTimingEnabled()
Returns whether to perform timing on its execution.String
globalInfo()
Returns a string describing the object.boolean
hasCallableActor()
Checks whether a reference to the callable actor is currently available.protected void
initialize()
Initializes the members.boolean
isFinished()
Returns whether the actor has finished.String
optionalTipText()
Returns the tip text for this property.String
prefixTipText()
Returns the tip text for this property.protected void
pruneBackup()
Removes entries from the backup.protected void
reset()
Resets the scheme.protected void
restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.void
setCallableName(CallableActorReference value)
Sets the name of the callable actor to use.void
setOptional(boolean value)
Sets whether the callable actor is optional.void
setPrefix(String value)
Sets the prefix to store in the timing container.void
setTimingEnabled(boolean value)
Sets whether to perform timing on its execution.String
setUp()
Initializes the item for flow execution.protected String
setUpCallableActor()
Configures the callable actor.void
stopExecution()
Stops the execution.String
timingEnabledTipText()
Returns the tip text for this property.void
wrapUp()
Cleans up after the execution has finished.-
Methods inherited from class adams.flow.control.Tee
checkTeeActor, checkTeeActors, getActorHandlerInfo, getTimedEquivalent, setUpTeeActors
-
Methods inherited from class adams.flow.control.AbstractTee
accepts, actorsTipText, add, add, asynchronousTipText, canProcessInput, check, createTeeToken, currentInput, execute, finishBeforeStoppingTipText, finishedAsynchronousExecution, flushExecution, forceVariables, generates, get, getActors, getAsynchronous, getFinishBeforeStopping, getInternalActors, getMinimumActiveActors, getStoppingTimeout, hasInput, hasPendingOutput, indexOf, input, output, processInput, remove, removeAll, set, setActors, setAsynchronous, setFinishBeforeStopping, setLoggingLevel, setMinimumActiveActors, setSkip, setStoppingTimeout, setUpSubActors, size, stoppingTimeoutTipText, updateParent, waitForAsynchronousExecution
-
Methods inherited from class adams.flow.control.AbstractControlActor
active, canInspectOptions, destroy, firstActive, firstInputConsumer, flowPauseStateChanged, isPaused, isSubFlowWrappedUp, lastActive, pauseExecution, preExecute, resumeExecution, setParent, wrapUpSubFlow
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, canPerformSetUpCheck, compareTo, configureLogger, equals, 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, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, pruneBackup, 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, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, toCommandLine, variableChanged
-
Methods inherited from interface adams.flow.core.ActorHandler
firstActive, lastActive
-
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel, setLoggingLevel
-
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_CALLABLEACTOR
public static final String BACKUP_CALLABLEACTOR
the key for backing up the callable actor.- See Also:
- Constant Field Values
-
BACKUP_CONFIGURED
public static final String BACKUP_CONFIGURED
the key for backing up the configured state.- See Also:
- Constant Field Values
-
m_TimingEnabled
protected boolean m_TimingEnabled
whether timing is enabled.
-
m_Prefix
protected String m_Prefix
the prefix to use.
-
m_CallableName
protected CallableActorReference m_CallableName
the callable name.
-
m_CallableActor
protected Actor m_CallableActor
the callable actor.
-
m_Configured
protected boolean m_Configured
whether the callable actor has been configured.
-
m_Helper
protected CallableActorHelper m_Helper
the helper class.
-
m_Optional
protected boolean m_Optional
whether the callable actor is optional.
-
m_StopWatch
protected transient org.apache.commons.lang.time.StopWatch m_StopWatch
the stopwatch for timing.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Overrides:
globalInfo
in classTee
- Returns:
- a description suitable for displaying in the gui
-
getConditionalEquivalent
public Class getConditionalEquivalent()
Returns the class that is the corresponding conditional equivalent.- Specified by:
getConditionalEquivalent
in interfaceActorWithConditionalEquivalent
- Overrides:
getConditionalEquivalent
in classTee
- Returns:
- the class, null if none available
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractTee
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classAbstractControlActor
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractTee
-
setTimingEnabled
public void setTimingEnabled(boolean value)
Sets whether to perform timing on its execution.- Parameters:
value
- true if timing enabled
-
getTimingEnabled
public boolean getTimingEnabled()
Returns whether to perform timing on its execution.- Returns:
- true if timing enabled
-
timingEnabledTipText
public String timingEnabledTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPrefix
public void setPrefix(String value)
Sets the prefix to store in the timing container.- Parameters:
value
- the prefix
-
getPrefix
public String getPrefix()
Returns the prefix to store in the timing container.- Returns:
- the prefix
-
prefixTipText
public String prefixTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setCallableName
public void setCallableName(CallableActorReference value)
Sets the name of the callable actor to use.- Specified by:
setCallableName
in interfaceTimedActor
- Parameters:
value
- the callable name
-
getCallableName
public CallableActorReference getCallableName()
Returns the name of the callable actor in use.- Specified by:
getCallableName
in interfaceTimedActor
- Returns:
- the callable name
-
callableNameTipText
public String callableNameTipText()
Returns the tip text for this property.- Specified by:
callableNameTipText
in interfaceTimedActor
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOptional
public void setOptional(boolean value)
Sets whether the callable actor is optional.- Specified by:
setOptional
in interfaceOptionalCallableActor
- Parameters:
value
- true if optional
-
getOptional
public boolean getOptional()
Returns whether the callable actor is optional.- Specified by:
getOptional
in interfaceOptionalCallableActor
- Returns:
- true if optional
-
optionalTipText
public String optionalTipText()
Returns the tip text for this property.- Specified by:
optionalTipText
in interfaceOptionalCallableActor
- 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:
getQuickInfo
in interfaceActor
- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Overrides:
getQuickInfo
in classAbstractTee
- Returns:
- null if no info available, otherwise short string
-
findCallableActor
protected Actor findCallableActor()
Tries to find the callable actor referenced by its callable name.- Returns:
- the callable actor or null if not found
-
hasCallableActor
public boolean hasCallableActor()
Checks whether a reference to the callable actor is currently available.- Specified by:
hasCallableActor
in interfaceTimedActor
- Returns:
- true if a reference is available
- See Also:
getCallableActor()
-
getCallableActor
public Actor getCallableActor()
Returns the currently set callable actor.- Specified by:
getCallableActor
in interfaceCallableActorUser
- Specified by:
getCallableActor
in interfaceTimedActor
- Returns:
- the actor, can be null
-
pruneBackup
protected void pruneBackup()
Removes entries from the backup.- Overrides:
pruneBackup
in classAbstractActor
- See Also:
AbstractActor.reset()
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.- Overrides:
backupState
in classAbstractTee
- Returns:
- the backup
- See Also:
AbstractActor.updateVariables()
,AbstractActor.restoreState(Hashtable)
-
restoreState
protected void restoreState(Hashtable<String,Object> state)
Restores the state of the actor before the variables got updated.- Overrides:
restoreState
in classAbstractTee
- Parameters:
state
- the backup of the state to restore from- See Also:
AbstractActor.updateVariables()
,AbstractActor.backupState()
-
setUpCallableActor
protected String setUpCallableActor()
Configures the callable actor.- Returns:
- null if successful, otherwise error message
-
setUp
public String setUp()
Initializes the item for flow execution.- Specified by:
setUp
in interfaceActor
- Overrides:
setUp
in classAbstractControlActor
- Returns:
- null if everything is fine, otherwise error message
- See Also:
AbstractActor.reset()
-
executeCallableActor
protected String executeCallableActor(double msec)
Executes the callable actor. Derived classes might need to override this method to ensure atomicity.- Parameters:
msec
- the time in milli-seconds- Returns:
- null if no error, otherwise error message
-
doExecute
protected String doExecute()
Executes the flow item.- Overrides:
doExecute
in classAbstractTee
- Returns:
- null if everything is fine, otherwise error message
-
isFinished
public boolean isFinished()
Returns whether the actor has finished.- Specified by:
isFinished
in interfaceActor
- Overrides:
isFinished
in classAbstractActor
- Returns:
- true if finished
-
stopExecution
public void stopExecution()
Stops the execution. No message set.- Specified by:
stopExecution
in interfaceActor
- Specified by:
stopExecution
in interfaceStoppable
- Overrides:
stopExecution
in classAbstractTee
-
wrapUp
public void wrapUp()
Cleans up after the execution has finished. Graphical output is left untouched.- Specified by:
wrapUp
in interfaceActor
- Overrides:
wrapUp
in classAbstractTee
-
cleanUp
public void cleanUp()
Cleans up after the execution has finished.- Specified by:
cleanUp
in interfaceActor
- Specified by:
cleanUp
in interfaceCleanUpHandler
- Overrides:
cleanUp
in classAbstractTee
-
-