Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: Tim MeagherHi,
If any node fails, then no nodes downstream of that node will execute.
This means that any nodes connected to the output of a failed node, or any nodes which are clocked to the outclock of a failed node will not execute.
You can force a node to fail using the BRAINscript abort operator, where you can provide the reason to the abort operator, like:
abort("Invalid data seen")
So in order to stop the entire graph from executing based on a certain condition, you could have a filter node with code like:
if (<condition>) then {
abort("Graph execution stopped due to <condition>")
}
Then by connecting that node via clocks and outputs you can ensure that no nodes after that node will run - you can use this to effectively stop the graph.
Alternately, if you want the graph to stop without forcing an error condition, you can use the BRAINScript setSuccessReturnCode operator.
Using setSuccessReturnCode(200) will ensure that the node terminates succesfully, but no nodes connected to any outclocks or outputs of the node will execute.
You could do this in a similar manner using something like:
if (<condition>) then {
setSuccessReturnCode(200)
}
As with the abort operator, you need to ensure that this node is then connected (via outputs or outclocks) to the nodes you want not to execute.
Note that when using input<->output connections, if you are using streaming mode (configurable in your BRE Preferences->Server Farm settings), then a node can start operating on the output of an upstream node prior to the upstream node completing its execution. In order to ensure this doesn't happen, and that the downstream node waits for completion of the upstream node, you can create a parameter with a runtime property name of "ls.brain.node.streamable" and set this to false.
This is documented in a little more detail in the BRAINScript help for the setSuccessReturnCode operator (found under "Miscellaneous Operators").
Regards,
Tim.