use of org.knime.core.node.workflow.execresult.NodeContainerExecutionStatus in project knime-core by knime.
the class WorkflowManager method mimicRemoteExecuted.
/**
* {@inheritDoc}
*/
@Override
void mimicRemoteExecuted(final NodeContainerExecutionStatus status) {
try (WorkflowLock lock = lock()) {
for (NodeContainer nc : m_workflow.getNodeValues()) {
int i = nc.getID().getIndex();
NodeContainerExecutionStatus sub = status.getChildStatus(i);
if (sub == null) {
assert false : "Execution status is null for child " + i;
sub = NodeContainerExecutionStatus.FAILURE;
}
// will be ignored on already executed nodes
// (think of an executed file reader in a metanode that is
// submitted onto a cluster in the executed state already)
nc.mimicRemoteExecuted(sub);
}
// do not propagate -- method is (indirectly) called from parent
lock.queueCheckForNodeStateChangeNotification(false);
}
}
use of org.knime.core.node.workflow.execresult.NodeContainerExecutionStatus in project knime-core by knime.
the class NodeExecutionJob method internalRun.
/**
*/
private void internalRun() {
NodeContainerExecutionStatus status = null;
// handle inactive branches -- do not delegate to custom job
// manager (the node will just return inactive branch objects)
boolean executeInactive = false;
if (m_nc instanceof SingleNodeContainer) {
SingleNodeContainer snc = (SingleNodeContainer) m_nc;
if (!snc.isInactiveBranchConsumer() && Node.containsInactiveObjects(getPortObjects())) {
executeInactive = true;
}
}
if (!isReConnecting()) {
try {
// sets state PREEXECUTE
if (!m_nc.notifyParentPreExecuteStart()) {
// node was canceled, omit any subsequent state transitions
return;
}
if (!executeInactive) {
beforeExecute();
}
} catch (Throwable throwable) {
logError(throwable);
status = NodeContainerExecutionStatus.FAILURE;
}
try {
// sets state EXECUTING
m_nc.notifyParentExecuteStart();
} catch (IllegalFlowObjectStackException e) {
status = NodeContainerExecutionStatus.FAILURE;
} catch (Throwable throwable) {
status = NodeContainerExecutionStatus.FAILURE;
logError(throwable);
}
}
// check thread cancelation
if (status == null) {
if (Thread.interrupted()) {
status = NodeContainerExecutionStatus.FAILURE;
} else {
try {
m_nc.getProgressMonitor().checkCanceled();
} catch (CanceledExecutionException cee) {
status = NodeContainerExecutionStatus.FAILURE;
}
}
}
try {
if (status == null) {
NodeLogger.getLogger(m_nc.getClass());
// start message and keep start time
final long time = System.currentTimeMillis();
m_logger.debug(m_nc.getNameWithID() + " Start execute");
if (executeInactive) {
SingleNodeContainer snc = (SingleNodeContainer) m_nc;
status = snc.performExecuteNode(getPortObjects());
} else {
status = mainExecute();
}
if (status != null && status.isSuccess()) {
String elapsed = StringFormat.formatElapsedTime(System.currentTimeMillis() - time);
m_logger.info(m_nc.getNameWithID() + " End execute (" + elapsed + ")");
}
}
} catch (Throwable throwable) {
status = NodeContainerExecutionStatus.FAILURE;
logError(throwable);
}
try {
// sets state POSTEXECUTE
m_nc.notifyParentPostExecuteStart(status);
if (!executeInactive) {
afterExecute();
}
} catch (Throwable throwable) {
status = NodeContainerExecutionStatus.FAILURE;
logError(throwable);
}
try {
// sets state EXECUTED
m_nc.notifyParentExecuteFinished(status);
} catch (Exception e) {
logError(e);
}
}
use of org.knime.core.node.workflow.execresult.NodeContainerExecutionStatus in project knime-core by knime.
the class SubNodeContainer method performStateTransitionEXECUTED.
/**
* {@inheritDoc}
*/
@Override
void performStateTransitionEXECUTED(final NodeContainerExecutionStatus status) {
synchronized (m_nodeMutex) {
switch(getInternalState()) {
case POSTEXECUTE:
NodeContainerExecutionStatus wfmStatus = status instanceof SubnodeContainerExecutionResult ? ((SubnodeContainerExecutionResult) status).getWorkflowExecutionResult() : status;
runIfInExternalExecutor(() -> m_wfm.mimicRemoteExecuted(wfmStatus));
InternalNodeContainerState newState = status.isSuccess() ? InternalNodeContainerState.EXECUTED : m_wfm.getInternalState();
setVirtualOutputIntoOutport(newState);
setInternalState(newState);
// don't reset and configure (like a NativeNodeContainer) for easier error inspection in case of failure
setExecutionJob(null);
break;
default:
throwIllegalStateException();
}
}
}
Aggregations