-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-12620 Allocate producer ids on the controller #10504
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
mumrah
merged 23 commits into
apache:trunk
from
mumrah:kafka-12620-producer-ids-controller
May 21, 2021
Merged
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
2d4be26
Add new AllocateProducerIds RPC and support for ZK-mode
mumrah f8ef8a4
Fix ApiKeysTest throttling test
mumrah 2c80252
Actually use throttling in KafkaApis for AllocateProducerIds RPC
mumrah 8243d9c
Rely on request timeouts
mumrah fa8b4b2
Merge remote-tracking branch 'apache-github/trunk' into kafka-12620-p…
mumrah ed5df4a
Merge remote-tracking branch 'apache-github/trunk' into kafka-12620-p…
mumrah 16cc8bf
Move data class to common module.
mumrah e89c4bb
Use new ProducerIdsBlock as callback type in controller
mumrah 1861526
Clean up a few things
mumrah aede4fc
Remove unwanted whitespace
mumrah 1ff2398
Add IBP 3.0-IV0 for gating this new RPC
mumrah 1260dac
Merge remote-tracking branch 'apache-github/trunk' into kafka-12620-p…
mumrah 1915452
Ensure the broker to controller channel is shutdown
mumrah d5ceeab
Remove redundant test case
mumrah e72431b
Add per-broker override to testkit
mumrah 726ab08
Fix an integration test
mumrah 86d7d8d
Fix dependencies in KafkaServer
mumrah e88a37a
Fixed throttle integration test
mumrah 8afade4
Don't eaglery fetch first ID block when using the RPC
mumrah e37571b
More PR feedback
mumrah 437ee4b
Clean up ZK impl
mumrah 4c83cd7
Make the naming consistent
mumrah 3262171
Loosen test case
mumrah 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
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
72 changes: 72 additions & 0 deletions
72
clients/src/main/java/org/apache/kafka/common/requests/AllocateProducerIdsRequest.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,72 @@ | ||
| /* | ||
| * 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.AllocateProducerIdsRequestData; | ||
| import org.apache.kafka.common.message.AllocateProducerIdsResponseData; | ||
| 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 AllocateProducerIdsRequest extends AbstractRequest { | ||
| private final AllocateProducerIdsRequestData data; | ||
|
|
||
| public AllocateProducerIdsRequest(AllocateProducerIdsRequestData data, short version) { | ||
| super(ApiKeys.ALLOCATE_PRODUCER_IDS, version); | ||
| this.data = data; | ||
| } | ||
|
|
||
| @Override | ||
| public AbstractResponse getErrorResponse(int throttleTimeMs, Throwable e) { | ||
| return new AllocateProducerIdsResponse(new AllocateProducerIdsResponseData() | ||
| .setThrottleTimeMs(throttleTimeMs) | ||
| .setErrorCode(Errors.forException(e).code())); | ||
| } | ||
|
|
||
| @Override | ||
| public AllocateProducerIdsRequestData data() { | ||
| return data; | ||
| } | ||
|
|
||
| public static class Builder extends AbstractRequest.Builder<AllocateProducerIdsRequest> { | ||
|
|
||
| private final AllocateProducerIdsRequestData data; | ||
|
|
||
| public Builder(AllocateProducerIdsRequestData data) { | ||
| super(ApiKeys.ALLOCATE_PRODUCER_IDS); | ||
| this.data = data; | ||
| } | ||
|
|
||
| @Override | ||
| public AllocateProducerIdsRequest build(short version) { | ||
| return new AllocateProducerIdsRequest(data, version); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return data.toString(); | ||
| } | ||
| } | ||
|
|
||
| public static AllocateProducerIdsRequest parse(ByteBuffer buffer, short version) { | ||
| return new AllocateProducerIdsRequest(new AllocateProducerIdsRequestData( | ||
| new ByteBufferAccessor(buffer), version), version); | ||
| } | ||
| } |
63 changes: 63 additions & 0 deletions
63
clients/src/main/java/org/apache/kafka/common/requests/AllocateProducerIdsResponse.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,63 @@ | ||
| /* | ||
| * 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.AllocateProducerIdsResponseData; | ||
| 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; | ||
|
|
||
| public class AllocateProducerIdsResponse extends AbstractResponse { | ||
|
|
||
| private final AllocateProducerIdsResponseData data; | ||
|
|
||
| public AllocateProducerIdsResponse(AllocateProducerIdsResponseData data) { | ||
| super(ApiKeys.ALLOCATE_PRODUCER_IDS); | ||
| this.data = data; | ||
| } | ||
|
|
||
| @Override | ||
| public AllocateProducerIdsResponseData data() { | ||
| return data; | ||
| } | ||
|
|
||
| /** | ||
| * The number of each type of error in the response, including {@link Errors#NONE} and top-level errors as well as | ||
| * more specifically scoped errors (such as topic or partition-level errors). | ||
| * | ||
| * @return A count of errors. | ||
| */ | ||
| @Override | ||
| public Map<Errors, Integer> errorCounts() { | ||
| return Collections.singletonMap(Errors.forCode(data.errorCode()), 1); | ||
| } | ||
|
|
||
| @Override | ||
| public int throttleTimeMs() { | ||
| return data.throttleTimeMs(); | ||
| } | ||
|
|
||
| public static AllocateProducerIdsResponse parse(ByteBuffer buffer, short version) { | ||
| return new AllocateProducerIdsResponse(new AllocateProducerIdsResponseData( | ||
| new ByteBufferAccessor(buffer), version)); | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
clients/src/main/resources/common/message/AllocateProducerIdsRequest.json
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,29 @@ | ||
| // 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 implie | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| { | ||
| "apiKey": 67, | ||
| "type": "request", | ||
| "listeners": ["controller", "zkBroker"], | ||
| "name": "AllocateProducerIdsRequest", | ||
| "validVersions": "0", | ||
| "flexibleVersions": "0+", | ||
| "fields": [ | ||
| { "name": "BrokerId", "type": "int32", "versions": "0+", "entityType": "brokerId", | ||
| "about": "The ID of the requesting broker" }, | ||
| { "name": "BrokerEpoch", "type": "int64", "versions": "0+", "default": "-1", | ||
| "about": "The epoch of the requesting broker" } | ||
| ] | ||
| } |
32 changes: 32 additions & 0 deletions
32
clients/src/main/resources/common/message/AllocateProducerIdsResponse.json
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,32 @@ | ||
| // 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. | ||
|
|
||
| { | ||
| "apiKey": 67, | ||
| "type": "response", | ||
| "name": "AllocateProducerIdsResponse", | ||
| "validVersions": "0", | ||
| "flexibleVersions": "0+", | ||
| "fields": [ | ||
| { "name": "ThrottleTimeMs", "type": "int32", "versions": "0+", | ||
| "about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." }, | ||
| { "name": "ErrorCode", "type": "int16", "versions": "0+", | ||
| "about": "The top level response error code" }, | ||
| { "name": "ProducerIdStart", "type": "int64", "versions": "0+", | ||
| "about": "The first producer ID in this range, inclusive"}, | ||
| { "name": "ProducerIdLen", "type": "int32", "versions": "0+", | ||
| "about": "The number of producer IDs in this range"} | ||
| ] | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.