org.knime.core.node.workflow
Class SingleNodeContainer

java.lang.Object
  extended by org.knime.core.node.workflow.NodeContainer
      extended by org.knime.core.node.workflow.SingleNodeContainer
All Implemented Interfaces:
EventListener, NodeProgressListener

public final class SingleNodeContainer
extends NodeContainer

Holds a node in addition to some status information.

Author:
M. Berthold/B. Wiswedel, University of Konstanz

Nested Class Summary
static class SingleNodeContainer.MemoryPolicy
          Available policy how to handle output data.
static class SingleNodeContainer.SingleNodeContainerSettings
          Handles the settings specific to a SingleNodeContainer.
 
Nested classes/interfaces inherited from class org.knime.core.node.workflow.NodeContainer
NodeContainer.NodeContainerSettings, NodeContainer.State
 
Field Summary
(package private) static String CFG_MEMORY_POLICY
          Config key: What memory policy to use for a node outport.
 
Fields inherited from class org.knime.core.node.workflow.NodeContainer
m_nodeMutex
 
Constructor Summary
SingleNodeContainer(WorkflowManager parent, NodeID id, SingleNodeContainerPersistor persistor)
          Create new SingleNodeContainer from persistor.
SingleNodeContainer(WorkflowManager parent, Node n, NodeID id)
          Create new SingleNodeContainer based on existing Node.
 
Method Summary
 boolean areDialogAndNodeSettingsEqual()
          
(package private)  boolean areSettingsValid(NodeSettingsRO settings)
          
(package private)  void cancelExecution()
          Cancel execution of a marked, queued, or executing node.
(package private)  void cleanup()
          Method that's called when the node is discarded.
(package private)  boolean configure(PortObjectSpec[] inObjectSpecs)
          Configure underlying node and update state accordingly.
 ExecutionContext createExecutionContext()
           
 SingleNodeContainerExecutionResult createExecutionResult(ExecutionMonitor exec)
          Saves all internals that are necessary to mimic the computed result into a new execution result object.
(package private)  void enableReQueuing()
          Queue underlying node for re-execution (= update state accordingly).
protected  NodeContainerPersistor getCopyPersistor(HashMap<Integer,ContainerTable> tableRep, boolean preserveDeletableFlags)
          Get a new persistor that is used to copy this node (copy&paste action).
(package private)  NodeDialogPane getDialogPane()
          
(package private)  NodeDialogPane getDialogPaneWithSettings(PortObjectSpec[] inSpecs)
          
(package private)  FlowObjectStack getFlowObjectStack()
           
 URL getIcon()
          
 NodeInPort getInPort(int index)
          Return a port, which for the inputs really only holds the type and some other static information.
 BufferedDataTable[] getInternalHeldTables()
          Get the tables that are kept by the underlying node.
(package private)  Node.LoopRole getLoopRole()
           
 String getName()
          
(package private)  Node getNode()
          Get the underlying node.
 Node getNodeReferenceBug2136()
          Deprecated. Method will be reduced to package scope in future version, currently public to enable workaround for bug #2136 (see also bug #2137)
 AbstractNodeView<NodeModel> getNodeView(int i)
          Return the view with the specified index provided by the node.
 String getNodeViewName(int i)
          
 int getNrInPorts()
          
 int getNrNodeViews()
          Returns the number of views provided by the node implementation.
 int getNrOutPorts()
          
(package private)  SingleNodeContainer.MemoryPolicy getOutDataMemoryPolicy()
          Get the policy for the data outports, that is, keep the output in main memory or write it to disc.
 NodeOutPort getOutPort(int index)
          Returns the output port for the given portID.
(package private)  SingleNodeContainer.SingleNodeContainerSettings getSingleNodeContainerSettings()
           
 NodeFactory.NodeType getType()
          
 Element getXMLDescription()
           
 boolean hasDialog()
          
protected  boolean isLocalWFM()
          Is this node a to be locally executed workflow.
(package private)  boolean isResetable()
          check if node can be safely reset.
(package private)  NodeID[] loadContent(NodeContainerPersistor nodePersistor, Map<Integer,BufferedDataTable> tblRep, FlowObjectStack inStack, ExecutionMonitor exec, WorkflowPersistor.LoadResult loadResult, boolean preserveNodeMessage)
          Restore content from persistor.
 void loadExecutionResult(NodeContainerExecutionResult execResult, ExecutionMonitor exec, WorkflowPersistor.LoadResult loadResult)
          Load information from execution result.
(package private)  void loadSettings(NodeSettingsRO settings)
          
