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

FEAT: Add random port mapping. #10

Merged
merged 1 commit into from
Jun 28, 2024
Merged

FEAT: Add random port mapping. #10

merged 1 commit into from
Jun 28, 2024

Conversation

brido4125
Copy link
Collaborator

πŸ”— Related Issue

#6 (comment)

⌨️ What I did

κ³ μ •λœ ν¬νŠΈκ°€ μ•„λ‹Œ 랜덀 포트둜 μΊμ‹œ ν΄λŸ¬μŠ€ν„°λ₯Ό κ΅¬λ™μ‹œν‚¬ 수 μžˆλ„λ‘ λ³€κ²½ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

@jhpark816
Copy link
Contributor

commit message μ˜€νƒ€ μžˆμŠ΅λ‹ˆλ‹€.

@brido4125 brido4125 changed the title FEAT: Add random port maaping. FEAT: Add random port mapping. Jun 13, 2024
Comment on lines 183 to 191
static int getPort() {
try (ServerSocket socket = new ServerSocket(0)) {
socket.setReuseAddress(true);
return socket.getLocalPort();
} catch (IOException e) {
throw new RuntimeException("memcached node port exception.", e);
}
}

Copy link
Contributor

@uhm0311 uhm0311 Jun 13, 2024

Choose a reason for hiding this comment

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

이 λ‘œμ§μ€ λ‹€λ₯Έ test-container κ΅¬ν˜„μ²΄μ—μ„œλ„ μ‚¬μš©ν•˜λŠ” λ‘œμ§μΈκ°€μš”?
λ‹€λ₯Έ κ΅¬ν˜„μ²΄μ—μ„œ κ΅¬ν˜„ν•œ 레퍼런슀 링크 μžˆλ‚˜μš”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이 λ‘œμ§μ€ λ‹€λ₯Έ test-container κ΅¬ν˜„μ²΄μ—μ„œλ„ μ‚¬μš©ν•˜λŠ” λ‘œμ§μΈκ°€μš”?

ν™•μΈν•˜μ§€ λͺ»ν–ˆμŠ΅λ‹ˆλ‹€. λ‹€λ§Œ μœ„ PRκ³Ό ν…ŒμŠ€νŠΈ μ»¨ν…Œμ΄λ„ˆμ˜ 맀핑 λͺ¨λ‘
50000λ²ˆλŒ€μ—μ„œ 주둜 μ΄λ€„μ§€λŠ”κ±Έ 보면 λ™μΌν•œ 방식을 μ‚¬μš©ν•˜μ§€ μ•Šλ‚˜ μƒκ°λ©λ‹ˆλ‹€.

λ‹€λ₯Έ κ΅¬ν˜„μ²΄μ—μ„œ κ΅¬ν˜„ν•œ 레퍼런슀 링크 μžˆλ‚˜μš”?

λ‹€λ₯Έ κ΅¬ν˜„μ²΄μ—μ„œ 직접 랜덀 포트 값을 λ¨Όμ € κ°€μ Έμ˜€λŠ” κ΅¬ν˜„μ€ 찾지 λͺ»ν–ˆμŠ΅λ‹ˆλ‹€.

Copy link
Contributor

Choose a reason for hiding this comment

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

Exception λ°œμƒ μ‹œ μ–΄λ–»κ²Œ μ²˜λ¦¬ν•˜λ‚˜ κΆκΈˆν–ˆλŠ”λ°, λ ˆνΌλŸ°μŠ€κ°€ μ—†κ΅°μš”.
Exception이 λ°œμƒν•˜λ©΄ μ œκ³΅ν•  κΈ°λ³Έ 포트λ₯Ό μ„€μ •ν•˜μ§€ μ•Šμ•„λ„ λ κΉŒμš”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

getPort() μ‹œ λ°œμƒν•˜λŠ” μ˜ˆμ™Έμ™€
Containerλ₯Ό start() ν•˜μ—¬ μ‹€μ œλ‘œ ꡬ동할 λ•Œ
λ°œμƒν•  수 μžˆλŠ” 포트 μ˜ˆμ™Έ(port already use)에 λŒ€ν•œ 처리λ₯Ό
λ™μΌν•˜κ²Œ κ°€μ Έκ°€λŠ”κ²Œ 일관적이라고 μƒκ°ν•©λ‹ˆλ‹€.

port already use λ°œμƒ μ‹œ μ˜ˆμ™ΈλŠ”
TestContainerλ‹¨μ—μ„œ catch λ˜μ–΄ μ²˜λ¦¬λ˜μ§€ μ•Šκ³  μƒμœ„ ν΄λž˜μŠ€κΉŒμ§€ throw λ©λ‹ˆλ‹€.

κ·Έλž˜μ„œ λ³„λ„μ˜ κΈ°λ³Έ 포트λ₯Ό μ‚¬μš©ν•΄μ„œ ν•˜κΈ°λ³΄λ‹€λŠ”
μ˜ˆμ™Έλ₯Ό λ˜μ Έμ„œ μ‚¬μš©μžμ—κ²Œ μ•Œλ €μ£ΌλŠ”κ²Œ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

Copy link
Member

Choose a reason for hiding this comment

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

redisμ—μ„œ 랜덀 포트λ₯Ό μ–΄λ–»κ²Œ λ§€ν•‘ν•˜λŠ”μ§€μ— λŒ€ν•œ μ½”λ“œλ₯Ό μ°Ύμ•„ μ²¨λΆ€ν•΄μ£Όμ‹œλ©΄ μ’‹κ² μŠ΅λ‹ˆλ‹€.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

