Search in sources :

Example 36 with ExecutionMonitor

use of org.knime.core.node.ExecutionMonitor in project knime-core by knime.

the class BugAP5712_CloseWhileStreaming method initWorkflowFromTemp.

private WorkflowLoadResult initWorkflowFromTemp() throws Exception {
    // will save the workflow in one of the test ...don't write SVN folder
    WorkflowLoadResult loadResult = loadWorkflow(m_workflowDir, new ExecutionMonitor());
    setManager(loadResult.getWorkflowManager());
    NodeID baseID = getManager().getID();
    m_tableView_4 = new NodeID(baseID, 4);
    m_streamSubnode_5 = new NodeID(baseID, 5);
    return loadResult;
}
Also used : ExecutionMonitor(org.knime.core.node.ExecutionMonitor) WorkflowLoadResult(org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult)

Example 37 with ExecutionMonitor

use of org.knime.core.node.ExecutionMonitor in project knime-core by knime.

the class BugAP6262_FileStoresInPortObjectCell method testExecuteAfterPartialSave.

@Test(timeout = 300000L)
public void testExecuteAfterPartialSave() throws Exception {
    WorkflowManager manager = getManager();
    checkState(manager, IDLE);
    executeAllAndWait();
    checkState(manager, EXECUTED);
    manager.save(m_workflowDir, new ExecutionMonitor(), true);
    closeWorkflow();
    assertNull(getManager());
    WorkflowLoadResult loadResult = initWorkflowFromTemp();
    manager = getManager();
    assertFalse("should not have errors", loadResult.hasErrors());
    checkState(manager, EXECUTED);
    reset(m_predictorLoopStart_11);
    checkState(manager, IDLE);
    executeAllAndWait();
    checkState(manager, EXECUTED);
}
Also used : ExecutionMonitor(org.knime.core.node.ExecutionMonitor) WorkflowLoadResult(org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult) Test(org.junit.Test)

Example 38 with ExecutionMonitor

use of org.knime.core.node.ExecutionMonitor in project knime-core by knime.

the class BugAP7982_FutureKNIMEVersion_AllCompatible method loadWorkflow.

/**
 * Load workflow, expect no errors.
 */
@Test
public void loadWorkflow() throws Exception {
    File wkfDir = getDefaultWorkflowDirectory();
    WorkflowLoadResult loadWorkflow = loadWorkflow(wkfDir, new ExecutionMonitor(), new WorkflowLoadHelper(wkfDir) {

        @Override
        public UnknownKNIMEVersionLoadPolicy getUnknownKNIMEVersionLoadPolicy(final LoadVersion workflowKNIMEVersion, final Version createdByKNIMEVersion, final boolean isNightlyBuild) {
            throw new AssertionFailedError("Not to be called - workflow is expected to be compatible");
        }
    });
    setManager(loadWorkflow.getWorkflowManager());
    assertThat("Expected to loaded without errors", loadWorkflow.getType(), is(LoadResultEntryType.Ok));
    assertThat("Workflow version incorrect", getManager().getLoadVersion(), is(LoadVersion.V280));
}
Also used : LoadVersion(org.knime.core.node.workflow.FileWorkflowPersistor.LoadVersion) Version(org.knime.core.util.Version) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) LoadVersion(org.knime.core.node.workflow.FileWorkflowPersistor.LoadVersion) AssertionFailedError(junit.framework.AssertionFailedError) File(java.io.File) WorkflowLoadResult(org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult) Test(org.junit.Test)

Example 39 with ExecutionMonitor

use of org.knime.core.node.ExecutionMonitor in project knime-core by knime.

the class Bug_4423_saveDuringResetDeadlock method runTest.

