use of org.apache.kafka.common.requests.OffsetCommitResponse in project kafka by apache.
the class KafkaConsumerTest method testLeaveGroupTimeout.
@Test
public void testLeaveGroupTimeout() throws Exception {
Map<TopicPartition, Errors> response = new HashMap<>();
response.put(tp0, Errors.NONE);
OffsetCommitResponse commitResponse = offsetCommitResponse(response);
consumerCloseTest(5000, Arrays.asList(commitResponse), 5000, false);
}
use of org.apache.kafka.common.requests.OffsetCommitResponse in project kafka by apache.
the class KafkaConsumerTest method testGracefulClose.
@Test
public void testGracefulClose() throws Exception {
Map<TopicPartition, Errors> response = new HashMap<>();
response.put(tp0, Errors.NONE);
OffsetCommitResponse commitResponse = offsetCommitResponse(response);
LeaveGroupResponse leaveGroupResponse = new LeaveGroupResponse(Errors.NONE);
consumerCloseTest(5000, Arrays.asList(commitResponse, leaveGroupResponse), 0, false);
}
use of org.apache.kafka.common.requests.OffsetCommitResponse in project kafka by apache.
the class ConsumerCoordinatorTest method gracefulCloseTest.
private void gracefulCloseTest(ConsumerCoordinator coordinator, boolean dynamicAssignment) throws Exception {
final AtomicBoolean commitRequested = new AtomicBoolean();
final AtomicBoolean leaveGroupRequested = new AtomicBoolean();
client.prepareResponse(new MockClient.RequestMatcher() {
@Override
public boolean matches(AbstractRequest body) {
commitRequested.set(true);
OffsetCommitRequest commitRequest = (OffsetCommitRequest) body;
return commitRequest.groupId().equals(groupId);
}
}, new OffsetCommitResponse(new HashMap<TopicPartition, Errors>()));
client.prepareResponse(new MockClient.RequestMatcher() {
@Override
public boolean matches(AbstractRequest body) {
leaveGroupRequested.set(true);
LeaveGroupRequest leaveRequest = (LeaveGroupRequest) body;
return leaveRequest.groupId().equals(groupId);
}
}, new LeaveGroupResponse(Errors.NONE));
coordinator.close();
assertTrue("Commit not requested", commitRequested.get());
if (dynamicAssignment)
assertTrue("Leave group not requested", leaveGroupRequested.get());
}
Aggregations