use of org.knime.core.node.ExecutionMonitor in project knime-core by knime.
the class Bug3673_CredentialsInputNode_Test1_SimpleNodeWithSavedPassword method testLoadWhileInactive.
@Test
public void testLoadWhileInactive() throws Exception {
getManager().addConnection(m_activeBranchInverter_3, 1, m_credentialsInput_1, 0);
getManager().save(m_workflowDirTemp, new ExecutionMonitor(), true);
executeAllAndWait();
checkState(getManager(), EXECUTED);
assertTrue(((NativeNodeContainer) findNodeContainer(m_credentialsInput_1)).isInactive());
// don't save
closeWorkflow();
initFlow();
checkState(m_credentialsInput_1, CONFIGURED);
assertFalse("Not expected to be dirty", getManager().isDirty());
executeAllAndWait();
assertTrue(((NativeNodeContainer) findNodeContainer(m_credentialsInput_1)).isInactive());
checkState(m_credentialsValidate_2, EXECUTED);
}
use of org.knime.core.node.ExecutionMonitor in project knime-core by knime.
the class Bug3673_CredentialsInputNode_Test2_SimpleNodeWithNoSavedPassword method testPartialExecuteSaveLoadExecute.
@Test
public void testPartialExecuteSaveLoadExecute() throws Exception {
TestWorkflowLoadHelper loadHelper = initFlow(new TestWorkflowLoadHelper("some-fixed-password"));
executeAndWait(m_credentialsInput_1);
checkState(m_credentialsInput_1, InternalNodeContainerState.EXECUTED);
checkState(m_credentialsValidate_2, InternalNodeContainerState.CONFIGURED);
getManager().save(m_workflowDirTemp, new ExecutionMonitor(), true);
assertTrue("No password prompted", loadHelper.hasBeenPrompted());
closeWorkflow();
loadHelper = initFlow(new TestWorkflowLoadHelper("some-fixed-password"));
// input node is executed - so no prompt expected
assertFalse("Password prompted but shouldn't", loadHelper.hasBeenPrompted());
checkState(m_credentialsInput_1, InternalNodeContainerState.EXECUTED);
checkState(m_credentialsValidate_2, InternalNodeContainerState.IDLE);
// because 2nd validator is now idle
assertTrue("Expected to be dirty", getManager().isDirty());
executeAndWait(m_credentialsValidate_2, m_credentialsValidate_4);
// expected to fail - null password
checkState(m_credentialsValidate_2, InternalNodeContainerState.IDLE);
checkState(m_credentialsValidate_4, InternalNodeContainerState.EXECUTED);
}
use of org.knime.core.node.ExecutionMonitor in project knime-core by knime.
the class Bug6729_InvalidConfigOnInactiveNodes method init.
private void init() throws Exception {
WorkflowLoadResult loadResult = loadWorkflow(m_workflowDirTemp, new ExecutionMonitor(), new WorkflowLoadHelper(m_workflowDirTemp));
assertThat("Expected non-error/non-warning load result: " + loadResult.getMessage(), loadResult.getType(), is(LoadResultEntryType.Ok));
final WorkflowManager workflowManager = loadResult.getWorkflowManager();
setManager(workflowManager);
NodeID baseID = workflowManager.getID();
m_fileReader2 = new NodeID(baseID, 2);
}
use of org.knime.core.node.ExecutionMonitor in project knime-core by knime.
the class Bug6339_LoopEndColAppend_PathTooLong method testMain.
/**
* Load workflow, execute, check, save, close, reopen, check, reset, execute, check.
*/
@Test
public void testMain() throws Exception {
WorkflowManager m = getManager();
checkState(m, IDLE);
checkState(m_javaSnippet_7, IDLE);
checkState(m_dataGen1, CONFIGURED);
executeAndWait(m_loopEnd_5);
m.save(m_tmpWorkflowDir, new ExecutionMonitor(), true);
executeAllAndWait();
checkState(getManager(), EXECUTED);
m.save(m_tmpWorkflowDir, new ExecutionMonitor(), true);
closeWorkflow();
assertNull(getManager());
loadAndSetWorkflow(m_tmpWorkflowDir);
m = getManager();
checkState(m, EXECUTED);
reset(m_javaSnippet_7);
checkState(m_javaSnippet_7, CONFIGURED);
executeAllAndWait();
checkState(m, EXECUTED);
}
use of org.knime.core.node.ExecutionMonitor in project knime-core by knime.
the class AbstractParallelNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected final BufferedDataTable[] execute(final BufferedDataTable[] data, final ExecutionContext exec) throws Exception {
final DataTableSpec[] outSpecs = prepareExecute(data);
final List<Future<BufferedDataContainer[]>> futures = new ArrayList<>();
final BufferedDataTable[] additionalTables = new BufferedDataTable[Math.max(0, data.length - 1)];
System.arraycopy(data, 1, additionalTables, 0, additionalTables.length);
// do some consistency checks to bail out as early as possible
if (outSpecs == null) {
throw new NullPointerException("Implementation Error: The " + "array of generated output table specs can't be null.");
}
if (outSpecs.length != getNrOutPorts()) {
throw new IllegalStateException("Implementation Error: Number of" + " provided DataTableSpecs doesn't match number of output" + " ports");
}
for (DataTableSpec outSpec : outSpecs) {
if (outSpec == null) {
throw new IllegalStateException("Implementation Error: The" + " generated output DataTableSpec is null.");
}
}
final double max = data[0].size();
final Callable<Void> submitter = new Callable<Void>() {
@Override
public Void call() throws Exception {
final RowIterator it = data[0].iterator();
BufferedDataContainer container = null;
int count = 0, chunks = 0;
while (true) {
if ((count++ % m_chunkSize == 0) || !it.hasNext()) {
exec.checkCanceled();
if (container != null) {
container.close();
final BufferedDataContainer temp = container;
chunks++;
final int temp2 = chunks;
futures.add(m_workers.submit(new Callable<BufferedDataContainer[]>() {
@Override
public BufferedDataContainer[] call() throws Exception {
ExecutionMonitor subProg = exec.createSilentSubProgress((m_chunkSize > max) ? 1 : m_chunkSize / max);
exec.setMessage("Processing chunk " + temp2);
BufferedDataContainer[] result = new BufferedDataContainer[outSpecs.length];
for (int i = 0; i < outSpecs.length; i++) {
result[i] = exec.createDataContainer(outSpecs[i], true, 0);
}
executeByChunk(temp.getTable(), additionalTables, result, subProg);
for (DataContainer c : result) {
c.close();
}
exec.setProgress(temp2 * m_chunkSize / max);
return result;
}
}));
}
if (!it.hasNext()) {
break;
}
container = exec.createDataContainer(data[0].getDataTableSpec());
}
container.addRowToTable(it.next());
}
return null;
}
};
try {
m_workers.runInvisible(submitter);
} catch (IllegalThreadStateException ex) {
// this node has not been started by a thread from a thread pool.
// This is odd, but may happen
submitter.call();
}
final BufferedDataTable[][] tempTables = new BufferedDataTable[outSpecs.length][futures.size()];
int k = 0;
for (Future<BufferedDataContainer[]> results : futures) {
try {
exec.checkCanceled();
} catch (CanceledExecutionException ex) {
for (Future<BufferedDataContainer[]> cancel : futures) {
cancel.cancel(true);
}
throw ex;
}
final BufferedDataContainer[] temp = results.get();
if ((temp == null) || (temp.length != getNrOutPorts())) {
throw new IllegalStateException("Invalid result. Execution " + " failed, reason: data is null or number " + "of outputs wrong.");
}
for (int i = 0; i < temp.length; i++) {
tempTables[i][k] = temp[i].getTable();
}
k++;
}
final BufferedDataTable[] resultTables = new BufferedDataTable[outSpecs.length];
for (int i = 0; i < resultTables.length; i++) {
resultTables[i] = exec.createConcatenateTable(exec, tempTables[i]);
}
return resultTables;
}
Aggregations