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

[APIS-1005] Extends the loadBalance Property of JDBC. #56

Merged
merged 4 commits into from
Dec 3, 2024

Conversation

airnet73
Copy link
Contributor

@airnet73 airnet73 commented Nov 29, 2024

http://jira.cubrid.org/browse/APIS-1005

Purpose
connection url의 loadBalance property 사용방법을 확장 하였다.
기존 기능에 Round-Robin 방식을 추가함

확장후 loadBalance 사용 방법
loadBalance=true (Round-Robin 방식)
loadBalance=false (기존과 동일, loadBalance 사용안함)
loadBalance=rr (Round-Robin 방식)
loadBalance=sh (Shuffle 방식)

@airnet73 airnet73 self-assigned this Nov 29, 2024
throw e;
String loadBalValue = connProperties.getConnLoadBal();

synchronized (this) {
Copy link
Contributor

@mhoh3963 mhoh3963 Nov 29, 2024

Choose a reason for hiding this comment

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

이 구간에 synchronized 를 사용하지 말고 conn_count 함수를 증가시키는 함수를 만들고 해당 함수에만 synchronized로 하는 것이 어떨까요 ?
private synchronized int increment_conn_count() {
conn_count = conn_count+1;
if (conn_count >= Interger.MAX_VALUE) conn_count=1;
return conn_count;
}
그리고 adjustHostList() 함수에서 conn_count++ 대신 count = increment_conn_count(); 변경한 후 local 변수인 count을 이용하면 thread safety 해 보임.

혹시 UJCIManager.connect()가 thread safety 하지 않나요 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

의견 감사합니다. 의견대로 적용하겠습니다.

@airnet73 airnet73 requested a review from mhoh3963 December 2, 2024 06:36

private synchronized int increment_conn_count() {
conn_count = conn_count + 1;
return conn_count;
Copy link
Contributor

Choose a reason for hiding this comment

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

conn_count가 INT_MAX가 넘는 경우에 대해 처리가 필요해보입니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

conn_count 의 overflow에 대한 처리를 추가 했습니다.

@airnet73 airnet73 merged commit 79f6602 into CUBRID:develop Dec 3, 2024
3 checks 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