Search in sources :

Example 1 with Type

use of org.knime.core.node.workflow.NodeMessage.Type 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();
            FlowScopeContext fsc = flowObjectStack.peek(FlowScopeContext.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.getOuterFlowScopeContext(FlowLoopContext.class)).orElse(null);
            if (fsc 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(ScopeEndNode.class)) {
                    // if this is an END to a loop/scope, make sure it knows its head
                    if (fsc == null) {
                        LOGGER.debug("Incoming flow object stack for " + nnc.getNameWithID() + ":\n" + flowObjectStack.toDeepString());
                        if (nnc.isModelCompatibleTo(LoopEndNode.class)) {
                            throw new IllegalFlowObjectStackException("Encountered loop-end without corresponding head!");
                        } else {
                            throw new IllegalFlowObjectStackException("Encountered scope-end without corresponding head!");
                        }
                    }
                    NodeContainer headNode = m_workflow.getNode(fsc.getOwner());
                    if (headNode == null) {
                        if (nnc.isModelCompatibleTo(LoopEndNode.class)) {
                            throw new IllegalFlowObjectStackException("Loop start and end nodes are not in the" + " same workflow");
                        } else {
                            throw new IllegalFlowObjectStackException("Scope start and end nodes are not in the" + " same workflow");
                        }
                    } else if (headNode instanceof NativeNodeContainer && ((NativeNodeContainer) headNode).isModelCompatibleTo(ScopeStartNode.class)) {
                        // check that the start and end nodes have compatible flow scope contexts
                        Class<? extends FlowScopeContext> endNodeFlowScopeContext = ((ScopeEndNode<?>) nnc.getNodeModel()).getFlowScopeContextClass();
                        if (!endNodeFlowScopeContext.isAssignableFrom(fsc.getClass())) {
                            if (nnc.isModelCompatibleTo(LoopEndNode.class)) {
                                throw new IllegalFlowObjectStackException("Encountered loop-end without compatible head!");
                            } else {
                                throw new IllegalFlowObjectStackException("Encountered scope-end without compatible head!");
                            }
                        }
                    }
                    assert ((NativeNodeContainer) headNode).getNode().getNodeModel().equals(nnc.getNode().getScopeStartNode(ScopeStartNode.class).orElse(null));
                } else if (nnc.isModelCompatibleTo(LoopStartNode.class)) {
                    pushFlowContextForLoopIteration(nnc);
                } else {
                    // or not if it's any other type of node
                    nnc.getNode().setScopeStartNode(null);
                }
            }
        }
        nc.performStateTransitionEXECUTING();
        lock.queueCheckForNodeStateChangeNotification(true);
    }
}
Also used : WorkflowSegment(org.knime.core.node.workflow.capture.WorkflowSegment) Arrays(java.util.Arrays) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) EXECUTING(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTING) ReferencedFile(org.knime.core.internal.ReferencedFile) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) InteractiveNode(org.knime.core.node.interactive.InteractiveNode) CoreException(org.eclipse.core.runtime.CoreException) StringUtils(org.apache.commons.lang3.StringUtils) AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) NodeView(org.knime.core.node.NodeView) NodeContainerExecutionStatus(org.knime.core.node.workflow.execresult.NodeContainerExecutionStatus) Node(org.knime.core.node.Node) Vector(java.util.Vector) Matcher(java.util.regex.Matcher) Map(java.util.Map) ModifiableNodeCreationConfiguration(org.knime.core.node.context.ModifiableNodeCreationConfiguration) LockFailedException(org.knime.core.util.LockFailedException) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) EXECUTINGREMOTELY(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTINGREMOTELY) Set(java.util.Set) ResolverUtil(org.knime.core.util.pathresolve.ResolverUtil) Executors(java.util.concurrent.Executors) POSTEXECUTE(org.knime.core.node.workflow.InternalNodeContainerState.POSTEXECUTE) InputNode(org.knime.core.node.dialog.InputNode) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Stream(java.util.stream.Stream) CONFIGURED(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ThreadNodeExecutionJobManager(org.knime.core.node.exec.ThreadNodeExecutionJobManager) JsonException(javax.json.JsonException) CollapseIntoMetaNodeResult(org.knime.core.node.workflow.action.CollapseIntoMetaNodeResult) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) VirtualParallelizedChunkPortObjectInNodeModel(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeModel) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) VMFileLocker(org.knime.core.util.VMFileLocker) RestoredFlowLoopContext(org.knime.core.node.workflow.FlowLoopContext.RestoredFlowLoopContext) SplitType(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings.SplitType) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) EXECUTED_QUEUED(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED_QUEUED) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) NotConfigurableException(org.knime.core.node.NotConfigurableException) UpdateStatus(org.knime.core.node.workflow.MetaNodeTemplateInformation.UpdateStatus) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult) DialogNode(org.knime.core.node.dialog.DialogNode) LinkedHashSet(java.util.LinkedHashSet) IntFunction(java.util.function.IntFunction) VirtualParallelizedChunkNodeInput(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkNodeInput) KNIMEConstants(org.knime.core.node.KNIMEConstants) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode) Executor(java.util.concurrent.Executor) PREEXECUTE(org.knime.core.node.workflow.InternalNodeContainerState.PREEXECUTE) InteractiveView(org.knime.core.node.interactive.InteractiveView) AuthorInformation(org.knime.core.util.workflowalizer.AuthorInformation) FileOutputStream(java.io.FileOutputStream) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) DialogNodeValue(org.knime.core.node.dialog.DialogNodeValue) File(java.io.File) ViewContent(org.knime.core.node.interactive.ViewContent) UNCONFIGURED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.UNCONFIGURED_MARKEDFOREXEC) OutputNode(org.knime.core.node.dialog.OutputNode) Platform(org.eclipse.core.runtime.Platform) LoopStatus(org.knime.core.node.workflow.NativeNodeContainer.LoopStatus) FileUtil(org.knime.core.util.FileUtil) CONFIGURED_QUEUED(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED_QUEUED) FlowVirtualScopeContext(org.knime.core.node.workflow.virtual.parchunk.FlowVirtualScopeContext) NodeType(org.knime.core.node.NodeFactory.NodeType) ExpandSubnodeResult(org.knime.core.node.workflow.action.ExpandSubnodeResult) NodeCreationConfiguration(org.knime.core.node.context.NodeCreationConfiguration) ListIterator(java.util.ListIterator) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) URL(java.net.URL) WorkflowLoadResult(org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult) ReexecutionCallback(org.knime.core.node.interactive.ReexecutionCallback) MetaNodeLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.MetaNodeLinkUpdateResult) FileFilterUtils(org.apache.commons.io.filefilter.FileFilterUtils) NodeDialogPane(org.knime.core.node.NodeDialogPane) JsonValue(javax.json.JsonValue) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) ReplaceNodeResult(org.knime.core.node.workflow.action.ReplaceNodeResult) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) AbstractNodeView(org.knime.core.node.AbstractNodeView) ConvenienceMethods(org.knime.core.node.util.ConvenienceMethods) URI(java.net.URI) ThreadFactory(java.util.concurrent.ThreadFactory) MetaNodeToSubNodeResult(org.knime.core.node.workflow.action.MetaNodeToSubNodeResult) PortType(org.knime.core.node.port.PortType) NodeAndInports(org.knime.core.node.workflow.Workflow.NodeAndInports) CONFIGURED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC) AbstractPortObjectRepositoryNodeModel(org.knime.core.node.workflow.virtual.AbstractPortObjectRepositoryNodeModel) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ReExecutable(org.knime.core.node.interactive.ReExecutable) CredentialsNode(org.knime.core.node.workflow.CredentialsStore.CredentialsNode) NodeModel(org.knime.core.node.NodeModel) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) BufferedDataTable(org.knime.core.node.BufferedDataTable) WorkflowPortTemplate(org.knime.core.node.workflow.WorkflowPersistor.WorkflowPortTemplate) LoadResultEntryType(org.knime.core.node.workflow.WorkflowPersistor.LoadResultEntry.LoadResultEntryType) NodeContainerTemplateLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.NodeContainerTemplateLinkUpdateResult) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) Entry(java.util.Map.Entry) Optional(java.util.Optional) CheckUtils(org.knime.core.node.util.CheckUtils) CheckUtils.checkState(org.knime.core.node.util.CheckUtils.checkState) PortObject(org.knime.core.node.port.PortObject) NodeContainerExecutionResult(org.knime.core.node.workflow.execresult.NodeContainerExecutionResult) IntStream(java.util.stream.IntStream) IOCase(org.apache.commons.io.IOCase) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) NodeExecutionJobManagerPool(org.knime.core.node.util.NodeExecutionJobManagerPool) SingleNodeContainerSettings(org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings) EXECUTED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED_MARKEDFOREXEC) LoadVersion(org.knime.core.util.LoadVersion) HashMap(java.util.HashMap) NodeSettings(org.knime.core.node.NodeSettings) ConnectionType(org.knime.core.node.workflow.ConnectionContainer.ConnectionType) Function(java.util.function.Function) Pair(org.knime.core.util.Pair) HashSet(java.util.HashSet) ExecutionContext(org.knime.core.node.ExecutionContext) IDLE(org.knime.core.node.workflow.InternalNodeContainerState.IDLE) ExternalNodeData(org.knime.core.node.dialog.ExternalNodeData) ConnectionContainerTemplate(org.knime.core.node.workflow.WorkflowPersistor.ConnectionContainerTemplate) NodeLogger(org.knime.core.node.NodeLogger) EXECUTED(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult) LinkedList(java.util.LinkedList) Role(org.knime.core.node.workflow.MetaNodeTemplateInformation.Role) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) SubNodeToMetaNodeResult(org.knime.core.node.workflow.action.SubNodeToMetaNodeResult) OutputStream(java.io.OutputStream) NodeFactory(org.knime.core.node.NodeFactory) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) TemplateType(org.knime.core.node.workflow.MetaNodeTemplateInformation.TemplateType) MetaPortInfo(org.knime.core.node.port.MetaPortInfo) VirtualParallelizedChunkPortObjectOutNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectOutNodeFactory) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) CheckedExceptionBiConsumer(org.knime.core.util.CheckedExceptionBiConsumer) ParallelizedChunkContent(org.knime.core.node.workflow.virtual.parchunk.ParallelizedChunkContent) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) Type(org.knime.core.node.workflow.NodeMessage.Type) TimeUnit(java.util.concurrent.TimeUnit) Condition(java.util.concurrent.locks.Condition) IEarlyStartup(org.knime.core.util.IEarlyStartup) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ParallelizedChunkContentMaster(org.knime.core.node.workflow.virtual.parchunk.ParallelizedChunkContentMaster) NodeProperty(org.knime.core.node.workflow.NodePropertyChangedEvent.NodeProperty) MetaNodeDialogType(org.knime.core.node.workflow.MetaNodeDialogPane.MetaNodeDialogType) Collections(java.util.Collections) PortObjectHolder(org.knime.core.node.port.PortObjectHolder) RestoredFlowLoopContext(org.knime.core.node.workflow.FlowLoopContext.RestoredFlowLoopContext) RestoredFlowLoopContext(org.knime.core.node.workflow.FlowLoopContext.RestoredFlowLoopContext)

