private void refreshLagMetrics() { for (Map.Entry<SystemStreamPartition, Long> e : nextOffsets.entrySet()) { SystemStreamPartition ssp = e.getKey(); Long offset = e.getValue(); TopicAndPartition tp = new TopicAndPartition(ssp.getStream(), ssp.getPartition().getPartitionId()); Long lag = latestLags.get(ssp); LOG.trace("Latest offset of {} is {}; lag = {}", ssp, offset, lag); if (lag != null && offset != null && lag >= 0) { long streamEndOffset = offset.longValue() + lag.longValue(); // update the metrics kafkaConsumerMetrics.setHighWatermarkValue(tp, streamEndOffset); kafkaConsumerMetrics.setLagValue(tp, lag.longValue()); } } }
private void refreshLagMetrics() { for (Map.Entry<SystemStreamPartition, Long> e : nextOffsets.entrySet()) { SystemStreamPartition ssp = e.getKey(); Long offset = e.getValue(); TopicAndPartition tp = new TopicAndPartition(ssp.getStream(), ssp.getPartition().getPartitionId()); Long lag = latestLags.get(ssp); LOG.trace("Latest offset of {} is {}; lag = {}", ssp, offset, lag); if (lag != null && offset != null && lag >= 0) { long streamEndOffset = offset.longValue() + lag.longValue(); // update the metrics kafkaConsumerMetrics.setHighWatermarkValue(tp, streamEndOffset); kafkaConsumerMetrics.setLagValue(tp, lag.longValue()); } } }
private void refreshLagMetrics() { for (Map.Entry<SystemStreamPartition, Long> e : nextOffsets.entrySet()) { SystemStreamPartition ssp = e.getKey(); Long offset = e.getValue(); TopicAndPartition tp = new TopicAndPartition(ssp.getStream(), ssp.getPartition().getPartitionId()); Long lag = latestLags.get(ssp); LOG.trace("Latest offset of {} is {}; lag = {}", ssp, offset, lag); if (lag != null && offset != null && lag >= 0) { long streamEndOffset = offset.longValue() + lag.longValue(); // update the metrics kafkaConsumerMetrics.setHighWatermarkValue(tp, streamEndOffset); kafkaConsumerMetrics.setLagValue(tp, lag.longValue()); } } }
expectedValues.put(metrics.highWatermark().get(tp2).getName(), "1001"); metrics.setLagValue(tp1, 200); metrics.setLagValue(tp1, 201); // final value 201 expectedValues.put(metrics.lag().get(tp1).getName(), "201");