-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-18282: Add StreamsGroupHeartbeat RPC definitions #18227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...ts/src/main/java/org/apache/kafka/common/errors/StreamsInvalidTopologyEpochException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.common.errors; | ||
|
|
||
| public class StreamsInvalidTopologyEpochException extends ApiException { | ||
| public StreamsInvalidTopologyEpochException(String message) { | ||
| super(message); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
clients/src/main/java/org/apache/kafka/common/errors/StreamsInvalidTopologyException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.common.errors; | ||
|
|
||
| public class StreamsInvalidTopologyException extends ApiException { | ||
| public StreamsInvalidTopologyException(String message) { | ||
| super(message); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
clients/src/main/java/org/apache/kafka/common/errors/StreamsTopologyFencedException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.common.errors; | ||
|
|
||
| public class StreamsTopologyFencedException extends ApiException { | ||
| public StreamsTopologyFencedException(String message) { | ||
| super(message); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
clients/src/main/java/org/apache/kafka/common/requests/StreamsGroupHeartbeatRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.common.requests; | ||
|
|
||
| import org.apache.kafka.common.message.StreamsGroupHeartbeatRequestData; | ||
| import org.apache.kafka.common.message.StreamsGroupHeartbeatResponseData; | ||
| import org.apache.kafka.common.protocol.ApiKeys; | ||
| import org.apache.kafka.common.protocol.ByteBufferAccessor; | ||
| import org.apache.kafka.common.protocol.Errors; | ||
|
|
||
| import java.nio.ByteBuffer; | ||
|
|
||
| public class StreamsGroupHeartbeatRequest extends AbstractRequest { | ||
|
|
||
| /** | ||
| * A member epoch of <code>-1</code> means that the member wants to leave the group. | ||
| */ | ||
| public static final int LEAVE_GROUP_MEMBER_EPOCH = -1; | ||
| public static final int LEAVE_GROUP_STATIC_MEMBER_EPOCH = -2; | ||
|
|
||
| /** | ||
| * A member epoch of <code>0</code> means that the member wants to join the group. | ||
| */ | ||
| public static final int JOIN_GROUP_MEMBER_EPOCH = 0; | ||
|
|
||
| public static class Builder extends AbstractRequest.Builder<StreamsGroupHeartbeatRequest> { | ||
| private final StreamsGroupHeartbeatRequestData data; | ||
|
|
||
| public Builder(StreamsGroupHeartbeatRequestData data) { | ||
| this(data, false); | ||
| } | ||
|
|
||
| public Builder(StreamsGroupHeartbeatRequestData data, boolean enableUnstableLastVersion) { | ||
| super(ApiKeys.STREAMS_GROUP_HEARTBEAT, enableUnstableLastVersion); | ||
| this.data = data; | ||
| } | ||
|
|
||
| @Override | ||
| public StreamsGroupHeartbeatRequest build(short version) { | ||
| return new StreamsGroupHeartbeatRequest(data, version); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return data.toString(); | ||
| } | ||
| } | ||
|
|
||
| private final StreamsGroupHeartbeatRequestData data; | ||
|
|
||
| public StreamsGroupHeartbeatRequest(StreamsGroupHeartbeatRequestData data, short version) { | ||
| super(ApiKeys.STREAMS_GROUP_HEARTBEAT, version); | ||
| this.data = data; | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) { | ||
| return new StreamsGroupHeartbeatResponse( | ||
| new StreamsGroupHeartbeatResponseData() | ||
| .setThrottleTimeMs(throttleTimeMs) | ||
| .setErrorCode(Errors.forException(e).code()) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public StreamsGroupHeartbeatRequestData data() { | ||
| return data; | ||
| } | ||
|
|
||
| public static StreamsGroupHeartbeatRequest parse(ByteBuffer buffer, short version) { | ||
| return new StreamsGroupHeartbeatRequest(new StreamsGroupHeartbeatRequestData( | ||
| new ByteBufferAccessor(buffer), version), version); | ||
| } | ||
| } |
103 changes: 103 additions & 0 deletions
103
clients/src/main/java/org/apache/kafka/common/requests/StreamsGroupHeartbeatResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.common.requests; | ||
|
|
||
| import org.apache.kafka.common.message.StreamsGroupHeartbeatResponseData; | ||
| import org.apache.kafka.common.protocol.ApiKeys; | ||
| import org.apache.kafka.common.protocol.ByteBufferAccessor; | ||
| import org.apache.kafka.common.protocol.Errors; | ||
|
|
||
| import java.nio.ByteBuffer; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Possible error codes. | ||
| * | ||
| * - {@link Errors#GROUP_AUTHORIZATION_FAILED} | ||
| * - {@link Errors#NOT_COORDINATOR} | ||
| * - {@link Errors#COORDINATOR_NOT_AVAILABLE} | ||
| * - {@link Errors#COORDINATOR_LOAD_IN_PROGRESS} | ||
| * - {@link Errors#INVALID_REQUEST} | ||
| * - {@link Errors#UNKNOWN_MEMBER_ID} | ||
| * - {@link Errors#FENCED_MEMBER_EPOCH} | ||
| * - {@link Errors#UNRELEASED_INSTANCE_ID} | ||
| * - {@link Errors#GROUP_MAX_SIZE_REACHED} | ||
| * - {@link Errors#GROUP_ID_NOT_FOUND} | ||
| * - {@link Errors#TOPIC_AUTHORIZATION_FAILED} | ||
| * - {@link Errors#CLUSTER_AUTHORIZATION_FAILED} | ||
| * - {@link Errors#STREAMS_INVALID_TOPOLOGY} | ||
| * - {@link Errors#STREAMS_INVALID_TOPOLOGY_EPOCH} | ||
| * - {@link Errors#STREAMS_TOPOLOGY_FENCED} | ||
| */ | ||
| public class StreamsGroupHeartbeatResponse extends AbstractResponse { | ||
| private final StreamsGroupHeartbeatResponseData data; | ||
|
|
||
| public StreamsGroupHeartbeatResponse(StreamsGroupHeartbeatResponseData data) { | ||
| super(ApiKeys.STREAMS_GROUP_HEARTBEAT); | ||
| this.data = data; | ||
| } | ||
|
|
||
| @Override | ||
| public StreamsGroupHeartbeatResponseData data() { | ||
| return data; | ||
| } | ||
|
|
||
| @Override | ||
| public Map<Errors, Integer> errorCounts() { | ||
| return Collections.singletonMap(Errors.forCode(data.errorCode()), 1); | ||
| } | ||
|
|
||
| @Override | ||
| public int throttleTimeMs() { | ||
| return data.throttleTimeMs(); | ||
| } | ||
|
|
||
| @Override | ||
| public void maybeSetThrottleTimeMs(int throttleTimeMs) { | ||
| data.setThrottleTimeMs(throttleTimeMs); | ||
| } | ||
|
|
||
| public static StreamsGroupHeartbeatResponse parse(ByteBuffer buffer, short version) { | ||
| return new StreamsGroupHeartbeatResponse(new StreamsGroupHeartbeatResponseData( | ||
| new ByteBufferAccessor(buffer), version)); | ||
| } | ||
|
|
||
| public enum Status { | ||
| STALE_TOPOLOGY((byte) 0, "The topology epoch supplied is inconsistent with the topology for this streams group."), | ||
| MISSING_SOURCE_TOPICS((byte) 1, "One or more source topics are missing or a source topic regex resolves to zero topics."), | ||
| INCORRECTLY_PARTITIONED_TOPICS((byte) 2, "One or more topics expected to be copartitioned are not copartitioned."), | ||
| MISSING_INTERNAL_TOPICS((byte) 3, "One or more internal topics are missing."), | ||
| SHUTDOWN_APPLICATION((byte) 4, "A client requested the shutdown of the whole application."); | ||
|
|
||
| private final byte code; | ||
| private final String message; | ||
|
|
||
| Status(final byte code, final String message) { | ||
| this.code = code; | ||
| this.message = message; | ||
| } | ||
|
|
||
| public byte code() { | ||
| return code; | ||
| } | ||
|
|
||
| public String message() { | ||
| return message; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the KIP, we also have the following errors that are not in this list:
GROUP_ID_NOT_FOUNDTOPIC_AUTHORIZATION_FAILEDCLUSTER_AUTHORIZATION_FAILEDIn this list, the following errors are not in the KIP:
UNSUPPORTED_ASSIGNORThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done