private void runTest(final Pointer<Exception> throwablePointer) throws Exception {
    final Display currentDisplay = Display.getCurrent();
    final Thread displayThread = currentDisplay.getThread();
    final Thread currentThread = Thread.currentThread();
    // reset and save are getting called from UI thread - replicate it here.
    assertTrue("Not executing in display thread: " + currentThread, currentThread == displayThread);
    final WorkflowManager workflowManager = getManager();
    executeAllAndWait();
    final NodeContainer nc = findNodeContainer(m_tableView2);
    final AtomicReference<Progress> saveProgressPointer = new AtomicReference<>(Progress.NotStarted);
    NodeContext.pushContext(nc);
    try {
        AbstractNodeView<?> view = ((NativeNodeContainer) nc).getNode().getView(0, "Programmatically opened in test flow");
        Node.invokeOpenView(view, "Programmatically opened in test flow");
    } finally {
        NodeContext.removeLastContext();
    }
    final NodeLogger logger = NodeLogger.getLogger(getClass());
    Runnable saveRunnable = new Runnable() {

        @Override
        public void run() {
            // in the full application (and as part of the bug report) this job is scheduled while the reset is
            // ongoing; note, it's not possible to replicate the exact behavior here as the whole test case is
            // run in the display thread - we have to schedule the job up-front
            Job saveJob = new Job("Workflow Save") {

                @Override
                protected IStatus run(final IProgressMonitor monitor) {
                    saveProgressPointer.set(Progress.Ongoing);
                    try {
                        logger.info("Calling save");
                        workflowManager.save(m_workflowDirTemp, new ExecutionMonitor(), true);
                        logger.info("Called save");
                    } catch (Exception e) {
                        throwablePointer.set(e);
                    } finally {
                        saveProgressPointer.set(Progress.Done);
                    }
                    return Status.OK_STATUS;
                }
            };
            saveJob.schedule();
            long wait = 5000;
            while ((saveJob.getResult() == null) && (wait > 0)) {
                try {
                    Thread.sleep(250);
                    wait -= 250;
                } catch (InterruptedException e) {
                    throwablePointer.set(e);
                }
            }
            if (saveJob.getResult() == null) {
                saveJob.cancel();
                throwablePointer.set(new IllegalStateException("Workflow save job has not finished within 5 secs, very likely because we have a deadlock"));
            }
        }
    };
    // doesn't actually run as this thread is the display thread
    currentDisplay.asyncExec(saveRunnable);
    // this is the display thread, cannot execute async scheduled tasks
    assertEquals(Progress.NotStarted, saveProgressPointer.get());
    logger.info("Calling reset");
    reset(m_dataGenerator1);
    logger.info("Called reset");
    // this might change in the future so we let the test case do its job:
    while (!Progress.Done.equals(saveProgressPointer.get())) {
        if (!currentDisplay.readAndDispatch()) {
            currentDisplay.sleep();
        }
    }
}
Also used : NodeLogger(org.knime.core.node.NodeLogger) AtomicReference(java.util.concurrent.atomic.AtomicReference) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Job(org.eclipse.core.runtime.jobs.Job) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) Display(org.eclipse.swt.widgets.Display)

Example 40 with ExecutionMonitor

use of org.knime.core.node.ExecutionMonitor in project knime-core by knime.

the class NodeContextTest method setupClass.

/**
 * Unpack and load testflow.
 *
 * @throws Exception if an error occurs
 */
@BeforeClass
public static void setupClass() throws Exception {
    File workflowZip = findInPlugin("/files/NodeContextTestflow.zip");
    File tmpDir = FileUtil.createTempDir("NodeContextTest");
    tmpDir.deleteOnExit();
    FileUtil.unzip(workflowZip, tmpDir);
    File workflowDir = tmpDir.listFiles()[0];
    WorkflowLoadResult res = WorkflowManager.loadProject(workflowDir, new ExecutionMonitor(), new WorkflowLoadHelper(workflowDir));
    if (res.hasErrors()) {
        throw new IOException("Error while loading workflow: " + res.getMessage());
    }
    wfm = res.getWorkflowManager();
    executorService = Executors.newSingleThreadExecutor();
}
Also used : IOException(java.io.IOException) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) File(java.io.File) WorkflowLoadResult(org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult) BeforeClass(org.junit.BeforeClass)

Aggregations

ExecutionMonitor (org.knime.core.node.ExecutionMonitor)160 BufferedDataTable (org.knime.core.node.BufferedDataTable)50 DataTableSpec (org.knime.core.data.DataTableSpec)43 DataRow (org.knime.core.data.DataRow)39 DataCell (org.knime.core.data.DataCell)35 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)35 Test (org.junit.Test)33 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)33 File (java.io.File)29 IOException (java.io.IOException)25 PortObject (org.knime.core.node.port.PortObject)25 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)23 DataColumnSpec (org.knime.core.data.DataColumnSpec)21 RowKey (org.knime.core.data.RowKey)20 ArrayList (java.util.ArrayList)19 WorkflowLoadResult (org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult)17 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)16 ExecutionException (java.util.concurrent.ExecutionException)14 ExecutionContext (org.knime.core.node.ExecutionContext)13 FileOutputStream (java.io.FileOutputStream)12