jsancio commented on pull request #10593:
URL: https://github.com/apache/kafka/pull/10593#issuecomment-849787584


   > @jsancio Addressed the comments but just found that I would need to 
generalize context.advanceLeaderHighWatermarkToEndOffset (), will update later~
   
   I needed something similar in a PR I am currently working and this is what I 
have if you want to adapt it to your PR:
   
   ```java
   public void advanceLocalLeaderHighWatermarkToLogEndOffset() throws 
InterruptedException {
       assertEquals(localId, currentLeader());
       long localLogEndOffset = log.endOffset().offset;
       Set<Integer> followers = voters.stream().filter(voter -> voter != 
localId.getAsInt()).collect(Collectors.toSet());
   
       // Send a request from every follower
       for (int follower : followers) {
           deliverRequest(
               fetchRequest(currentEpoch(), follower, localLogEndOffset, 
currentEpoch(), 0)
           );
           pollUntilResponse();
           assertSentFetchPartitionResponse(Errors.NONE, currentEpoch(), 
localId);
       }
   
       pollUntil(() -> 
OptionalLong.of(localLogEndOffset).equals(client.highWatermark()));
   }
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to