Search in sources :

Example 1 with ForwardingStreamConsumer

use of co.cask.cdap.data2.transaction.stream.ForwardingStreamConsumer in project cdap by caskdata.

the class LineageWriterDataFabricFacade method createStreamConsumer.

@Override
public StreamConsumer createStreamConsumer(StreamId streamName, ConsumerConfig consumerConfig) throws IOException {
    String namespace = String.format("%s.%s", programId.getApplicationId(), programId.getId());
    final StreamConsumer consumer = streamConsumerFactory.create(streamName, namespace, consumerConfig);
    datasetCache.addExtraTransactionAware(consumer);
    ProgramContext programContext = this.programContext;
    if (programContext != null) {
        lineageWriter.addAccess(programContext.getProgramRunId(), streamName, AccessType.READ, programContext.getComponentId());
    }
    return new ForwardingStreamConsumer(consumer) {

        @Override
        public void close() throws IOException {
            super.close();
            datasetCache.removeExtraTransactionAware(consumer);
        }
    };
}
Also used : ForwardingStreamConsumer(co.cask.cdap.data2.transaction.stream.ForwardingStreamConsumer) StreamConsumer(co.cask.cdap.data2.transaction.stream.StreamConsumer) ProgramContext(co.cask.cdap.data.ProgramContext) ForwardingStreamConsumer(co.cask.cdap.data2.transaction.stream.ForwardingStreamConsumer)

Aggregations

ProgramContext (co.cask.cdap.data.ProgramContext)1 ForwardingStreamConsumer (co.cask.cdap.data2.transaction.stream.ForwardingStreamConsumer)1 StreamConsumer (co.cask.cdap.data2.transaction.stream.StreamConsumer)1