Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ public void unsubscribe() {
try {
log.debug("Unsubscribed all topics or patterns and assigned partitions");
this.subscriptions.unsubscribe();
this.coordinator.maybeLeaveGroup(false);
this.coordinator.maybeLeaveGroup();
this.metadata.needMetadataForAllTopics(false);
} finally {
release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,26 +540,26 @@ protected void coordinatorDead() {
@Override
public void close() {
client.disableWakeups();
maybeLeaveGroup(true);
maybeLeaveGroup();
}

/**
* Leave the current group and reset local generation/memberId.
*/
public void maybeLeaveGroup(boolean awaitResponse) {
public void maybeLeaveGroup() {
client.unschedule(heartbeatTask);
if (!coordinatorUnknown() && generation > 0) {
// this is a minimal effort attempt to leave the group. we do not
// attempt any resending if the request fails or times out.
sendLeaveGroupRequest(awaitResponse);
sendLeaveGroupRequest();
}

this.generation = OffsetCommitRequest.DEFAULT_GENERATION_ID;
this.memberId = JoinGroupRequest.UNKNOWN_MEMBER_ID;
rejoinNeeded = true;
}

private void sendLeaveGroupRequest(boolean awaitResponse) {
private void sendLeaveGroupRequest() {
LeaveGroupRequest request = new LeaveGroupRequest(groupId, memberId);
RequestFuture<Void> future = client.send(coordinator, ApiKeys.LEAVE_GROUP, request)
.compose(new LeaveGroupResponseHandler());
Expand All @@ -574,10 +574,7 @@ public void onFailure(RuntimeException e) {
}
});

if (awaitResponse)
client.poll(future);
else
client.poll(future, 0);
client.poll(future, 0);
}

private class LeaveGroupResponseHandler extends CoordinatorResponseHandler<LeaveGroupResponse, Void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public boolean matches(ClientRequest request) {
leaveRequest.groupId().equals(groupId);
}
}, new LeaveGroupResponse(Errors.NONE.code()).toStruct());
coordinator.maybeLeaveGroup(false);
coordinator.maybeLeaveGroup();
assertTrue(received.get());
assertEquals(JoinGroupRequest.UNKNOWN_MEMBER_ID, coordinator.memberId);
assertEquals(OffsetCommitRequest.DEFAULT_GENERATION_ID, coordinator.generation);
Expand Down Expand Up @@ -672,7 +672,7 @@ public void testCommitAfterLeaveGroup() {
// now switch to manual assignment
client.prepareResponse(new LeaveGroupResponse(Errors.NONE.code()).toStruct());
subscriptions.unsubscribe();
coordinator.maybeLeaveGroup(false);
coordinator.maybeLeaveGroup();
subscriptions.assignFromUser(Arrays.asList(tp));

// the client should not reuse generation/memberId from auto-subscribed generation
Expand Down