Search in sources :

Example 1 with SingleTaskDataPublisher

use of org.apache.gobblin.publisher.SingleTaskDataPublisher in project incubator-gobblin by apache.

the class Task method publishTaskData.

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();
    }
}
Also used : Closer(com.google.common.io.Closer) SingleTaskDataPublisher(org.apache.gobblin.publisher.SingleTaskDataPublisher)

Aggregations

Closer (com.google.common.io.Closer)1 SingleTaskDataPublisher (org.apache.gobblin.publisher.SingleTaskDataPublisher)1