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;
}
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);
}
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));
}
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();
}
}
}
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();
}
Aggregations