Skip to content

KAFKA-2120#320

Closed
MayureshGharat wants to merge 2 commits into
apache:trunkfrom
MayureshGharat:kafka-2120-followup
Closed

KAFKA-2120#320
MayureshGharat wants to merge 2 commits into
apache:trunkfrom
MayureshGharat:kafka-2120-followup

Conversation

@MayureshGharat

Copy link
Copy Markdown
Contributor

Trivial fix to get rid of unused statements in kafkaProducer.

@eribeiro

Copy link
Copy Markdown
Contributor

@MayureshGharat There's a typo here:

* Check and may be get the time elapsed since startTime.
it's maybe, not may be ;)

Also, it would be nice to be detailed about the error by informing the value and the threshold that was violated:

throw new TimeoutException("Request timed out");

In this case, the exception is more of a side effect of this function -- and so, better to be documented in the @throws clause of the comment -- than a proper goal of this method, that is, afaik, to retrieve the remaining time.

* Throws a {@link org.apache.kafka.common.errors.TimeoutException} if the elapsed time

Finally, this checkMaybeGetRemainingTime is a mouthful of a name and mixes two duties for a single method: it checks if the threshold was violated and retrieves the value otherwise. I would suggest to rename it to checkAndGetRemainingTime or something alike, because it only "maybe" retrieves the time if the check doesn't passes so "maybe" is superfluous here, imho. Up to you.

@guozhangwang

Copy link
Copy Markdown
Contributor

Since the purpose of this PR is just a follow-up cleanup of KAFKA-2120, I am fine either addressing @eribeiro 's comments in another MINOR PR or in this PR as well if @MayureshGharat would like to do so.

@MayureshGharat

Copy link
Copy Markdown
Contributor Author

@guozhangwang I will make the change for @throw and also the threshold message in this PR. I am not sure if we should change the method name. I had discussed this with Joel and we had comeup with that name. Its little verbose but it kind of explains what might happen. Does that sound good ?

@guozhangwang

Copy link
Copy Markdown
Contributor

I am OK with the current function name too, it is up to you for how to address the comments :)

@MayureshGharat

Copy link
Copy Markdown
Contributor Author

@eribeiro
Adding the threshold is a great suggestion. I will upload a new PR for the same :)
Regarding "In this case, the exception is more of a side effect of this function -- and so, better to be documented in the @throws clause of the comment -- than a proper goal of this method, that is, afaik, to retrieve the remaining time.",
The main goal is to first check and return the value only and only if the check is valid.

As per http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html#throwstag, the purpose of the @throws tag is to indicate which exceptions the programmer must catch (for checked exceptions) or might want to catch (for unchecked exceptions). (It is considered poor programming practice to include unchecked exceptions in the throws clause.)
Also TimeoutException is a type of KafkaException, which is an unchecked exception. . Also the checkMaybeGetRemainingTime() is a private method and is only used in the Kafkaproducer.send(). so if we are throwing the TimeoutException from checkMaybeGetRemainingTime(), it will be caught in Kafkaproducer.send() as a KafkaException and rethrown to the user.

@eribeiro

Copy link
Copy Markdown
Contributor

@MayureshGharat +1 about your comments. :) After posting the comment, I ended up in the http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html page too, so I totally see the point of throws. Agree with you again. I am okay with keeping the name as-is too. No problem. :)

@asfgit asfgit closed this in 7efa127 Oct 16, 2015
@guozhangwang

Copy link
Copy Markdown
Contributor

LGTM, thanks @MayureshGharat

guozhangwang pushed a commit to guozhangwang/kafka that referenced this pull request Jun 11, 2020
apache#320)

* add individual end quorum request

* use retry backoff

* start election immediately if top on list
hachikuji pushed a commit to hachikuji/kafka that referenced this pull request Aug 5, 2020
apache#320)

* add individual end quorum request

* use retry backoff

* start election immediately if top on list
hachikuji pushed a commit to hachikuji/kafka that referenced this pull request Aug 13, 2020
apache#320)

* add individual end quorum request

* use retry backoff

* start election immediately if top on list
wyuka added a commit to wyuka/kafka that referenced this pull request May 16, 2022
…fault` and `quota.consumer.default` configurations (apache#10427)" (apache#320)

TICKET =
LI_DESCRIPTION = We currently need the quota.producer.default and quota.consumer.default in kafka-rest, and that is read from ZK node /cluster_configs. This node is written to by the kafka-server. If the config is mising, kafka-rest currently fails with an exception.
EXIT_CRITERIA = Once we have migrated Kafka server to write dynamic config to zk /cluster_configs node, or removed the check in kafka-rest for these 2 config properties, we can remove this commit.

This reverts commit ff3b2d6.
wyuka added a commit to wyuka/kafka that referenced this pull request Jun 16, 2022
…fault` and `quota.consumer.default` configurations (apache#10427)" (apache#320)

TICKET =
LI_DESCRIPTION = We currently need the quota.producer.default and quota.consumer.default in kafka-rest, and that is read from ZK node /cluster_configs. This node is written to by the kafka-server. If the config is mising, kafka-rest currently fails with an exception.
EXIT_CRITERIA = Once we have migrated Kafka server to write dynamic config to zk /cluster_configs node, or removed the check in kafka-rest for these 2 config properties, we can remove this commit.

This reverts commit ff3b2d6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants