-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip
- Loading branch information
Showing
8 changed files
with
105 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...main/java/org/apache/kafka/clients/consumer/internals/events/ListOffsetsForTimeEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.kafka.clients.consumer.internals.events; | ||
|
||
import org.apache.kafka.clients.consumer.OffsetAndTimestamp; | ||
import org.apache.kafka.common.TopicPartition; | ||
import org.apache.kafka.common.utils.Timer; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Application event to list offsets for partitions by timestamps. It is completed with the map of | ||
* {@link TopicPartition} and {@link OffsetAndTimestamp} found (offset of the first message whose timestamp is | ||
* greater than or equals to the target timestamp) | ||
*/ | ||
public class ListOffsetsForTimeEvent extends CompletableApplicationEvent<Map<TopicPartition, OffsetAndTimestamp>> { | ||
private final Map<TopicPartition, Long> timestampsToSearch; | ||
|
||
public ListOffsetsForTimeEvent(final Map<TopicPartition, Long> timestampToSearch, final Timer timer) { | ||
super(Type.LIST_OFFSETS_FOR_TIME, timer); | ||
this.timestampsToSearch = Collections.unmodifiableMap(timestampToSearch); | ||
} | ||
|
||
/** | ||
* Build result representing that no offsets were found as part of the current event. | ||
* | ||
* @return Map containing all the partitions the event was trying to get offsets for, and | ||
* null {@link OffsetAndTimestamp} as value | ||
*/ | ||
public Map<TopicPartition, OffsetAndTimestamp> emptyResult() { | ||
HashMap<TopicPartition, OffsetAndTimestamp> offsetsByTimes = new HashMap<>(timestampsToSearch.size()); | ||
for (Map.Entry<TopicPartition, Long> entry : timestampsToSearch.entrySet()) | ||
offsetsByTimes.put(entry.getKey(), null); | ||
return offsetsByTimes; | ||
} | ||
|
||
public Map<TopicPartition, Long> timestampsToSearch() { | ||
return timestampsToSearch; | ||
} | ||
|
||
@Override | ||
public String toStringBase() { | ||
return super.toStringBase() + | ||
", timestampsToSearch=" + timestampsToSearch; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters