Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

kafka-763 delta; Add an option to replica from the largest offset dur…

…ing unclean leader election; patched by Swapnil Ghike; reviewed by Jun Rao
  • Loading branch information...
commit 3b3fb7fed622cc0339c3b9e3fb175e6093e427a3 1 parent 0a92835
Swapnil Ghike authored junrao committed
View
7 core/src/main/scala/kafka/consumer/ConsumerFetcherThread.scala
@@ -58,12 +58,7 @@ class ConsumerFetcherThread(name: String,
case OffsetRequest.LargestTimeString => startTimestamp = OffsetRequest.LatestTime
case _ => startTimestamp = OffsetRequest.LatestTime
}
- val request = OffsetRequest(Map(topicAndPartition -> PartitionOffsetRequestInfo(startTimestamp, 1)))
- val partitionErrorAndOffset = simpleConsumer.getOffsetsBefore(request).partitionErrorAndOffsets(topicAndPartition)
- val newOffset = partitionErrorAndOffset.error match {
- case ErrorMapping.NoError => partitionErrorAndOffset.offsets.head
- case _ => throw ErrorMapping.exceptionFor(partitionErrorAndOffset.error)
- }
+ val newOffset = simpleConsumer.earliestOrLatestOffset(topicAndPartition, startTimestamp, Request.OrdinaryConsumerId)
val pti = partitionMap(topicAndPartition)
pti.resetFetchOffset(newOffset)
pti.resetConsumeOffset(newOffset)
View
1  core/src/main/scala/kafka/consumer/SimpleConsumer.scala
@@ -141,6 +141,7 @@ class SimpleConsumer(val host: String,
*/
def earliestOrLatestOffset(topicAndPartition: TopicAndPartition, earliestOrLatest: Long, consumerId: Int): Long = {
val request = OffsetRequest(requestInfo = Map(topicAndPartition -> PartitionOffsetRequestInfo(earliestOrLatest, 1)),
+ clientId = clientId,
replicaId = consumerId)
val partitionErrorAndOffset = getOffsetsBefore(request).partitionErrorAndOffsets(topicAndPartition)
val offset = partitionErrorAndOffset.error match {
Please sign in to comment.
Something went wrong with that request. Please try again.