Skip to content

[KAFKA-7379] [streams] send.buffer.bytes should be allowed to set -1 in KafkaStreams - #5643

Merged
guozhangwang merged 2 commits into
apache:trunkfrom
aai95:7379-constraint-in-StreamsConfig
Sep 20, 2018
Merged

[KAFKA-7379] [streams] send.buffer.bytes should be allowed to set -1 in KafkaStreams#5643
guozhangwang merged 2 commits into
apache:trunkfrom
aai95:7379-constraint-in-StreamsConfig

Conversation

@aai95

@aai95 aai95 commented Sep 12, 2018

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

atLeast(0) in StreamsConfig, ProducerConfig and ConsumerConfig were replaced by SEND_BUFFER_LOWER_BOUND and RECEIVE_BUFFER_LOWER_BOUND from CommonClientConfigs.

How was this patch tested?

Three unit tests were added to KafkaStreamsTest

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@aai95

aai95 commented Sep 12, 2018

Copy link
Copy Markdown
Contributor Author

@mjsax review my changes, please.
Is my understanding of the goal of this JIRA correct?

@vvcephei

Copy link
Copy Markdown
Contributor

Hey @aai95 ,
Thanks for the PR!

I think we only wanted to change the bound on send and receive buffers.

Also, can you think of some way to test this change?

Thanks,
-John

@mjsax mjsax added the streams label Sep 12, 2018
@aai95
aai95 force-pushed the 7379-constraint-in-StreamsConfig branch from 5d5dde0 to a3b0401 Compare September 13, 2018 13:09
@aai95

aai95 commented Sep 13, 2018

Copy link
Copy Markdown
Contributor Author

Hi @vvcephei,
Thank you for your remarks! I made corresponding changes.
Regarding test coverage, as I understand org.apache.kafka.clients.producer.KafkaProducerTest and
org.apache.kafka.clients.consumer.KafkaConsumerTest already contain methods testInvalidSocketSendBufferSize and testInvalidSocketReceiveBufferSize
which check these cases if send.buffer.bytes and receive.buffer.bytes become less than -1.

@mjsax

mjsax commented Sep 13, 2018

Copy link
Copy Markdown
Member

@aai95 trunk branch was broken recently -- can you please rebase this PR to pick up latest trunk that is fixed now? Otherwise, we can't get a green build. Thx.

For testing, we could add a test, but if Consumer/Producer would change the bounds, our test would not catch this anyway. Adding those parameters is basically code duplication.

If we want to improve the code, Consumer/Producer (or mabye CommonConfig) should define a public final static variable, that define the lower bound, and we could use this in all three classes. This way, if the bounds change, all are updated and we don't miss anything.

Thoughts?

@aai95
aai95 force-pushed the 7379-constraint-in-StreamsConfig branch from a3b0401 to 762b2d2 Compare September 14, 2018 11:16
@aai95

aai95 commented Sep 14, 2018

Copy link
Copy Markdown
Contributor Author

I performed rebase of my PR just to check that build passes. The test will be added.

@aai95
aai95 force-pushed the 7379-constraint-in-StreamsConfig branch from 762b2d2 to e609518 Compare September 18, 2018 12:49
@aai95

aai95 commented Sep 18, 2018

Copy link
Copy Markdown
Contributor Author

@mjsax review my changes, please.
I implemented your suggestion regarding global constants. Thanks.
In classes KafkaProducerTest and KafkaConsumerTest we have method testOsDefaultSocketBufferSizes.
Here value Selectable.USE_DEFAULT_BUFFER_SIZE is -1, as I understand this case covers my changes.
This test successfully passed before, because in ProducerConfig and ConsumerConfig we had hard-coded value -1, now we have global constant in CommonClientConfigs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guozhangwang @hachikuji I think we can do this without a KIP, but I would like to very with you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me.

@guozhangwang

Copy link
Copy Markdown
Contributor

@aai95 could you add the unit test in KafkaStreamsTest for testing the scope of this config for Streams as well? The existing tests in KafkaProducerTest / KafkaConsumerTest does not cover streams case.

@aai95
aai95 force-pushed the 7379-constraint-in-StreamsConfig branch from e609518 to ead236f Compare September 20, 2018 12:49
@aai95

aai95 commented Sep 20, 2018

Copy link
Copy Markdown
Contributor Author

@guozhangwang review my changes, please.
Three unit tests were added to KafkaStreamsTest

@guozhangwang guozhangwang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@guozhangwang

Copy link
Copy Markdown
Contributor

The jenkins failure is not relevant.

@guozhangwang
guozhangwang merged commit 7bc1019 into apache:trunk Sep 20, 2018

@mjsax mjsax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just catching up on this PR -- couple of follow up comments -- maybe worth to do a follow up PR?

One more meta comment: why did we add the test in KafkaStreamsTest but not in StreamsConfigTest? Seems to be miss placed.

props.put(CommonClientConfigs.SEND_BUFFER_CONFIG, Selectable.USE_DEFAULT_BUFFER_SIZE);
props.put(CommonClientConfigs.RECEIVE_BUFFER_CONFIG, Selectable.USE_DEFAULT_BUFFER_SIZE);
final KafkaStreams streams = new KafkaStreams(builder.build(), props);
streams.close();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just catching up on this PR. Should we wrap the close() into a finally block?

}

@Test
public void testOsDefaultSocketBufferSizes() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: naming -> shouldAcceptDefaultBufferSizes()

Also, I am wondering why we check for default buffer size? The ticket was about the issue, that -1 was not accepted. Thus, while having this test is ok, we should actually test for -1 to have a test that covers the reported issue.

public void testInvalidSocketSendBufferSize() {
props.put(CommonClientConfigs.SEND_BUFFER_CONFIG, -2);
final KafkaStreams streams = new KafkaStreams(builder.build(), props);
streams.close();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If new KafkaStreams throws, this line will never be executed (same below). Also, streams will not have any object assigned. Thus, we cannot even close anything, as the object was never created -- I think we can remove this line and also remove the variable streams.

}

@Test(expected = KafkaException.class)
public void testInvalidSocketSendBufferSize() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: -> shouldThrowForInvalidSocketSendBufferSize()

}

@Test(expected = KafkaException.class)
public void testInvalidSocketReceiveBufferSize() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: -> shouldThrowForInvalidSocketReceiveBufferSize()

pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…in KafkaStreams (apache#5643)

What changes were proposed in this pull request?
atLeast(0) in StreamsConfig, ProducerConfig and ConsumerConfig were replaced by SEND_BUFFER_LOWER_BOUND and RECEIVE_BUFFER_LOWER_BOUND from CommonClientConfigs.

How was this patch tested?
Three unit tests were added to KafkaStreamsTest

Reviewers: Guozhang Wang <guozhang@confluent.io>, John Roesler <john@confluent.io>, Matthias J. Sax <mjsax@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants