/** * Sets the {@link ConfigurationKeys#TASK_FAILURE_EXCEPTION_KEY} for each given {@link TaskState} to the given * {@link Throwable}. * * Make this method public as this exception catching routine can be reusable in other occasions as well. */ public static void setTaskFailureException(Collection<? extends WorkUnitState> taskStates, Throwable t) { for (WorkUnitState taskState : taskStates) { ((TaskState) taskState).setTaskFailureException(t); } }
private void publishTaskData() throws IOException { Closer closer = Closer.create(); try { Class<? extends DataPublisher> dataPublisherClass = getTaskPublisherClass(); SingleTaskDataPublisher publisher = closer.register(SingleTaskDataPublisher.getInstance(dataPublisherClass, this.taskState)); LOG.info("Publishing data from task " + this.taskId); publisher.publish(this.taskState); } catch (ClassCastException e) { LOG.error(String.format("To publish data in task, the publisher class must extend %s", SingleTaskDataPublisher.class.getSimpleName()), e); this.taskState.setTaskFailureException(e); throw closer.rethrow(e); } catch (Throwable t) { this.taskState.setTaskFailureException(t); throw closer.rethrow(t); } finally { closer.close(); } }
/** * Sets the {@link ConfigurationKeys#TASK_FAILURE_EXCEPTION_KEY} for each given {@link TaskState} to the given * {@link Throwable}. * * Make this method public as this exception catching routine can be reusable in other occasions as well. */ public static void setTaskFailureException(Collection<? extends WorkUnitState> taskStates, Throwable t) { for (WorkUnitState taskState : taskStates) { ((TaskState) taskState).setTaskFailureException(t); } }
private void publishTaskData() throws IOException { Closer closer = Closer.create(); try { Class<? extends DataPublisher> dataPublisherClass = getTaskPublisherClass(); SingleTaskDataPublisher publisher = closer.register(SingleTaskDataPublisher.getInstance(dataPublisherClass, this.taskState)); LOG.info("Publishing data from task " + this.taskId); publisher.publish(this.taskState); } catch (ClassCastException e) { LOG.error(String.format("To publish data in task, the publisher class must extend %s", SingleTaskDataPublisher.class.getSimpleName()), e); this.taskState.setTaskFailureException(e); throw closer.rethrow(e); } catch (Throwable t) { this.taskState.setTaskFailureException(t); throw closer.rethrow(t); } finally { closer.close(); } }