Skip to content
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

netty server sockets shall be configurable #3755

Merged
merged 1 commit into from
Nov 23, 2017
Merged

netty server sockets shall be configurable #3755

merged 1 commit into from
Nov 23, 2017

Conversation

xiaoshuang-lu
Copy link
Contributor

No description provided.

@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
The Linux Foundation CLA GitHub bot

1 similar comment
@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
The Linux Foundation CLA GitHub bot

* Specifies a channel option. As the underlying channel as well as network implementation may
* ignore this value applications should consider it a hint.
*/
public <T> NettyServerBuilder withOption(ChannelOption<T> option, T value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

withChildOption? These won't affect the listening socket itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, Carl. I will change the method name to withChildOption later.

@@ -403,7 +417,7 @@ protected NettyServer buildTransportServer(
}

return new NettyServer(
address, channelType, bossEventLoopGroup, workerEventLoopGroup,
address, channelType, channelOptions, bossEventLoopGroup, workerEventLoopGroup,
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be a copy of the map. If someone modifies the map later, existing servers would accidentally see the changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. How about coping the map in NettyServer constructor?

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems fine to me.

@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
The Linux Foundation CLA GitHub bot

Copy link
Contributor

@carl-mastrangelo carl-mastrangelo left a comment

Choose a reason for hiding this comment

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

Would you midn adding a test (something like starting a server with some options, and then checking from the handler the channel option is properly set?)

@ejona86 wanna take a look?

@@ -403,7 +417,7 @@ protected NettyServer buildTransportServer(
}

return new NettyServer(
address, channelType, bossEventLoopGroup, workerEventLoopGroup,
address, channelType, channelOptions, bossEventLoopGroup, workerEventLoopGroup,
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems fine to me.

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

+1 to having a simple test. Otherwise, LGTM

@@ -122,6 +129,7 @@ public int getPort() {
return ((InetSocketAddress) localAddr).getPort();
}

@SuppressWarnings("unchecked")
Copy link
Member

Choose a reason for hiding this comment

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

Instead of disabling the checking for the entire (large) method, make a temporary variable to apply the annotation to:

@SuppressWarnings("unchecked")
ChannelOption<Object> key = (ChannelOption<Object>) entry.getKey();
b.childOption(key, entry.getValue());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

* Specifies a channel option. As the underlying channel as well as network implementation may
* ignore this value applications should consider it a hint.
*/
public <T> NettyServerBuilder withChildOption(ChannelOption<T> option, T value) {
Copy link
Member

Choose a reason for hiding this comment

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

Add @since 1.9.0 in the javadoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy.

@carl-mastrangelo
Copy link
Contributor

@xiaoshuang-lu You'll need to sign the CLA before we an accept this PR.

@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
The Linux Foundation CLA GitHub bot

2 similar comments
@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
The Linux Foundation CLA GitHub bot

@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
The Linux Foundation CLA GitHub bot

@xiaoshuang-lu
Copy link
Contributor Author

@carl-mastrangelo A testing case was appended to NettyServerTest.

try {
socket.connect(new InetSocketAddress("localhost", 9999), 8000);
} catch (Exception e) {
Assert.assertTrue("" + e, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

just let the exception propagate. Make the test signature a throws

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Roger.

.isEqualTo(sendBufferSize);

countDownLatch.countDown();

Copy link
Contributor

Choose a reason for hiding this comment

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

nit, if an error happens here (like an assertion fails), the test thread wont find out about it. On receiving these values you should set them in an atomic integer or something, and then check for the test thread.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

travis-ci node will overwrite receiveBufferSize and sendBufferSize?

@@ -91,4 +102,65 @@ public void getPort_notStarted() throws Exception {

assertThat(ns.getPort()).isEqualTo(-1);
}

@Test(timeout = 60000)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not use timeout here, and instead use a JUnit4 timeout rule:

@Rule public final Timeout globalTimeout = Timeout.seconds(30);

The reason is that the timeout rule works correctly when debugging / stepping through code.

Copy link
Contributor

@carl-mastrangelo carl-mastrangelo left a comment

Choose a reason for hiding this comment

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

LGTM. @ejona86 API looks fine?

@ejona86
Copy link
Member

ejona86 commented Nov 22, 2017

@carl-mastrangelo, I don't see any changes to the API since my last approval. The NettyServerBuilder.withChildOption seems fine to me.

@dapengzhang0 dapengzhang0 added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Nov 22, 2017
@kokoro-team kokoro-team removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Nov 22, 2017
@carl-mastrangelo carl-mastrangelo merged commit cdb1f54 into grpc:master Nov 23, 2017
@carl-mastrangelo
Copy link
Contributor

@xiaoshuang-lu merged, Thanks!

@carl-mastrangelo carl-mastrangelo added this to the 1.9 milestone Nov 30, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants