Search in sources :

Example 6 with VoteResponseData

use of org.apache.kafka.common.message.VoteResponseData in project kafka by apache.

the class RaftClientTestContext method assertSentVoteResponse.

void assertSentVoteResponse(Errors error) {
    List<RaftResponse.Outbound> sentMessages = drainSentResponses(ApiKeys.VOTE);
    assertEquals(1, sentMessages.size());
    RaftMessage raftMessage = sentMessages.get(0);
    assertTrue(raftMessage.data() instanceof VoteResponseData);
    VoteResponseData response = (VoteResponseData) raftMessage.data();
    assertEquals(error, Errors.forCode(response.errorCode()));
}
Also used : VoteResponseData(org.apache.kafka.common.message.VoteResponseData)

Example 7 with VoteResponseData

use of org.apache.kafka.common.message.VoteResponseData in project kafka by apache.

the class RaftClientTestContext method expectAndGrantVotes.

void expectAndGrantVotes(int epoch) throws Exception {
    pollUntilRequest();
    List<RaftRequest.Outbound> voteRequests = collectVoteRequests(epoch, log.lastFetchedEpoch(), log.endOffset().offset);
    for (RaftRequest.Outbound request : voteRequests) {
        VoteResponseData voteResponse = voteResponse(true, Optional.empty(), epoch);
        deliverResponse(request.correlationId, request.destinationId(), voteResponse);
    }
    client.poll();
    assertElectedLeader(epoch, localIdOrThrow());
}
Also used : VoteResponseData(org.apache.kafka.common.message.VoteResponseData)

Aggregations

VoteResponseData (org.apache.kafka.common.message.VoteResponseData)7 Errors (org.apache.kafka.common.protocol.Errors)2 Test (org.junit.jupiter.api.Test)2 OptionalInt (java.util.OptionalInt)1 VoteRequestData (org.apache.kafka.common.message.VoteRequestData)1