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

FEATURE: Add TCP connection keep-alive option. #673

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

brido4125
Copy link
Collaborator

관련 이슈

https://github.com/jam2in/arcus-works/issues/441

Motivation

기존 구현은 사용자가 TCP Keep Alive 옵션을 설정하는 인터페이스를 제공하지 않는다.
이를 ConnectionFactoryBuilder를 통해 사용자가 설정할 수 있도록 제공한다.
keepAlive의 기본 옵션은 false이다.

@brido4125 brido4125 self-assigned this Sep 13, 2023
@brido4125 brido4125 marked this pull request as draft September 13, 2023 07:23
Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

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

리뷰 완료

@@ -919,6 +922,9 @@ private void handleIO(SelectionKey sk) {
if (sk.isConnectable()) {
getLogger().info("Connection state changed for %s", qa);
final SocketChannel channel = qa.getChannel();
Socket socket = channel.socket();
socket.setTcpNoDelay(!connFactory.useNagleAlgorithm());
socket.setKeepAlive(keepAlive);
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • connFactory.getKeepAlive() 사용

connFactory.getKeepAlive() 값이 true인 경우만 socket,setKeepAlive() 호출하는 것보다, true/false 관계없이 무조건 호출하는 것이 나은 가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ConnectionFactoryBuilder 내의 arcusMigrEnabled, arcusMigrEnabled 등의 다른 property 변수와의 일관성을 위해 위와 같이 구현하였습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

tcp socket option을 설정하는 useNagleAlgorithm()와 일관성을 맞춰주세요.

@brido4125 brido4125 marked this pull request as ready for review September 13, 2023 07:41
@brido4125 brido4125 force-pushed the feature/keepAlive branch 2 times, most recently from 7784389 to 3ae1795 Compare September 13, 2023 23:53
@@ -59,6 +59,7 @@ public class ConnectionFactoryBuilder {
private boolean isDaemon = true;
private boolean shouldOptimize = false;
private boolean useNagle = false;
protected boolean keepAlive = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기만 protected인 이유가 있나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

수정하였습니다.

@Override
public boolean getKeepAlive() {
return inner.getKeepAlive();
}
Copy link
Collaborator

@uhm0311 uhm0311 Sep 14, 2023

Choose a reason for hiding this comment

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

ConnectionFactoryBuilderTest 클래스에 keepAlive 관련 테스트를 추가합시다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

추가 완료 하였습니다.

@jhpark816 jhpark816 merged commit c87a852 into naver:develop Sep 14, 2023
1 check passed
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