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);
}
};
}
Aggregations