my $self = shift;
my $return_value = $self->param('return_value');
## Success
unless ($return_value) {
# FIXME branch number
$self->dataflow_output_ids_from_json($self->param('dataflow_file'), $self->param('dataflow_branch')) if $self->param('dataflow_file');
return;
}
## Error processing
my $stderr = $self->param('stderr');
my $flat_cmd = $self->param('flat_cmd');
if ($return_value == -1) {
# system() could not start, or wait() failed
die sprintf( "Could not start '%s': %s\n", $flat_cmd, $stderr);
} elsif ($return_value == -2) {
$self->complete_early_if_branch_connected("The command was aborted because it exceeded the allowed runtime. Flowing to the -2 branch.\n", -2);
die "The command was aborted because it exceeded the allowed runtime, but there are no dataflow-rules on branch -2.\n";
# Lower 8 bits indicate the process has been killed and did not complete.
} elsif ($return_value & 255) {
# It can happen because of a MEMLIMIT / RUNLIMIT, which we
# know are not atomic. The best is to wait a bit that LSF kills
# the worker too
sleep 30;
# If we reach this point, it was killed for another reason.
die sprintf( "'%s' was killed with code=%d\nstderr is: %s\n", $flat_cmd, $return_value, $stderr);
} else {
# "Normal" process exit with a non-zero code (in the upper 8 bits)
$return_value >>= 8;
# We create a dataflow event depending on the exit code of the process.
if (ref($self->param('return_codes_2_branches')) and exists $self->param('return_codes_2_branches')->{$return_value}) {
my $branch_number = $self->param('return_codes_2_branches')->{$return_value};
$self->complete_early(sprintf("The command exited with code %d, which is mapped to a dataflow on branch #%d.\n", $return_value, $branch_number), $branch_number);
}
if ($stderr =~ /Exception in thread ".*" java.lang.OutOfMemoryError: Java heap space at/) {
$self->complete_early_if_branch_connected("Java heap space is out of memory. A job has been dataflown to the -1 branch.\n", -1);
die $stderr;
}
die sprintf( "'%s' resulted in an error code=%d\nstderr is: %s\n", $flat_cmd, $return_value, $stderr);
}
}