Package adams.flow.source
Class TimedSource
- java.lang.Object
-
- All Implemented Interfaces:
AdditionalInformationHandler,CleanUpHandler,Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,Pausable,QuickInfoSupporter,ShallowCopySupporter<Actor>,SizeOfHandler,Stoppable,StoppableWithFeedback,VariablesInspectionHandler,FlowPauseStateListener,VariableChangeListener,AtomicExecution,Actor,ActorHandler,CallableActorUser,ControlActor,ErrorHandler,Flushable,MutableActorHandler,OptionalCallableActor,OutputProducer,SubFlowWrapUp,TimedActor,Serializable,Comparable
public class TimedSource extends SequenceSource implements TimedActor
Encapsulates a sequence of flow items, with the last one generating the output for this meta-source.
Times how long the sub-source 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:
- 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 min-user-mode: Expert
-name <java.lang.String> (property: name) The name of the actor. default: TimedSource
-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
-finish-before-stopping <boolean> (property: finishBeforeStopping) If enabled, actor first finishes processing all data before stopping. default: false
-stopping-timeout <int> (property: stoppingTimeout) The timeout in milliseconds when waiting for actors to finish (<= 0 for infinity; see 'finishBeforeStopping'). default: -1 minimum: -1
-stopping-warning-interval <int> (property: stoppingWarningInterval) The interval in milliseconds to output logging warnings if the actors haven't stopped yet (and no stopping timeout set); no warning if <= 0. default: 10000 minimum: -1
-actor <adams.flow.core.Actor> [-actor ...] (property: actors) All the actors that define this sequence. 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
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class adams.flow.source.SequenceSource
SequenceSource.SequenceSourceDirector
-
-
Field Summary
Fields Modifier and Type Field Description static StringBACKUP_CALLABLEACTORthe key for backing up the callable actor.static StringBACKUP_CONFIGUREDthe key for backing up the configured state.protected Actorm_CallableActorthe callable actor.protected CallableActorReferencem_CallableNamethe callable name.protected booleanm_Configuredwhether the callable actor has been configured.protected CallableActorHelperm_Helperthe helper class.protected booleanm_Optionalwhether the callable actor is optional.protected Stringm_Prefixthe prefix to use.protected org.apache.commons.lang3.time.StopWatchm_StopWatchthe stopwatch for timing.protected booleanm_TimingEnabledwhether timing is enabled.-
Fields inherited from class adams.flow.source.SequenceSource
m_OutputTokens
-
Fields inherited from class adams.flow.control.MutableConnectedControlActor
m_Actors
-
Fields inherited from class adams.flow.control.AbstractDirectedControlActor
m_Director, m_FinishBeforeStopping, m_StoppingTimeout, m_StoppingWarningInterval
-
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 TimedSource()
-
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.StringcallableNameTipText()Returns the tip text for this property.voidcleanUp()Cleans up after the execution has finished.voiddefineOptions()Adds options to the internal list of options.protected StringdoExecute()Executes the flow item.protected StringexecuteCallableActor(double msec)Executes the callable actor.protected ActorfindCallableActor()Tries to find the callable actor referenced by its callable name.ActorgetCallableActor()Returns the currently set callable actor.CallableActorReferencegetCallableName()Returns the name of the callable actor in use.booleangetOptional()Returns whether the callable actor is optional.StringgetPrefix()Returns the prefix to store in the timing container.StringgetQuickInfo()Returns a quick info about the actor, which will be displayed in the GUI.booleangetTimingEnabled()Returns whether to perform timing on its execution.StringglobalInfo()Returns a string describing the object.booleanhasCallableActor()Checks whether a reference to the callable actor is currently available.protected voidinitialize()Initializes the members.booleanisFinished()Returns whether the actor has finished.StringoptionalTipText()Returns the tip text for this property.StringprefixTipText()Returns the tip text for this property.protected voidpruneBackup()Removes entries from the backup.protected voidreset()Resets the scheme.protected voidrestoreState(Hashtable<String,Object> state)Restores the state of the actor before the variables got updated.voidsetCallableName(CallableActorReference value)Sets the name of the callable actor to use.voidsetOptional(boolean value)Sets whether the callable actor is optional.voidsetPrefix(String value)Sets the prefix to store in the timing container.voidsetTimingEnabled(boolean value)Sets whether to perform timing on its execution.StringsetUp()Initializes the item for flow execution.protected StringsetUpCallableActor()Configures the callable actor.voidstopExecution()Stops the execution.StringtimingEnabledTipText()Returns the tip text for this property.voidwrapUp()Cleans up after the execution has finished.-
Methods inherited from class adams.flow.source.SequenceSource
actorsTipText, addOutputToken, generates, getActorHandlerInfo, getOutputTokens, hasPendingOutput, newDirector, output
-
Methods inherited from class adams.flow.control.MutableConnectedControlActor
add, add, get, getActors, indexOf, remove, removeAll, set, setActors, size
-
Methods inherited from class adams.flow.control.AbstractConnectedControlActor
check, checkConnections, classesToString
-
Methods inherited from class adams.flow.control.AbstractDirectedControlActor
finishBeforeStoppingTipText, flushExecution, getDirector, getFinishBeforeStopping, getStoppingTimeout, getStoppingWarningInterval, setFinishBeforeStopping, setStoppingTimeout, setStoppingWarningInterval, stoppingTimeoutTipText, stoppingWarningIntervalTipText, updateVariables
-
Methods inherited from class adams.flow.control.AbstractControlActor
active, canInspectOptions, destroy, firstActive, firstInputConsumer, flowPauseStateChanged, forceVariables, isPaused, isSubFlowWrappedUp, lastActive, pauseExecution, preExecute, resumeExecution, setParent, setUpSubActors, updateParent, wrapUpSubFlow
-
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, 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, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, postExecute, pruneBackup, setAnnotations, setErrorHandler, setName, setSilent, setSkip, setStopFlowOnError, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, variableChanged
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, 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
check, firstActive, flushExecution, 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.lang3.time.StopWatch m_StopWatch
the stopwatch for timing.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Overrides:
globalInfoin classSequenceSource- 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 classMutableConnectedControlActor
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin classAbstractControlActor
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classMutableConnectedControlActor
-
setTimingEnabled
public void setTimingEnabled(boolean value)
Sets whether to perform timing on its execution.- Specified by:
setTimingEnabledin interfaceTimedActor- Parameters:
value- true if timing enabled
-
getTimingEnabled
public boolean getTimingEnabled()
Returns whether to perform timing on its execution.- Specified by:
getTimingEnabledin interfaceTimedActor- Returns:
- true if timing enabled
-
timingEnabledTipText
public String timingEnabledTipText()
Returns the tip text for this property.- Specified by:
timingEnabledTipTextin interfaceTimedActor- 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.- Specified by:
setPrefixin interfaceTimedActor- Parameters:
value- the prefix
-
getPrefix
public String getPrefix()
Returns the prefix to store in the timing container.- Specified by:
getPrefixin interfaceTimedActor- Returns:
- the prefix
-
prefixTipText
public String prefixTipText()
Returns the tip text for this property.- Specified by:
prefixTipTextin interfaceTimedActor- 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:
setCallableNamein interfaceTimedActor- Parameters:
value- the callable name
-
getCallableName
public CallableActorReference getCallableName()
Returns the name of the callable actor in use.- Specified by:
getCallableNamein interfaceTimedActor- Returns:
- the callable name
-
callableNameTipText
public String callableNameTipText()
Returns the tip text for this property.- Specified by:
callableNameTipTextin 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:
setOptionalin interfaceOptionalCallableActor- Parameters:
value- true if optional
-
getOptional
public boolean getOptional()
Returns whether the callable actor is optional.- Specified by:
getOptionalin interfaceOptionalCallableActor- Returns:
- true if optional
-
optionalTipText
public String optionalTipText()
Returns the tip text for this property.- Specified by:
optionalTipTextin 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:
getQuickInfoin interfaceActor- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Overrides:
getQuickInfoin classAbstractDirectedControlActor- 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:
hasCallableActorin interfaceTimedActor- Returns:
- true if a reference is available
- See Also:
getCallableActor()
-
getCallableActor
public Actor getCallableActor()
Returns the currently set callable actor.- Specified by:
getCallableActorin interfaceCallableActorUser- Specified by:
getCallableActorin interfaceTimedActor- Returns:
- the actor, can be null
-
pruneBackup
protected void pruneBackup()
Removes entries from the backup.- Overrides:
pruneBackupin classAbstractActor- See Also:
AbstractActor.reset()
-
backupState
protected Hashtable<String,Object> backupState()
Backs up the current state of the actor before update the variables.- Overrides:
backupStatein classAbstractActor- 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:
restoreStatein classAbstractActor- 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:
setUpin interfaceActor- Overrides:
setUpin classAbstractDirectedControlActor- 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:
doExecutein classAbstractDirectedControlActor- Returns:
- null if everything is fine, otherwise error message
-
isFinished
public boolean isFinished()
Returns whether the actor has finished.- Specified by:
isFinishedin interfaceActor- Overrides:
isFinishedin classAbstractActor- Returns:
- true if finished
-
stopExecution
public void stopExecution()
Stops the execution. No message set.- Specified by:
stopExecutionin interfaceActor- Specified by:
stopExecutionin interfaceStoppable- Overrides:
stopExecutionin classAbstractDirectedControlActor
-
wrapUp
public void wrapUp()
Cleans up after the execution has finished. Graphical output is left untouched.- Specified by:
wrapUpin interfaceActor- Overrides:
wrapUpin classAbstractDirectedControlActor
-
cleanUp
public void cleanUp()
Cleans up after the execution has finished.- Specified by:
cleanUpin interfaceActor- Specified by:
cleanUpin interfaceCleanUpHandler- Overrides:
cleanUpin classSequenceSource
-
-