@Override protected void restoreFromSnapshot(@Nonnull Object key, @Nonnull Object value) { @SuppressWarnings("unchecked") int partitionId = ((BroadcastKey<Integer>) key).key(); int partitionIndex = arrayIndexOf(partitionId, partitionIds); long offset = ((long[]) value)[0]; long wm = ((long[]) value)[1]; if (partitionIndex >= 0) { readOffsets[partitionIndex] = offset; emitOffsets[partitionIndex] = offset; // Always use partition index of 0, treating all the partitions the // same for coalescing purposes. eventTimeMapper.restoreWatermark(0, wm); } }
@Override public boolean finishSnapshotRestore() { eventTimeMapper.restoreWatermark(0, minRestoredWm); logFine(getLogger(), "restored lastEmittedWm=%s", minRestoredWm); return true; }
@Override public void restoreFromSnapshot(@Nonnull Object key, @Nonnull Object value) { TopicPartition topicPartition = ((BroadcastKey<TopicPartition>) key).key(); long[] value1 = (long[]) value; long offset = value1[0]; long watermark = value1[1]; long[] topicOffsets = offsets.get(topicPartition.topic()); if (topicOffsets == null) { getLogger().warning("Offset for topic '" + topicPartition.topic() + "' is present in snapshot, but the topic is not supposed to be read"); return; } if (topicPartition.partition() >= topicOffsets.length) { getLogger().warning("Offset for partition '" + topicPartition + "' is present in snapshot," + " but that topic currently has only " + topicOffsets.length + " partitions"); } Integer partitionIndex = currentAssignment.get(topicPartition); if (partitionIndex != null) { assert topicOffsets[topicPartition.partition()] < 0 : "duplicate offset for topicPartition '" + topicPartition + "' restored, offset1=" + topicOffsets[topicPartition.partition()] + ", offset2=" + offset; topicOffsets[topicPartition.partition()] = offset; consumer.seek(topicPartition, offset + 1); eventTimeMapper.restoreWatermark(partitionIndex, watermark); } }