redisμ—μ„œ 랜덀 포트λ₯Ό μ–΄λ–»κ²Œ λ§€ν•‘ν•˜λŠ”μ§€μ— λŒ€ν•œ μ½”λ“œλ₯Ό μ°Ύμ•„ μ²¨λΆ€ν•΄μ£Όμ‹œλ©΄ μ’‹κ² μŠ΅λ‹ˆλ‹€.

λ ˆλ””μŠ€ ν…ŒμŠ€νŠΈ μ»¨ν…Œμ΄λ„ˆ λΌμ΄λΈŒλŸ¬λ¦¬λ„ test containerμ—μ„œ μ œκ³΅ν•˜λŠ” κΈ°λŠ₯을
톡해 랜덀 포트 맀핑을 ν•˜κ³  λ³„λ„μ˜ κ΅¬ν˜„μ„ ν•˜μ§„ μ•ŠμŠ΅λ‹ˆλ‹€.

Copy link
Member

Choose a reason for hiding this comment

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

저희도 test containerμ—μ„œ μ œκ³΅ν•˜λŠ” κΈ°λŠ₯을 μ‚¬μš©ν•˜κΈ΄ μ–΄λ €μš΄κ°€μš”?
test container λ‚΄λΆ€μ—μ„œλŠ” 랜덀 포트λ₯Ό μ–΄λ–»κ²Œ μ°Ύκ³  λ§€ν•‘ν•˜λ‚˜μš”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

μœ„μ™€ 같이 λ³„λ„λ‘œ 둜직 κ΅¬μ„±ν•œ μ΄μœ λŠ” μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€.

ν…ŒμŠ€νŠΈ μ»¨ν…Œμ΄λ„ˆμ—μ„œλŠ” μ»¨ν…Œμ΄λ„ˆ 생성 μš”μ²­ ν›„, 포트λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€.
κ·Έλž˜μ„œ μ»¨ν…Œμ΄λ„ˆ 객체가 생성 된 ν›„, 포트 정보λ₯Ό κ°€μ Έμ˜¬ 수 μžˆμŠ΅λ‹ˆλ‹€.

ν•˜μ§€λ§Œ μ €ν¬λŠ” μ»¨ν…Œμ΄λ„ˆ 객체 생성 전에 할당될 포트λ₯Ό μ•Œμ•„μ•Ό
zk의 cache_server_mapping에 정보λ₯Ό λ„˜κ²¨μ€„ 수 μžˆμŠ΅λ‹ˆλ‹€.

test container λ‚΄λΆ€μ—μ„œλŠ” 랜덀 포트λ₯Ό μ–΄λ–»κ²Œ μ°Ύκ³  λ§€ν•‘ν•˜λ‚˜μš”?

μ•„λ§ˆ μ œκ°€ μ„ νƒν•œ 방식(new ServerSocket(0) μ‚¬μš©)으둜 찾을 것 κ°™λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€.
직접 μ½”λ“œλ₯Ό μ°Ύμ•„λ³΄λ €λŠ”λ° λ‚΄λΆ€ κ΅¬ν˜„μ΄ λ³΅μž‘ν•΄μ„œ μ‹œκ°„μ„ 듀이진 μ•Šμ•˜μŠ΅λ‹ˆλ‹€.

κ°™λ‹€κ³  μƒκ°ν•œ μ΄μœ λŠ” μ œκ°€ κ΅¬ν˜„ν•œ 방식과 ν…ŒμŠ€νŠΈ μ»¨ν…Œμ΄λ„ˆμ—μ„œ
ν• λ‹Ήν•˜λŠ” ν¬νŠΈλ“€μ˜ λŒ€λΆ€λΆ„ 50000λ²ˆλŒ€ 맀핑이 되기 λ•Œλ¬Έμž…λ‹ˆλ‹€.
λ˜ν•œ μœ„μ™€ 같은 방식이 μžλ°”μ—μ„œ κ°€μš© 포트λ₯Ό 찾을 λ•Œ 자주 ν™œμš©λœλ‹€κ³  ν•©λ‹ˆλ‹€.

@brido4125 brido4125 self-assigned this Jun 13, 2024
@jhpark816
Copy link
Contributor

@oliviarla
λ‚΄κ°€ λ°”λΉ μ„œ μΆ”κ°€ λ¦¬λ·°μ–΄λ‘œ μ§€μ •ν•©λ‹ˆλ‹€.

@brido4125 brido4125 requested a review from oliviarla June 18, 2024 02:03
@brido4125
Copy link
Collaborator Author

@oliviarla

리뷰 λΆ€νƒλ“œλ €μš”..

@oliviarla
Copy link
Member

@brido4125 내일 μ€‘μœΌλ‘œ 리뷰 μ™„λ£Œν•˜κ² μŠ΅λ‹ˆλ‹€!!

Copy link
Member

@oliviarla oliviarla left a comment

Choose a reason for hiding this comment

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

리뷰 μ™„λ£Œμž…λ‹ˆλ‹€.

Comment on lines 183 to 191
static int getPort() {
try (ServerSocket socket = new ServerSocket(0)) {
socket.setReuseAddress(true);
return socket.getLocalPort();
} catch (IOException e) {
throw new RuntimeException("memcached node port exception.", e);
}
}

Copy link
Member

Choose a reason for hiding this comment

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

redisμ—μ„œ 랜덀 포트λ₯Ό μ–΄λ–»κ²Œ λ§€ν•‘ν•˜λŠ”μ§€μ— λŒ€ν•œ μ½”λ“œλ₯Ό μ°Ύμ•„ μ²¨λΆ€ν•΄μ£Όμ‹œλ©΄ μ’‹κ² μŠ΅λ‹ˆλ‹€.

@jhpark816 jhpark816 merged commit f01cf16 into develop Jun 28, 2024
3 checks passed
@uhm0311 uhm0311 deleted the feat/randomPort branch July 3, 2024 10:10
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.

4 participants