-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-12369; Implement ListTransactions API
#10206
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
Changes from 1 commit
14da0b2
a24b67e
c7908e7
f6181b2
f5b38d1
3bddc5f
42cee99
bbc5308
13b6ae7
e210e76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * 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.ListTransactionsRequestData; | ||
| import org.apache.kafka.common.message.ListTransactionsResponseData; | ||
| 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 ListTransactionsRequest extends AbstractRequest { | ||
| public static class Builder extends AbstractRequest.Builder<ListTransactionsRequest> { | ||
| public final ListTransactionsRequestData data; | ||
|
|
||
| public Builder(ListTransactionsRequestData data) { | ||
| super(ApiKeys.LIST_TRANSACTIONS); | ||
| this.data = data; | ||
| } | ||
|
|
||
| @Override | ||
| public ListTransactionsRequest build(short version) { | ||
| return new ListTransactionsRequest(data, version); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return data.toString(); | ||
| } | ||
| } | ||
|
|
||
| private final ListTransactionsRequestData data; | ||
|
|
||
| private ListTransactionsRequest(ListTransactionsRequestData data, short version) { | ||
| super(ApiKeys.LIST_TRANSACTIONS, version); | ||
| this.data = data; | ||
| } | ||
|
|
||
| public ListTransactionsRequestData data() { | ||
| return data; | ||
| } | ||
|
|
||
| @Override | ||
| public ListTransactionsResponse getErrorResponse(int throttleTimeMs, Throwable e) { | ||
| Errors error = Errors.forException(e); | ||
| ListTransactionsResponseData response = new ListTransactionsResponseData() | ||
| .setErrorCode(error.code()); | ||
| return new ListTransactionsResponse(response); | ||
| } | ||
|
|
||
| public static ListTransactionsRequest parse(ByteBuffer buffer, short version) { | ||
| return new ListTransactionsRequest(new ListTransactionsRequestData( | ||
| new ByteBufferAccessor(buffer), version), version); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString(boolean verbose) { | ||
| return data.toString(); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * 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.ListTransactionsResponseData; | ||
| 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.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class ListTransactionsResponse extends AbstractResponse { | ||
| private final ListTransactionsResponseData data; | ||
|
|
||
| public ListTransactionsResponse(ListTransactionsResponseData data) { | ||
| super(ApiKeys.LIST_TRANSACTIONS); | ||
| this.data = data; | ||
| } | ||
|
|
||
| public ListTransactionsResponseData data() { | ||
| return data; | ||
| } | ||
|
|
||
| @Override | ||
| public Map<Errors, Integer> errorCounts() { | ||
| Map<Errors, Integer> errorCounts = new HashMap<>(); | ||
| updateErrorCounts(errorCounts, Errors.forCode(data.errorCode())); | ||
| return errorCounts; | ||
| } | ||
|
|
||
| public static ListTransactionsResponse parse(ByteBuffer buffer, short version) { | ||
| return new ListTransactionsResponse(new ListTransactionsResponseData( | ||
| new ByteBufferAccessor(buffer), version)); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return data.toString(); | ||
| } | ||
|
|
||
| @Override | ||
| public int throttleTimeMs() { | ||
| return data.throttleTimeMs(); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // 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": 66, | ||
| "type": "request", | ||
| "listeners": ["zkBroker", "broker"], | ||
| "name": "ListTransactionsRequest", | ||
| "validVersions": "0", | ||
| "flexibleVersions": "0+", | ||
| "fields": [ | ||
| { "name": "StatesFilter", "type": "[]string", "versions": "0+", | ||
| "about": "The transaction states to filter by: if empty, all transactions are returned; if non-empty, then only transactions matching one of the filtered states will be returned" | ||
| }, | ||
| { "name": "ProducerIdFilter", "type": "[]int64", "versions": "0+", | ||
| "about": "The producerIds to filter by: if empty, no transactions will be returned; if non-empty, only transactions which match one of the filtered producerIds will be returned" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, my bad. On a side note, do you think it would be clearer if we used
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
it should be fine in this case. However, the |
||
| } | ||
| ] | ||
| } | ||
| 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": 66, | ||
| "type": "response", | ||
| "name": "ListTransactionsResponse", | ||
| "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+" }, | ||
| { "name": "TransactionStates", "type": "[]TransactionState", "versions": "0+", "fields": [ | ||
| { "name": "TransactionalId", "type": "string", "versions": "0+", "entityType": "transactionalId" }, | ||
| { "name": "ProducerId", "type": "int64", "versions": "0+", "entityType": "producerId" }, | ||
| { "name": "TransactionState", "type": "string", "versions": "0+" } | ||
|
hachikuji marked this conversation as resolved.
Outdated
|
||
| ]} | ||
| ] | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.