use of org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED in project knime-core by knime.
the class WorkflowManager method doBeforeExecution.
/**
* Call-back from NodeContainer called before node is actually executed. The argument node is in usually a
* {@link SingleNodeContainer}, although it can also be a metanode (i.e. a <code>WorkflowManager</code>), which is
* executed remotely (execution takes place as a single operation).
*
* @param nc node whose execution is about to start
* @throws IllegalFlowObjectStackException If loop end nodes have problems identifying their start node
*/
void doBeforeExecution(final NodeContainer nc) {
assert !nc.getID().equals(this.getID());
assert !nc.isLocalWFM() : "No execution of local metanodes";
try (WorkflowLock lock = lock()) {
// allow NNC to update states etc
LOGGER.debug(nc.getNameWithID() + " doBeforeExecution");
nc.getNodeTimer().startExec();
if (nc instanceof SingleNodeContainer) {
FlowObjectStack flowObjectStack = nc.getFlowObjectStack();
FlowLoopContext slc = flowObjectStack.peek(FlowLoopContext.class);
// if the node is in a subnode the subnode may be part of restored loop, see AP-7585
FlowLoopContext subnodeOuterFlowLoopContext = flowObjectStack.peekOptional(FlowSubnodeScopeContext.class).map(s -> s.getOuterFlowLoopContext()).orElse(null);
if (slc instanceof RestoredFlowLoopContext || subnodeOuterFlowLoopContext instanceof RestoredFlowLoopContext) {
throw new IllegalFlowObjectStackException("Can't continue loop as the workflow was restored with the loop being partially " + "executed. Reset loop start and execute entire loop again.");
}
if (nc instanceof NativeNodeContainer) {
NativeNodeContainer nnc = (NativeNodeContainer) nc;
if (nnc.isModelCompatibleTo(LoopEndNode.class)) {
// if this is an END to a loop, make sure it knows its head
if (slc == null) {
LOGGER.debug("Incoming flow object stack for " + nnc.getNameWithID() + ":\n" + flowObjectStack.toDeepString());
throw new IllegalFlowObjectStackException("Encountered loop-end without corresponding head!");
}
NodeContainer headNode = m_workflow.getNode(slc.getOwner());
if (headNode == null) {
throw new IllegalFlowObjectStackException("Loop start and end nodes are not in the" + " same workflow");
}
assert ((NativeNodeContainer) headNode).getNode().getNodeModel().equals(nnc.getNode().getLoopStartNode());
} else if (nnc.isModelCompatibleTo(LoopStartNode.class)) {
nnc.getNode().getOutgoingFlowObjectStack().push(new InnerFlowLoopContext());
// nnc.getNode().getFlowObjectStack().push(new InnerFlowLoopContext());
} else {
// or not if it's any other type of node
nnc.getNode().setLoopStartNode(null);
}
}
}
nc.performStateTransitionEXECUTING();
lock.queueCheckForNodeStateChangeNotification(true);
}
}
Aggregations