Example 2 with Type

use of org.knime.core.node.workflow.NodeMessage.Type in project knime-core by knime.

the class WorkflowManager method postLoad.

private void postLoad(final Map<NodeID, NodeContainerPersistor> persistorMap, final Map<Integer, BufferedDataTable> tblRep, final boolean mustWarnOnDataLoadError, final ExecutionMonitor exec, final LoadResult loadResult, final boolean keepNodeMessage) throws CanceledExecutionException {
    // linked set because we need reverse order later on
    Collection<NodeID> failedNodes = new LinkedHashSet<NodeID>();
    boolean isStateChangePredictable = false;
    final Set<NodeID> nodeIDsInPersistorSet = persistorMap.keySet();
    // had NPE below - adding this line to get better debug information
    CheckUtils.checkArgumentNotNull(nodeIDsInPersistorSet, "NodeID list from persistor must not be null for workflow %s", getNameWithID());
    for (NodeID bfsID : m_workflow.createBreadthFirstSortedList(nodeIDsInPersistorSet, true).keySet()) {
        NodeContainer cont = getNodeContainer(bfsID);
        // initialize node container with CredentialsStore
        if (cont instanceof SingleNodeContainer) {
            SingleNodeContainer snc = (SingleNodeContainer) cont;
            snc.setCredentialsStore(m_credentialsStore);
        }
        LoadResult subResult = new LoadResult(cont.getNameWithID());
        InternalNodeContainerState contStateBeforeLoadContent = cont.getInternalState();
        NodeOutPort[] predPorts = assemblePredecessorOutPorts(bfsID);
        final int predCount = predPorts.length;
        PortObject[] portObjects = new PortObject[predCount];
        boolean inPortsContainNull = false;
        FlowObjectStack[] predStacks = new FlowObjectStack[predCount];
        for (int i = 0; i < predCount; i++) {
            NodeOutPort p = predPorts[i];
            if (cont instanceof SingleNodeContainer && p != null) {
                SingleNodeContainer snc = (SingleNodeContainer) cont;
                snc.setInHiLiteHandler(i, p.getHiLiteHandler());
            }
            if (p != null) {
                predStacks[i] = p.getFlowObjectStack();
                portObjects[i] = p.getPortObject();
                inPortsContainNull &= portObjects[i] == null;
            }
        }
        FlowObjectStack inStack;
        boolean needsReset = false;
        try {
            if (isSourceNode(bfsID)) {
                predStacks = new FlowObjectStack[] { getWorkflowVariableStack() };
            }
            inStack = new FlowObjectStack(cont.getID(), predStacks);
        } catch (IllegalFlowObjectStackException ex) {
            subResult.addError("Errors creating flow object stack for node \"" + cont.getNameWithID() + "\", (resetting flow variables): " + ex.getMessage());
            needsReset = true;
            inStack = new FlowObjectStack(cont.getID());
        }
        NodeContainerPersistor persistor = persistorMap.get(bfsID);
        InternalNodeContainerState loadState = persistor.getMetaPersistor().getState();
        exec.setMessage(cont.getNameWithID());
        exec.checkCanceled();
        // two steps below: loadNodeContainer and loadContent
        ExecutionMonitor sub1 = exec.createSubProgress(1.0 / (2 * m_workflow.getNrNodes()));
        ExecutionMonitor sub2 = exec.createSubProgress(1.0 / (2 * m_workflow.getNrNodes()));
        NodeContext.pushContext(cont);
        try {
            persistor.loadNodeContainer(tblRep, sub1, subResult);
        } catch (CanceledExecutionException e) {
            throw e;
        } catch (Exception e) {
            if (!(e instanceof InvalidSettingsException) && !(e instanceof IOException)) {
                LOGGER.error("Caught unexpected \"" + e.getClass().getSimpleName() + "\" during node loading", e);
            }
            subResult.addError("Errors loading, skipping it: " + e.getMessage());
            needsReset = true;
        } finally {
            NodeContext.removeLastContext();
        }
        sub1.setProgress(1.0);
        // (that is being asserted in methods which get called indirectly)
        try (WorkflowLock lock = cont instanceof WorkflowManager ? ((WorkflowManager) cont).lock() : lock()) {
            cont.loadContent(persistor, tblRep, inStack, sub2, subResult, keepNodeMessage);
        }
        sub2.setProgress(1.0);
        if (persistor.isDirtyAfterLoad()) {
            cont.setDirty();
        }
        boolean hasPredecessorFailed = false;
        for (ConnectionContainer cc : m_workflow.getConnectionsByDest(bfsID)) {
            NodeID s = cc.getSource();
            if (s.equals(getID())) {
                // don't consider WFM_IN connections
                continue;
            }
            if (failedNodes.contains(s)) {
                hasPredecessorFailed = true;
            }
        }
        if (!needsReset) {
            boolean isFullyConnected = isFullyConnected(bfsID);
            switch(contStateBeforeLoadContent) {
                case IDLE:
                case UNCONFIGURED_MARKEDFOREXEC:
                    needsReset = false;
                    break;
                default:
                    // we reset everything which is not fully connected
                    needsReset = !isFullyConnected;
                    break;
            }
            needsReset |= persistor.needsResetAfterLoad();
            needsReset |= hasPredecessorFailed;
        }
        boolean isExecuted = cont.getInternalState().equals(EXECUTED);
        boolean remoteExec = persistor.getMetaPersistor().getExecutionJobSettings() != null;
        // predecessors has been loaded as IDLE
        if (!needsReset && isExecuted && inPortsContainNull) {
            needsReset = true;
            subResult.addError("Predecessor ports have no data", true);
        }
        if (needsReset && cont instanceof SingleNodeContainer && cont.isResetable()) {
            // we don't care for successors because they are not loaded yet
            invokeResetOnSingleNodeContainer((SingleNodeContainer) cont);
            isExecuted = false;
        }
        if (needsReset) {
            failedNodes.add(bfsID);
        }
        if (!isExecuted && cont instanceof SingleNodeContainer) {
            configureSingleNodeContainer((SingleNodeContainer) cont, keepNodeMessage);
        }
        if (persistor.mustComplainIfStateDoesNotMatch() && !cont.getInternalState().equals(loadState) && !hasPredecessorFailed) {
            isStateChangePredictable = true;
            String warning = "State has changed from " + loadState + " to " + cont.getInternalState();
            switch(subResult.getType()) {
                case DataLoadError:
                    // data load errors cause state changes
                    subResult.addError(warning, true);
                    break;
                default:
                    subResult.addNodeStateChangedWarning(warning);
            }
            cont.setDirty();
        }
        // saved in executing state (e.g. grid job), request to reconnect
        if (remoteExec) {
            if (needsReset) {
                subResult.addError("Can't continue execution " + "due to load errors");
            }
            if (inPortsContainNull) {
                subResult.addError("Can't continue execution; no data in inport");
            }
            if (!cont.getInternalState().equals(EXECUTINGREMOTELY)) {
                subResult.addError("Can't continue execution; node is not " + "configured but " + cont.getInternalState());
            }
            try {
                if (!continueExecutionOnLoad(cont, persistor)) {
                    cont.cancelExecution();
                    cont.setDirty();
                    subResult.addError("Can't continue execution; unknown reason");
                }
            } catch (Exception exc) {
                StringBuilder error = new StringBuilder("Can't continue execution");
                if (exc instanceof NodeExecutionJobReconnectException || exc instanceof InvalidSettingsException) {
                    error.append(": ").append(exc.getMessage());
                } else {
                    error.append(" due to ");
                    error.append(exc.getClass().getSimpleName());
                    error.append(": ").append(exc.getMessage());
                }
                LOGGER.error(error, exc);
                cont.cancelExecution();
                cont.setDirty();
                subResult.addError(error.toString());
            }
        }
        loadResult.addChildError(subResult);
        // which must be reported.
        switch(subResult.getType()) {
            case Ok:
            case Warning:
                break;
            case DataLoadError:
                if (!mustWarnOnDataLoadError) {
                    break;
                }
            default:
                NodeMessage oldMessage = cont.getNodeMessage();
                StringBuilder messageBuilder = new StringBuilder(oldMessage.getMessage());
                if (messageBuilder.length() != 0) {
                    messageBuilder.append("\n");
                }
                NodeMessage.Type type;
                switch(oldMessage.getMessageType()) {
                    case RESET:
                    case WARNING:
                        type = NodeMessage.Type.WARNING;
                        break;
                    default:
                        type = NodeMessage.Type.ERROR;
                }
                messageBuilder.append(subResult.getFilteredError("", LoadResultEntryType.Warning));
                cont.setNodeMessage(new NodeMessage(type, messageBuilder.toString()));
        }
    }
    if (!sweep(nodeIDsInPersistorSet) && !isStateChangePredictable) {
        loadResult.addWarning("Some node states were invalid");
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) PortObject(org.knime.core.node.port.PortObject) Type(org.knime.core.node.workflow.NodeMessage.Type) IOException(java.io.IOException) WorkflowLoadResult(org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) CoreException(org.eclipse.core.runtime.CoreException) LockFailedException(org.knime.core.util.LockFailedException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) JsonException(javax.json.JsonException) NotConfigurableException(org.knime.core.node.NotConfigurableException) IOException(java.io.IOException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 3 with Type

use of org.knime.core.node.workflow.NodeMessage.Type in project knime-core by knime.

the class FileNodeContainerMetaPersistor method loadNodeMessage.

/**
 * Load messages that were set on the node.
 *
 * @param settings to load from.
 * @return null in this class, sub-classes overwrite this method.
 * @throws InvalidSettingsException If this fails.
 */
protected NodeMessage loadNodeMessage(final NodeSettingsRO settings) throws InvalidSettingsException {
    if (getLoadVersion().isOlderThan(LoadVersion.V200)) {
        return null;
    } else {
        final String key;
        // the node message in the Node class.
        if (getLoadVersion().ordinal() >= LoadVersion.V280.ordinal()) {
            key = "nodecontainer_message";
        } else {
            key = "node_message";
        }
        if (settings.containsKey(key)) {
            NodeSettingsRO sub = settings.getNodeSettings(key);
            String typeS = sub.getString("type");
            if (typeS == null) {
                throw new InvalidSettingsException("Message type must not be null");
            }
            Type type;
            try {
                type = Type.valueOf(typeS);
            } catch (IllegalArgumentException iae) {
                throw new InvalidSettingsException("Invalid message type: " + typeS, iae);
            }
            String message = sub.getString("message");
            return new NodeMessage(type, message);
        }
        return null;
    }
}
Also used : Type(org.knime.core.node.workflow.NodeMessage.Type) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Aggregations

IOException (java.io.IOException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 LinkedHashSet (java.util.LinkedHashSet)2 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 Type (org.knime.core.node.workflow.NodeMessage.Type)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 URI (java.net.URI)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1