use of org.zalando.nakadi.view.SubscriptionCursor in project nakadi by zalando.
the class StreamingState method flushData.
private void flushData(final EventTypePartition pk, final List<ConsumedEvent> data, final Optional<String> metadata) {
try {
final NakadiCursor sentOffset = offsets.get(pk).getSentOffset();
final SubscriptionCursor cursor = getContext().getCursorConverter().convert(sentOffset, getContext().getCursorTokenService().generateToken());
final int batchSize = getContext().getWriter().writeSubscriptionBatch(getOut().getOutputStream(), cursor, data, metadata);
bytesSentMeterPerSubscription.mark(batchSize);
final StreamKpiData kpiData = kpiDataPerEventType.get(pk.getEventType());
kpiData.addBytesSent(batchSize);
kpiData.addNumberOfEventsSent(data.size());
batchesSent++;
} catch (final IOException e) {
getLog().error("Failed to write data to output.", e);
shutdownGracefully("Failed to write data to output");
}
}
Aggregations