-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
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, |
1 similar comment
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, |
* 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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, |
There was a problem hiding this 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, |
There was a problem hiding this comment.
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.
There was a problem hiding this 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") |
There was a problem hiding this comment.
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());
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy.
@xiaoshuang-lu You'll need to sign the CLA before we an accept this PR. |
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, |
2 similar comments
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, |
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, |
@carl-mastrangelo A testing case was appended to NettyServerTest. |
try { | ||
socket.connect(new InetSocketAddress("localhost", 9999), 8000); | ||
} catch (Exception e) { | ||
Assert.assertTrue("" + e, false); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(); | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this 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?
@carl-mastrangelo, I don't see any changes to the API since my last approval. The NettyServerBuilder.withChildOption seems fine to me. |
@xiaoshuang-lu merged, Thanks! |
No description provided.