(package private)  void loadSNCSettings(NodeSettingsRO settings)
          Loads the SingleNodeContainer settings from the argument.
(package private)  void markForExecution(boolean flag)
          Enable (or disable) queuing of underlying node for execution.
(package private)  void mimicRemoteExecuted(NodeContainerExecutionStatus status)
          Put this node into either the NodeContainer.State.EXECUTED or NodeContainer.State.IDLE state depending on the argument.
(package private)  void mimicRemoteExecuting()
          Marks this node as remotely executing.
(package private)  void mimicRemotePostExecute()
          Puts this node (and all its children) into the NodeContainer.State.POSTEXECUTE state.
(package private)  void mimicRemotePreExecute()
          Puts this node (and all its children) into the NodeContainer.State.PREEXECUTE state.
 NodeContainerExecutionStatus performExecuteNode(PortObject[] inObjects)
          Execute underlying Node asynchronously.
(package private)  void performShutdown()
          Called when the workflow is to be disposed.
(package private)  void performStateTransitionEXECUTED(NodeContainerExecutionStatus status)
          This should be used to change the nodes states correctly (and likely needs to be synchronized with other changes visible to successors of this node as well!) AFTER the actual execution.
(package private)  void performStateTransitionEXECUTING()
          This should be used to change the nodes states correctly (and likely needs to be synchronized with other changes visible to successors of this node as well!) BEFORE the actual execution.
(package private)  void performStateTransitionPOSTEXECUTE()
          Called when the state of a node should switch from NodeContainer.State.EXECUTING (or NodeContainer.State.EXECUTINGREMOTELY) to NodeContainer.State.POSTEXECUTE.
(package private)  boolean performStateTransitionPREEXECUTE()
          Called when the state of a node should switch from NodeContainer.State.QUEUED to NodeContainer.State.PREEXECUTE.
(package private)  void reset()
          Reset underlying node and update state accordingly.
(package private)  void saveSettings(NodeSettingsWO settings)
          
(package private)  void saveSNCSettings(NodeSettingsWO settings)
          Saves the SingleNodeContainer settings such as the job executor to the argument node settings object.
 void setDirty()
          Overridden to also ensure that outport tables are "open" (node directory is deleted upon save() - so the tables are better copied into temp).
(package private)  void setFlowObjectStack(FlowObjectStack st)
          Set FlowObjectStack.
(package private)  void setInHiLiteHandler(int index, HiLiteHandler hdl)
          Set a new HiLiteHandler for an incoming connection.
(package private)  void setJobManager(NodeExecutionJobManager je)
          Set a new NodeExecutionJobManager for this node.
 
Methods inherited from class org.knime.core.node.workflow.NodeContainer
addJobManagerChangedListener, addNodeMessageListener, addNodeStateChangeListener, addProgressListener, addUIInformationListener, addWaitingLoop, applySettingsFromDialog, areDialogSettingsValid, clearWaitingLoopList, closeAllJobManagerViews, continueExecutionOnLoad, findJobManager, getCustomDescription, getCustomName, getDialogPaneWithSettings, getDisplayLabel, getExecutionJob, getID, getJobManager, getNameWithID, getNodeContainerDirectory, getNodeMessage, getNrViews, getParent, getProgressMonitor, getSplitType, getState, getUIInformation, getView, getViewName, getWaitingLoops, isDeletable, isDirty, notifyJobManagerChangedListener, notifyMessageListeners, notifyParentExecuteFinished, notifyParentExecuteStart, notifyParentPostExecuteStart, notifyParentPreExecuteStart, notifyProgressListeners, notifyStateChangeListeners, notifyUIListeners, openDialogInJFrame, progressChanged, queue, removeJobManagerChangedListener, removeNodeMessageListener, removeNodeProgressListener, removeNodeStateChangeListener, removeUIInformationListener, removeWaitingLoopHeadNode, resetJobManagerViews, saveExecutionResult, saveNodeExecutionJobReconnectInfo, setCustomDescription, setCustomName, setExecutionJob, setNodeContainerDirectory, setNodeMessage, setState, setState, setUIInformation, throwIllegalStateException, toString, unsetDirty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CFG_MEMORY_POLICY

static final String CFG_MEMORY_POLICY
Config key: What memory policy to use for a node outport.

See Also:
Constant Field Values
Constructor Detail

SingleNodeContainer

SingleNodeContainer(WorkflowManager parent,
                    Node n,
                    NodeID id)
Create new SingleNodeContainer based on existing Node.

Parameters:
parent - the workflow manager holding this node
n - the underlying node
id - the unique identifier

SingleNodeContainer

