@Test public void testUpdateFetchPositionResetToLatestOffset() { subscriptions.assignFromUser(Arrays.asList(tp)); subscriptions.needOffsetReset(tp, OffsetResetStrategy.LATEST); client.prepareResponse(listOffsetRequestMatcher(ListOffsetRequest.LATEST_TIMESTAMP), listOffsetResponse(Errors.NONE, Arrays.asList(5L))); fetcher.updateFetchPositions(Collections.singleton(tp)); assertFalse(subscriptions.isOffsetResetNeeded(tp)); assertTrue(subscriptions.isFetchable(tp)); assertEquals(5, subscriptions.position(tp).longValue()); }
public void updateFetchPositions(Set<TopicPartition> partitions) { for (TopicPartition tp : partitions) { if (!subscriptions.isAssigned(tp) || subscriptions.isFetchable(tp)) { continue; } if (subscriptions.isOffsetResetNeeded(tp)) { resetOffset(tp); } else if (subscriptions.committed(tp) == null) { subscriptions.needOffsetReset(tp); resetOffset(tp); } else { long committed = subscriptions.committed(tp) .offset(); log.debug("Resetting offset for partition {} to the committed offset {}", tp, committed); subscriptions.seek(tp, committed); } } }
Fetcher { public void updateFetchPositions(Set<TopicPartition> partitions) { for (TopicPartition tp : partitions) { if (!subscriptions.isAssigned(tp) || subscriptions.isFetchable(tp)) { continue; } if (subscriptions.isOffsetResetNeeded(tp)) { resetOffset(tp); } else if (subscriptions.committed(tp) == null) { subscriptions.needOffsetReset(tp); resetOffset(tp); } else { long committed = subscriptions.committed(tp) .offset(); log.debug("Resetting offset for partition {} to the committed offset {}", tp, committed); subscriptions.seek(tp, committed); } } } }
Fetcher { public void updateFetchPositions(Set<TopicPartition> partitions) { for (TopicPartition tp : partitions) { if (!subscriptions.isAssigned(tp) || subscriptions.isFetchable(tp)) { continue; } if (subscriptions.isOffsetResetNeeded(tp)) { resetOffset(tp); } else if (subscriptions.committed(tp) == null) { subscriptions.needOffsetReset(tp); resetOffset(tp); } else { long committed = subscriptions.committed(tp) .offset(); log.debug("Resetting offset for partition {} to the committed offset {}", tp, committed); subscriptions.seek(tp, committed); } } } Fetcher(ConsumerNetworkClient client,
        int minBytes,
        int maxWaitMs,
        int fetchSize,
        int maxPollRecords,
        boolean checkCrcs,
        Deserializer<K> keyDeserializer,
        Deserializer<V> valueDeserializer,
        Metadata metadata,
        SubscriptionState subscriptions,
        Metrics metrics,
        String metricGrpPrefix,
        Time time,
        long retryBackoffMs); }
Fetcher { public void updateFetchPositions(Set<TopicPartition> partitions) { for (TopicPartition tp : partitions) { if (!subscriptions.isAssigned(tp) || subscriptions.isFetchable(tp)) { continue; } if (subscriptions.isOffsetResetNeeded(tp)) { resetOffset(tp); } else if (subscriptions.committed(tp) == null) { subscriptions.needOffsetReset(tp); resetOffset(tp); } else { long committed = subscriptions.committed(tp) .offset(); log.debug("Resetting offset for partition {} to the committed offset {}", tp, committed); subscriptions.seek(tp, committed); } } } Fetcher(ConsumerNetworkClient client,
        int minBytes,
        int maxWaitMs,
        int fetchSize,
        int maxPollRecords,
        boolean checkCrcs,
        Deserializer<K> keyDeserializer,
        Deserializer<V> valueDeserializer,
        Metadata metadata,
        SubscriptionState subscriptions,
        Metrics metrics,
        String metricGrpPrefix,
        Time time,
        long retryBackoffMs); void sendFetches(); Map<TopicPartition, List<ConsumerRecord<K, V>>> fetchedRecords(); void updateFetchPositions(Set<TopicPartition> partitions); Map<String, List<PartitionInfo>> getAllTopicMetadata(long timeout); Map<String, List<PartitionInfo>> getTopicMetadata(MetadataRequest request, long timeout); }
Fetcher { public void updateFetchPositions(Set<TopicPartition> partitions) { for (TopicPartition tp : partitions) { if (!subscriptions.isAssigned(tp) || subscriptions.isFetchable(tp)) { continue; } if (subscriptions.isOffsetResetNeeded(tp)) { resetOffset(tp); } else if (subscriptions.committed(tp) == null) { subscriptions.needOffsetReset(tp); resetOffset(tp); } else { long committed = subscriptions.committed(tp) .offset(); log.debug("Resetting offset for partition {} to the committed offset {}", tp, committed); subscriptions.seek(tp, committed); } } } Fetcher(ConsumerNetworkClient client,
        int minBytes,
        int maxWaitMs,
        int fetchSize,
        int maxPollRecords,
        boolean checkCrcs,
        Deserializer<K> keyDeserializer,
        Deserializer<V> valueDeserializer,
        Metadata metadata,
        SubscriptionState subscriptions,
        Metrics metrics,
        String metricGrpPrefix,
        Time time,
        long retryBackoffMs); void sendFetches(); Map<TopicPartition, List<ConsumerRecord<K, V>>> fetchedRecords(); void updateFetchPositions(Set<TopicPartition> partitions); Map<String, List<PartitionInfo>> getAllTopicMetadata(long timeout); Map<String, List<PartitionInfo>> getTopicMetadata(MetadataRequest request, long timeout);  }