@Override public void map(Object key, Object value, Mapper.Context context) throws IOException, InterruptedException { try { transformRunner.transform(key, value); } catch (StageFailureException e) { PIPELINE_LOG.error("{}", e.getMessage(), e.getCause()); Throwables.propagate(e.getCause()); } catch (Exception e) { Throwables.propagate(e); } }
/** * Consume a record and send it to the relevant output transforms. * * @param input the record to consume * @throws StageFailureException if there was an exception consuming the input */ public void consume(T input) { try { consumeInput(input); } catch (StageFailureException e) { // Another stage has already failed, just throw the exception as-is throw e; } catch (Exception e) { Throwable rootCause = Throwables.getRootCause(e); // Create StageFailureException to save the Stage information throw new StageFailureException( String.format("Failed to execute pipeline stage '%s' with the error: %s. Please review your pipeline " + "configuration and check the system logs for more details.", stageName, rootCause.getMessage()), rootCause); } }
@Override protected void reduce(Object key, Iterable values, Context context) throws IOException, InterruptedException { try { transformRunner.transform(key, values.iterator()); } catch (StageFailureException e) { PIPELINE_LOG.error("{}", e.getMessage(), e.getCause()); Throwables.propagate(e.getCause()); } catch (Exception e) { Throwables.propagate(e); } }