SingleNodeContainer(WorkflowManager parent,
                    NodeID id,
                    SingleNodeContainerPersistor persistor)
Create new SingleNodeContainer from persistor.

Parameters:
parent - the workflow manager holding this node
id - the identifier
persistor - to read from
Method Detail

getNode

Node getNode()
Get the underlying node.

Returns:
the underlying Node

getNodeReferenceBug2136

@Deprecated
public Node getNodeReferenceBug2136()
Deprecated. Method will be reduced to package scope in future version, currently public to enable workaround for bug #2136 (see also bug #2137)

Returns:
reference to underlying node.

getNrOutPorts

public int getNrOutPorts()

Specified by:
getNrOutPorts in class NodeContainer

getNrInPorts

public int getNrInPorts()

Specified by:
getNrInPorts in class NodeContainer

getOutPort

public NodeOutPort getOutPort(int index)
Returns the output port for the given portID. This port is essentially a container for the underlying Node and the index and will retrieve all interesting data from the Node.

Specified by:
getOutPort in class NodeContainer
Parameters:
index - The output port's ID.
Returns:
Output port with the specified ID.
Throws:
IndexOutOfBoundsException - If the index is out of range.

getInPort

public NodeInPort getInPort(int index)
Return a port, which for the inputs really only holds the type and some other static information.

Specified by:
getInPort in class NodeContainer
Parameters:
index - the index of the input port
Returns:
port

getOutDataMemoryPolicy

final SingleNodeContainer.MemoryPolicy getOutDataMemoryPolicy()
Get the policy for the data outports, that is, keep the output in main memory or write it to disc. This method is used from within the ExecutionContext when the derived NodeModel is executing.

Returns:
The memory policy to use.

setInHiLiteHandler

void setInHiLiteHandler(int index,
                        HiLiteHandler hdl)
Set a new HiLiteHandler for an incoming connection.

Parameters:
index - index of port
hdl - new HiLiteHandler

getNodeView

public AbstractNodeView<NodeModel> getNodeView(int i)
Return the view with the specified index provided by the node.

Specified by:
getNodeView in class NodeContainer
Parameters:
i - the view to create
Returns:
a new view instance with index i provided by the node

getNodeViewName

public String getNodeViewName(int i)

Specified by:
getNodeViewName in class NodeContainer

getNrNodeViews

public int getNrNodeViews()
Returns the number of views provided by the node implementation.

Specified by:
getNrNodeViews in class NodeContainer
Returns:
the number of views provided by the node implementation

cleanup

void cleanup()
Method that's called when the node is discarded. The single node container overwrites this method and cleans the outport data of the node (deletes temp files).

Overrides:
cleanup in class NodeContainer

setJobManager

void setJobManager(NodeExecutionJobManager je)
Set a new NodeExecutionJobManager for this node. This also includes all child nodes unless they have their own dedicated job manager.

Overrides:
setJobManager in class NodeContainer
Parameters:
je - the new job manager.

createExecutionContext

public ExecutionContext createExecutionContext()

configure

boolean configure(PortObjectSpec[] inObjectSpecs)
Configure underlying node and update state accordingly.

Parameters:
inObjectSpecs - input table specifications
Returns:
true if output specs have changed.
Throws:
IllegalStateException - in case of illegal entry state.

isResetable

boolean isResetable()
check if node can be safely reset.

Specified by:
isResetable in class NodeContainer
Returns:
if node can be reset.

reset

void reset()
Reset underlying node and update state accordingly.

Throws:
IllegalStateException - in case of illegal entry state.

markForExecution

void markForExecution(boolean flag)
Enable (or disable) queuing of underlying node for execution. This really only changes the state of the node and once all pre-conditions for execution are fulfilled (e.g. configuration succeeded and all ingoing objects are available) the node will be actually queued.

Specified by:
markForExecution in class NodeContainer
Parameters:
flag - determines if node is marked or unmarked for execution
Throws:
IllegalStateException - in case of illegal entry state.

enableReQueuing

void enableReQueuing()
Queue underlying node for re-execution (= update state accordingly).

Throws:
IllegalStateException - in case of illegal entry state.

cancelExecution

void cancelExecution()
Cancel execution of a marked, queued, or executing node. (Tolerate execute as this may happen throughout cancelation).

Specified by:
cancelExecution in class NodeContainer

performShutdown

void performShutdown()
Called when the workflow is to be disposed. It will cancel this node if it is still running. If this node is being executed remotely (cluster execution) and has been saved, it will just disconnect it.

Specified by:
performShutdown in class NodeContainer

mimicRemotePreExecute

