public class StepManagerImpl extends java.lang.Object implements StepManager
CON_AUX_DATA_BATCH_ASSOCIATION_RULES, CON_AUX_DATA_CHART_DATA_POINT, CON_AUX_DATA_CHART_LEGEND, CON_AUX_DATA_CHART_MAX, CON_AUX_DATA_CHART_MIN, CON_AUX_DATA_CLASS_ATTRIBUTE, CON_AUX_DATA_ENVIRONMENT_PROPERTIES, CON_AUX_DATA_ENVIRONMENT_RESULTS, CON_AUX_DATA_ENVIRONMENT_VARIABLES, CON_AUX_DATA_GRAPH_TITLE, CON_AUX_DATA_GRAPH_TYPE, CON_AUX_DATA_INCREMENTAL_STREAM_END, CON_AUX_DATA_INSTANCE, CON_AUX_DATA_IS_INCREMENTAL, CON_AUX_DATA_LABEL, CON_AUX_DATA_MAX_SET_NUM, CON_AUX_DATA_PRIMARY_PAYLOAD_NOT_THREAD_SAFE, CON_AUX_DATA_SET_NUM, CON_AUX_DATA_TEST_INSTANCE, CON_AUX_DATA_TESTSET, CON_AUX_DATA_TEXT_TITLE, CON_AUX_DATA_TRAININGSET, CON_BATCH_ASSOCIATOR, CON_BATCH_CLASSIFIER, CON_BATCH_CLUSTERER, CON_CHART, CON_DATASET, CON_ENVIRONMENT, CON_GRAPH, CON_IMAGE, CON_INCREMENTAL_CLASSIFIER, CON_INCREMENTAL_CLUSTERER, CON_INFO, CON_INSTANCE, CON_JOB_FAILURE, CON_JOB_SUCCESS, CON_TESTSET, CON_TEXT, CON_THRESHOLD_DATA, CON_TRAININGSET, CON_VISUALIZABLE_ERROR
Constructor and Description |
---|
StepManagerImpl(Step step)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addIncomingConnection(java.lang.String connectionName,
StepManagerImpl step)
Add an incoming connection (comprising of the type of connection and
associated step component) to this step of the specified type
|
boolean |
addOutgoingConnection(java.lang.String connectionName,
StepManagerImpl step)
Add an outgoing connection (comprising of the type of connection and
associated target step) to this step of the specified type.
|
boolean |
addOutgoingConnection(java.lang.String connectionName,
StepManagerImpl step,
boolean force)
Add an outgoing connection (comprising of the type of connection and
associated target step) to this step of the specified type.
|
void |
addStepOutputListener(StepOutputListener listener,
java.lang.String outputConnectionName)
Register non-step third party to receive data from the managed step for the
specified outgoing connection type.
|
void |
clearAllConnections()
Clear all connections to/from the step managed by this manager.
|
void |
clearAllStepOutputListeners()
Clear all registered StepOutputListeners
|
void |
clearStepOutputListeners(java.lang.String outputConnectionName)
Clear all the StepOutputListeners that are registered to receive the
supplied connection type.
|
void |
disconnectStep(Step toDisconnect)
Remove the supplied step from connections (both incoming and outgoing of
all types) for the step managed by this manager.
|
void |
disconnectStepWithConnection(Step toDisconnect,
java.lang.String connType)
Disconnect the supplied step under the associated connection type from both
the incoming and outgoing connections for the step managed by this manager.
|
java.lang.String |
environmentSubstitute(java.lang.String source)
Substitute the values of environment variables in the given string
|
StepManager |
findStepInFlow(java.lang.String stepNameToFind)
Finds a named step in the current flow.
|
void |
finished()
Finished all processing.
|
ExecutionEnvironment |
getExecutionEnvironment()
Get the execution environment the managed step is running in
|
java.util.List<StepManager> |
getIncomingConnectedStepsOfConnectionType(java.lang.String connectionName)
Get a list of steps providing incoming connections of the specified type
|
StepManager |
getIncomingConnectedStepWithName(java.lang.String stepName)
Get a named step connected to this step with an incoming connection
|
java.util.Map<java.lang.String,java.util.List<StepManager>> |
getIncomingConnections()
Get the man of upstream (incoming connections) connected steps
|
Instances |
getIncomingStructureForConnectionType(java.lang.String connectionName)
Attempt to get the incoming structure (as a header-only set of instances)
for the named incoming connection type.
|
Instances |
getIncomingStructureForConnectionType(java.lang.String connectionName,
Environment env)
Attempt to retrieve the structure (as a header-only set of instances) for
the named incoming connection type.
|
Instances |
getIncomingStructureFromStep(StepManager sourceStep,
java.lang.String connectionName)
Attempt to get the incoming structure (as a header-only set of instances)
from the given managed step for the given connection type.
|
Step |
getInfoStep()
Returns a reference to the step being managed if it has one or more
outgoing CON_INFO connections.
|
Step |
getInfoStep(java.lang.Class stepClass)
Returns a reference to the step being managed if it has one or more
outgoing CON_INFO connections and the managed step is of the supplied class
|
Logger |
getLog()
Get the log to use
|
LoggingLevel |
getLoggingLevel()
Get the logging level in use
|
Step |
getManagedStep()
Get the step managed by this manager
|
java.lang.String |
getName()
Get the name of the Step being managed
|
java.util.List<StepManager> |
getOutgoingConnectedStepsOfConnectionType(java.lang.String connectionName)
Get a list of downstream steps connected to this step with the given
connection type.
|
StepManager |
getOutgoingConnectedStepWithName(java.lang.String stepName)
Get a named step connected to this step with an outgoing connection
|
java.util.Map<java.lang.String,java.util.List<StepManager>> |
getOutgoingConnections()
Get the map of downstream (outgoing connections) connected steps
|
Settings |
getSettings()
Get the current knowledge flow settings
|
boolean |
getStepMustRunSingleThreaded()
Get whether the managed step must run single-threaded.
|
java.util.List<java.lang.String> |
getStepOutgoingConnectionTypes()
Used by the rendering routine in LayoutPanel to ensure that connections
downstream from a deleted connection get rendered in grey rather than red.
|
java.lang.Object |
getStepProperty(java.lang.String name)
Get a named property for this step.
|
StepVisual |
getStepVisual()
Get the step visual in use (if running in a visual environment)
|
void |
interrupted()
Finished processing due to a stop being requested.
|
boolean |
isStepBusy()
Returns true if, at the current time, the managed step is busy with
processing
|
boolean |
isStepFinished()
Return true if the current step is finished.
|
boolean |
isStopRequested()
Return true if a stop has been requested by the runtime environment
|
boolean |
isStreamFinished(Data data)
Returns true if this data object marks the end of an incremental stream.
|
void |
log(java.lang.String message,
LoggingLevel level)
Log a message at the supplied logging level
|
void |
logBasic(java.lang.String message)
Log a message at the basic logging level
|
void |
logDebug(java.lang.String message)
Log a message at the debugging logging level
|
void |
logDetailed(java.lang.String message)
Log a message at the detailed logging level
|
void |
logError(java.lang.String message,
java.lang.Throwable cause)
Log an error
|
void |
logLow(java.lang.String message)
Log a message at the low logging level
|
void |
logWarning(java.lang.String message)
Log a warning message
|
int |
numIncomingConnections()
Get the number of incoming connections to the managed step
|
int |
numIncomingConnectionsOfType(java.lang.String connectionName)
Get the number of incoming connections to the managed step of a given type
|
int |
numOutgoingConnections()
Get the number of outgoing connections from the managed step
|
int |
numOutgoingConnectionsOfType(java.lang.String connectionName)
Get the number of outgoing connections from the managed step of a given
type
|
void |
outputData(Data... data)
Output one or more Data objects to all relevant steps.
|
void |
outputData(java.lang.String outgoingConnectionName,
Data data)
Output a Data object to all downstream connected Steps that are connected
with the supplied connection name.
|
void |
outputData(java.lang.String outgoingConnectionName,
java.lang.String stepName,
Data data)
Outputs the supplied Data object to the named Step.
|
void |
processing()
Started processing.
|
void |
removeIncomingConnection(java.lang.String connectionName,
StepManagerImpl step)
Remove an incoming connection to this step of the specified type
|
void |
removeOutgoingConnection(java.lang.String connectionName,
StepManagerImpl step)
Remove an outgoing connection from this step of the specified type
|
void |
removeStepOutputListener(StepOutputListener listener,
java.lang.String outputConnectionName)
De-register non-step third party from receiving data from the managed step
|
void |
setLog(Logger log)
Set the log to use
|
void |
setLoggingLevel(LoggingLevel newLevel)
Set the logging level to use
|
void |
setManagedStep(Step step)
Set the step managed by this manager
|
void |
setStepIsResourceIntensive(boolean resourceIntensive)
Set whether the managed step is resource (cpu/memory) intensive or not
|
void |
setStepMustRunSingleThreaded(boolean mustRunSingleThreaded)
Set whether the managed step must run single-threaded.
|
void |
setStepProperty(java.lang.String name,
java.lang.Object value)
Set a property for this step
|
void |
setStepVisual(StepVisual visual)
Set the step visual to use when running in a graphical environment
|
void |
setStopRequested(boolean stopRequested)
Set the status of the stop requested flag
|
void |
statusMessage(java.lang.String message)
Output a status message to the status area of the log
|
boolean |
stepIsResourceIntensive()
Get whether the managed step is resource (cpu/memory) intensive or not
|
java.lang.String |
stepStatusMessagePrefix()
Gets a prefix for the step managed by this manager.
|
void |
throughputFinished(Data... data)
Clients can use this to indicate that throughput measuring is finished
(i.e.
|
void |
throughputUpdateEnd()
Clients can use this to record a stop point for streaming throughput
measuring
|
void |
throughputUpdateStart()
Clients can use this to record a start point for streaming throughput
measuring
|
public StepManagerImpl(Step step)
step
- the Step to managepublic java.lang.String getName()
getName
in interface StepManager
public Step getManagedStep()
getManagedStep
in interface StepManager
public void setManagedStep(Step step)
step
- the step to managepublic void setStepIsResourceIntensive(boolean resourceIntensive)
setStepIsResourceIntensive
in interface StepManager
resourceIntensive
- true if the managed step is resource intensivepublic boolean stepIsResourceIntensive()
stepIsResourceIntensive
in interface StepManager
public void setStepMustRunSingleThreaded(boolean mustRunSingleThreaded)
setStepMustRunSingleThreaded
in interface StepManager
mustRunSingleThreaded
- true if the managed step must run
single-threadedpublic boolean getStepMustRunSingleThreaded()
getStepMustRunSingleThreaded
in interface StepManager
public StepVisual getStepVisual()
public void setStepVisual(StepVisual visual)
visual
- the step visual to usepublic void setStepProperty(java.lang.String name, java.lang.Object value)
name
- the name of the propertyvalue
- the value of the propertypublic java.lang.Object getStepProperty(java.lang.String name)
name
- the name of the property to getpublic ExecutionEnvironment getExecutionEnvironment()
getExecutionEnvironment
in interface StepManager
public Settings getSettings()
getSettings
in interface StepManager
java.lang.IllegalStateException
- if there is no execution environment
availablepublic LoggingLevel getLoggingLevel()
getLoggingLevel
in interface StepManager
public void setLoggingLevel(LoggingLevel newLevel)
newLevel
- the level to usepublic Logger getLog()
getLog
in interface StepManager
public void setLog(Logger log)
log
- the log to usepublic boolean isStepBusy()
isStepBusy
in interface StepManager
public boolean isStopRequested()
isStopRequested
in interface StepManager
public boolean isStepFinished()
isStepFinished
in interface StepManager
public void setStopRequested(boolean stopRequested)
stopRequested
- true if a stop has been requestedpublic void processing()
processing
in interface StepManager
public void finished()
finished
in interface StepManager
public void interrupted()
interrupted
in interface StepManager
public boolean isStreamFinished(Data data)
isStreamFinished
in interface StepManager
data
- the data element to checkpublic void throughputUpdateStart()
throughputUpdateStart
in interface StepManager
public void throughputUpdateEnd()
throughputUpdateEnd
in interface StepManager
public void throughputFinished(Data... data) throws WekaException
throughputFinished
in interface StepManager
data
- one or more Data events (with appropriate connection type set)
to pass on to downstream connected steps. These are used to carry
any final data and to inform the downstream step(s) that the
stream has endedWekaException
- if a problem occurspublic void disconnectStepWithConnection(Step toDisconnect, java.lang.String connType)
toDisconnect
- the step to disconnectconnType
- the connection type to disconnectpublic void disconnectStep(Step toDisconnect)
toDisconnect
- the step to disconnectpublic void clearAllConnections()
public void addIncomingConnection(java.lang.String connectionName, StepManagerImpl step)
connectionName
- the name of the type of connection to addstep
- the source step component that is connecting with given
connection typepublic void removeIncomingConnection(java.lang.String connectionName, StepManagerImpl step)
connectionName
- the name of the type of connection to removestep
- the source step component associated with the given connection
typepublic boolean addOutgoingConnection(java.lang.String connectionName, StepManagerImpl step)
connectionName
- the name of the type of connection to addstep
- the target step component that is receiving the given
connection type it can't accept the connection at the present timepublic boolean addOutgoingConnection(java.lang.String connectionName, StepManagerImpl step, boolean force)
connectionName
- the name of the type of connection to addstep
- the target step component that is receiving the given
connection typeforce
- whether to force the connection, even if the target step says
it can't accept the connection at the present timepublic void removeOutgoingConnection(java.lang.String connectionName, StepManagerImpl step)
connectionName
- the name of the type of connection to removestep
- the target step component associated with the given connection
typepublic java.util.List<StepManager> getIncomingConnectedStepsOfConnectionType(java.lang.String connectionName)
getIncomingConnectedStepsOfConnectionType
in interface StepManager
connectionName
- the type of connection being received by this steppublic java.util.List<StepManager> getOutgoingConnectedStepsOfConnectionType(java.lang.String connectionName)
StepManager
getOutgoingConnectedStepsOfConnectionType
in interface StepManager
connectionName
- the name of the outgoing connectionpublic StepManager getIncomingConnectedStepWithName(java.lang.String stepName)
getIncomingConnectedStepWithName
in interface StepManager
stepName
- the name of the step to look forpublic StepManager getOutgoingConnectedStepWithName(java.lang.String stepName)
getOutgoingConnectedStepWithName
in interface StepManager
stepName
- the name of the step to look forpublic java.util.Map<java.lang.String,java.util.List<StepManager>> getOutgoingConnections()
getOutgoingConnections
in interface StepManager
public java.util.Map<java.lang.String,java.util.List<StepManager>> getIncomingConnections()
getIncomingConnections
in interface StepManager
public void addStepOutputListener(StepOutputListener listener, java.lang.String outputConnectionName)
listener
- the output listener to registeroutputConnectionName
- the name of the connection typepublic void removeStepOutputListener(StepOutputListener listener, java.lang.String outputConnectionName)
listener
- the output listener to de-registeroutputConnectionName
- the name of the connection type the listener is
registered againstpublic void clearAllStepOutputListeners()
public void clearStepOutputListeners(java.lang.String outputConnectionName)
outputConnectionName
- type of the connection to clear the listeners
forpublic void outputData(java.lang.String outgoingConnectionName, Data data) throws WekaException
outputData
in interface StepManager
outgoingConnectionName
- the type of the outgoing connection to send
data todata
- a single Data object to sendWekaException
public void outputData(Data... data) throws WekaException
StepOutputListeners
. Note that the downstream
step(s)' processIncoming() method is called in a separate thread for batch
connections. Furthermore, if multiple Data objects are supplied via the
varargs argument, and a target step will receive more than one of the Data
objects, then they will be passed on to the step in question sequentially
within the same thread of execution.outputData
in interface StepManager
data
- one or more Data objects to be sentWekaException
- if a problem occurspublic void outputData(java.lang.String outgoingConnectionName, java.lang.String stepName, Data data) throws WekaException
outputData
in interface StepManager
outgoingConnectionName
- the name of the outgoing connectionstepName
- the name of the step to send the data todata
- the data to sendWekaException
public java.util.List<java.lang.String> getStepOutgoingConnectionTypes()
public int numIncomingConnections()
numIncomingConnections
in interface StepManager
public int numIncomingConnectionsOfType(java.lang.String connectionName)
numIncomingConnectionsOfType
in interface StepManager
connectionName
- the name of the connection typepublic int numOutgoingConnections()
numOutgoingConnections
in interface StepManager
public int numOutgoingConnectionsOfType(java.lang.String connectionName)
numOutgoingConnectionsOfType
in interface StepManager
connectionName
- the name of the connection typepublic Instances getIncomingStructureForConnectionType(java.lang.String connectionName) throws WekaException
getIncomingStructureForConnectionType
in interface StepManager
connectionName
- the name of the incoming connection to get the
structure forWekaException
- if a problem occurspublic Instances getIncomingStructureForConnectionType(java.lang.String connectionName, Environment env) throws WekaException
getIncomingStructureForConnectionType
in interface StepManager
connectionName
- the type of the incoming connection to get the
structure forenv
- the Environment to useWekaException
- if a problem occurspublic Instances getIncomingStructureFromStep(StepManager sourceStep, java.lang.String connectionName) throws WekaException
getIncomingStructureFromStep
in interface StepManager
sourceStep
- the step manager managing the source stepconnectionName
- the name of the connection to attempt to get the
structure forWekaException
- if a problem occurspublic void logLow(java.lang.String message)
logLow
in interface StepManager
message
- the message to logpublic void logBasic(java.lang.String message)
logBasic
in interface StepManager
message
- the message to logpublic void logDetailed(java.lang.String message)
logDetailed
in interface StepManager
message
- the message to logpublic void logDebug(java.lang.String message)
logDebug
in interface StepManager
message
- the message to logpublic void logWarning(java.lang.String message)
logWarning
in interface StepManager
message
- the message to logpublic void logError(java.lang.String message, java.lang.Throwable cause)
logError
in interface StepManager
message
- the message to logcause
- the optional Throwable to logpublic void statusMessage(java.lang.String message)
statusMessage
in interface StepManager
message
- the message to outputpublic void log(java.lang.String message, LoggingLevel level)
log
in interface StepManager
message
- the message to writelevel
- the level for the messagepublic java.lang.String environmentSubstitute(java.lang.String source)
environmentSubstitute
in interface StepManager
source
- the source string to substitute inpublic Step getInfoStep(java.lang.Class stepClass) throws WekaException
getInfoStep
in interface StepManager
stepClass
- the expected class of the stepWekaException
- if there are no outgoing CON_INFO connections or the
managed step is the wrong typepublic Step getInfoStep() throws WekaException
getInfoStep
in interface StepManager
WekaException
- if there are no outgoing CON_INFO connectionspublic StepManager findStepInFlow(java.lang.String stepNameToFind)
findStepInFlow
in interface StepManager
stepNameToFind
- the name of the step to findpublic java.lang.String stepStatusMessagePrefix()