AndrewJSchofield commented on code in PR #17858:
URL: https://github.com/apache/kafka/pull/17858#discussion_r1856254567
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamThread.java:
##########
@@ -1294,29 +1294,25 @@ private void resetOffsets(final Set<TopicPartition>
partitions, final Exception
final Set<TopicPartition> notReset = new HashSet<>();
for (final TopicPartition partition : partitions) {
- final OffsetResetStrategy offsetResetStrategy =
topologyMetadata.offsetResetStrategy(partition.topic());
+ final AutoOffsetResetStrategy offsetResetStrategy =
topologyMetadata.offsetResetStrategy(partition.topic());
// This may be null if the task we are currently processing was
apart of a named topology that was just removed.
// TODO KAFKA-13713: keep the StreamThreads and TopologyMetadata
view of named topologies in sync until final thread has acked
if (offsetResetStrategy != null) {
- switch (offsetResetStrategy) {
- case EARLIEST:
- addToResetList(partition, seekToBeginning, "Setting
topic '{}' to consume from {} offset", "earliest", loggedTopics);
- break;
- case LATEST:
- addToResetList(partition, seekToEnd, "Setting topic
'{}' to consume from {} offset", "latest", loggedTopics);
- break;
- case NONE:
- if ("earliest".equals(originalReset)) {
- addToResetList(partition, seekToBeginning, "No
custom setting defined for topic '{}' using original config '{}' for offset
reset", "earliest", loggedTopics);
- } else if ("latest".equals(originalReset)) {
- addToResetList(partition, seekToEnd, "No custom
setting defined for topic '{}' using original config '{}' for offset reset",
"latest", loggedTopics);
- } else {
- notReset.add(partition);
- }
- break;
- default:
- throw new IllegalStateException("Unable to locate
topic " + partition.topic() + " in the topology");
+ if (offsetResetStrategy == AutoOffsetResetStrategy.EARLIEST) {
+ addToResetList(partition, seekToBeginning, "Setting topic
'{}' to consume from {} offset", "earliest", loggedTopics);
+ } else if (offsetResetStrategy ==
AutoOffsetResetStrategy.LATEST) {
+ addToResetList(partition, seekToEnd, "Setting topic '{}'
to consume from {} offset", "latest", loggedTopics);
+ } else if (offsetResetStrategy ==
AutoOffsetResetStrategy.NONE) {
+ if (AutoOffsetResetStrategy.EARLIEST ==
AutoOffsetResetStrategy.fromString(originalReset)) {
Review Comment:
I suggest making a variable to hold
`AutoOffsetResetStrategy.fromString(originalReset)` so this code is not
repeated in both if conditions.
##########
clients/src/main/java/org/apache/kafka/clients/consumer/OffsetResetStrategy.java:
##########
@@ -18,6 +18,10 @@
import java.util.Locale;
+/**
+ * @deprecated Since 4.0.
Review Comment:
I suggest adding an indication about what to migrate to instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]