GitHub user seglo opened a pull request:
https://github.com/apache/kafka/pull/4216
KAFKA-5859: Avoid retaining AbstractRequest in RequestChannel.Response
This PR removes the need to keep a reference to the parsed
`AbstractRequest` after it's been handled in `KafkaApis`. A reference to
`RequestAndSize` which holds the parsed `AbstractRequest` in
`RequestChannel.Request` was kept in scope as a consequence of being passed
into the `RequestChannel.Response` after being handled.
The Jira ticket
[KAFKA-5859](https://issues.apache.org/jira/browse/KAFKA-5859) suggests
removing this reference as soon as it's no longer needed. I considered several
implementations and I settled on creating a new type that contains all the
relevant information of the Request that is required after it has been handled.
I think this approach allows for the least amount of invasive changes in the
Request/Response lifecycle while retaining the immutability of the
`RequestChannel.Request`.
A new type called `RequestChannel.RequestSummary` now contains much of the
information that was in `RequestChannel.Request` before. The
`RequestChannel.Request` now generates a `RequestChannel.RequestSummary` that
is passed into the `RequestChannel.Response` after being handled in
`KafkaApis`. `RequestChannel.RequestSummary` contains information such as:
* A detailed and non-detailed description of the request
* Metrics associated with the request
* Helper methods to update various Request metrics
* A special case describing whether or not the original Request was a
`FetchRequest` and whether it was from a follower. This information is
required in the `updateRequestMetrics` metrics helper method.
This change does not make any behaviour changes so no additional tests were
added. I've verified that all unit and integration tests pass and no
regressions were introduced. I'm interested in seeing the before and after
results of the Confluent Kafka system tests as described in step 11 of the
[Contributing Code
Changes](https://cwiki.apache.org/confluence/display/KAFKA/Contributing+Code+Changes#ContributingCodeChanges-PullRequest)
section. I would like to request access to kick off this system tests suite
if you agree that it's relevant to this ticket.
This is my first contribution to this project. I picked up this issue
because it was marked with the newbie flag and it seemed like a good
opportunity to learn more about about the request and response lifecycle in the
Kafka broker.
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/seglo/kafka to-request-summary-5859
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/kafka/pull/4216.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #4216
----
commit 9bd67ea7cf16077e20db8e1a87330176eb3772de
Author: seglo <[email protected]>
Date: 2017-11-12T02:42:55Z
Use RequestSummary in RequestChannel.Response
----
---