void mimicRemotePreExecute()
Puts this node (and all its children) into the NodeContainer.State.PREEXECUTE state. This method is used when a workflow is executed remotely.

Specified by:
mimicRemotePreExecute in class NodeContainer

mimicRemoteExecuting

void mimicRemoteExecuting()
Marks this node as remotely executing. This is necessary if the entire (sub-) flow that this node is part of is executed remotely.

Specified by:
mimicRemoteExecuting in class NodeContainer

mimicRemotePostExecute

void mimicRemotePostExecute()
Puts this node (and all its children) into the NodeContainer.State.POSTEXECUTE state. This method is used when a workflow is executed remotely.

Specified by:
mimicRemotePostExecute in class NodeContainer

mimicRemoteExecuted

void mimicRemoteExecuted(NodeContainerExecutionStatus status)
Put this node into either the NodeContainer.State.EXECUTED or NodeContainer.State.IDLE state depending on the argument. This method is applied recursively on all of this node's children (if a meta node).

Specified by:
mimicRemoteExecuted in class NodeContainer
Parameters:
status - Where to get the success flag from.

performStateTransitionPREEXECUTE

boolean performStateTransitionPREEXECUTE()
Called when the state of a node should switch from NodeContainer.State.QUEUED to NodeContainer.State.PREEXECUTE. The method is to be called from the node's parent in a synchronized environment.

Specified by:
performStateTransitionPREEXECUTE in class NodeContainer
Returns:
whether there was an actual state transition, false if the execution was canceled (cancel checking to be done in synchronized block)

performStateTransitionEXECUTING

void performStateTransitionEXECUTING()
This should be used to change the nodes states correctly (and likely needs to be synchronized with other changes visible to successors of this node as well!) BEFORE the actual execution. The main reason is that the actual execution should be performed unsynchronized!

Specified by:
performStateTransitionEXECUTING in class NodeContainer

performStateTransitionPOSTEXECUTE

void performStateTransitionPOSTEXECUTE()
Called when the state of a node should switch from NodeContainer.State.EXECUTING (or NodeContainer.State.EXECUTINGREMOTELY) to NodeContainer.State.POSTEXECUTE. The method is to be called from the node's parent in a synchronized environment.

Specified by:
performStateTransitionPOSTEXECUTE in class NodeContainer

performStateTransitionEXECUTED

void performStateTransitionEXECUTED(NodeContainerExecutionStatus status)
This should be used to change the nodes states correctly (and likely needs to be synchronized with other changes visible to successors of this node as well!) AFTER the actual execution. The main reason is that the actual execution should be performed unsynchronized!

Specified by:
performStateTransitionEXECUTED in class NodeContainer
Parameters:
status - indicates if execution was successful

performExecuteNode

public NodeContainerExecutionStatus performExecuteNode(PortObject[] inObjects)
Execute underlying Node asynchronously. Make sure to give Workflow- Manager a chance to call pre- and postExecuteNode() appropriately and synchronize those parts (since they changes states!).

Parameters:
inObjects - input data
Returns:
whether execution was successful.
Throws:
IllegalStateException - in case of illegal entry state.

loadSettings

void loadSettings(NodeSettingsRO settings)
            throws InvalidSettingsException

Overrides:
loadSettings in class NodeContainer
Throws:
InvalidSettingsException

loadContent

NodeID[] loadContent(NodeContainerPersistor nodePersistor,
                     Map<Integer,BufferedDataTable> tblRep,
                     FlowObjectStack inStack,
                     ExecutionMonitor exec,
                     WorkflowPersistor.LoadResult loadResult,
                     boolean preserveNodeMessage)
               throws CanceledExecutionException
Restore content from persistor. This represents the second step when loading a workflow.

Specified by:
loadContent in class NodeContainer
Parameters:
nodePersistor - To load from.
tblRep - A table repository to restore BufferedDatTables
inStack - Incoming FlowObjectStack.
exec - For progress
loadResult - Where to report errors/warnings to
preserveNodeMessage - Whether possible node messages in the persistor are to be preserved (parameter to configure method that is called during load).
Returns:
The list of nodes that were inserted, for single node containers the result is an empty array.
Throws:
CanceledExecutionException - If canceled.

loadExecutionResult

public void loadExecutionResult(NodeContainerExecutionResult execResult,
                                ExecutionMonitor exec,
                                WorkflowPersistor.LoadResult loadResult)
Load information from execution result. Subclasses will override this method and will call this implementation as super.loadEx....

Overrides:
loadExecutionResult in class NodeContainer
Parameters:
execResult - The execution result (contains port objects, messages, etc)
exec - For progress information (no cancelation supported)
loadResult - A load result that contains, e.g. error messages.

createExecutionResult

public SingleNodeContainerExecutionResult createExecutionResult(ExecutionMonitor exec)
                                                         throws CanceledExecutionException
Saves all internals that are necessary to mimic the computed result into a new execution result object. This method is called on node instances, which are, e.g. executed on a server and later on read back into a true KNIME instance (upon which #loadExecutionResult(NodeContainerExecutionResult, ExecutionMonitor, LoadResult) is called).

Specified by:
createExecutionResult in class NodeContainer
Parameters:
exec - For progress information (this method will copy port objects).
Returns:
A new execution result instance.
Throws:
CanceledExecutionException - If canceled.

saveSettings

void saveSettings(NodeSettingsWO settings)

Overrides:
saveSettings in class NodeContainer

saveSNCSettings

void saveSNCSettings(NodeSettingsWO settings)
Saves the SingleNodeContainer settings such as the job executor to the argument node settings object.

Parameters:
settings - To save to.
See Also:
loadSNCSettings(NodeSettingsRO)

loadSNCSettings

void loadSNCSettings(NodeSettingsRO settings)
               throws InvalidSettingsException
Loads the SingleNodeContainer settings from the argument. This is the reverse operation to saveSNCSettings(NodeSettingsWO).

Parameters:
settings - To load from.
Throws:
InvalidSettingsException - If settings are invalid.

getSingleNodeContainerSettings

SingleNodeContainer.SingleNodeContainerSettings getSingleNodeContainerSettings()
Returns:
reference to internally used settings (contains information for memory policy, e.g.)

areSettingsValid

boolean areSettingsValid(NodeSettingsRO settings)

Overrides:
areSettingsValid in class NodeContainer

setFlowObjectStack

void setFlowObjectStack(FlowObjectStack st)
Set FlowObjectStack.

Parameters:
st - new stack

getFlowObjectStack

FlowObjectStack getFlowObjectStack()
Returns:
current FlowObjectStack

getLoopRole

Node.LoopRole getLoopRole()
Returns:
role of node within a loop

getName

public String getName()

Specified by:
getName in class NodeContainer

hasDialog

public boolean hasDialog()

Specified by:
hasDialog in class NodeContainer

getDialogPaneWithSettings

NodeDialogPane getDialogPaneWithSettings(PortObjectSpec[] inSpecs)
                                   throws NotConfigurableException

Specified by:
getDialogPaneWithSettings in class NodeContainer
Throws:
NotConfigurableException

getDialogPane

NodeDialogPane getDialogPane()

Specified by:
getDialogPane in class NodeContainer

areDialogAndNodeSettingsEqual

public boolean areDialogAndNodeSettingsEqual()

Specified by:
areDialogAndNodeSettingsEqual in class NodeContainer

getInternalHeldTables

public BufferedDataTable[] getInternalHeldTables()
Get the tables that are kept by the underlying node. The return value is null if (a) the underlying node is not a BufferedDataTableHolder or (b) the node is not executed.

Returns:
The internally held tables.
See Also:
BufferedDataTableHolder, Node.getInternalHeldTables()

getType

public NodeFactory.NodeType getType()

Specified by:
getType in class NodeContainer

getIcon

public URL getIcon()

Specified by:
getIcon in class NodeContainer

getXMLDescription

public Element getXMLDescription()
Returns:
the XML description of the node for the NodeDescription view

isLocalWFM

protected boolean isLocalWFM()
Is this node a to be locally executed workflow. In contrast to remotely executed workflows, the nodes in the encapsulated workflow will be executed independently (each represented by an own job), whereas remote execution means that the entire workflow execution is one single job.

This method returns false for all single node container.

Specified by:
isLocalWFM in class NodeContainer
Returns:
The above described property.

setDirty

public void setDirty()
Overridden to also ensure that outport tables are "open" (node directory is deleted upon save() - so the tables are better copied into temp). Mark this node container to be changed, that is, it needs to be saved.

Overrides:
setDirty in class NodeContainer

getCopyPersistor

protected NodeContainerPersistor getCopyPersistor(HashMap<Integer,ContainerTable> tableRep,
                                                  boolean preserveDeletableFlags)
Get a new persistor that is used to copy this node (copy&paste action).

Specified by:
getCopyPersistor in class NodeContainer
Parameters:
tableRep - Table repository of the destination.
preserveDeletableFlags - Whether the "isdeleteable" annotation should be copied also (false when individual nodes are copied but true when an entire meta node is copied).
Returns:
A new persistor for copying.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.