-
Notifications
You must be signed in to change notification settings - Fork 1
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
블로킹 큐 구현체 완성 및 테스트 작성 완료 #36
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Test : 테스트 코드 추가 1. 비동기 서비스 클래스 생성 2. 생성한 메서드에 대한 기본 테스트 작성 1. 여러 입출력 상황에 맞게 비동기 메서드 호출과 비동기 객체 병합 방법 강구
1. 메서드가 비동기 메서드인지 확인하는 테스트 작성 2. @async를 붙인 메서드가 비동기로 동자가하지 않고 하나의 쓰레드에서 동작한다.
✅ Test : 테스트 코드 추가 1. 다중 스레드 설정을 위해 taskExecutor 메서드 빈으로 저장 2. 비동기 메서드 다중 호출 시 병렬적으로 동작하는지 testGetMultiString에서 검증 3. 비동기 메서드의 지연시간이 길어질 경우 타임아웃 발생하도록 하는 부분 검증
✅ Test : 테스트 코드 추가 1. 비동기 호출을 10회 하는 비동기 메서드를 10회 호출하는 calculateRunTime 작성 2. 비동기 호출이 100회 일 때 50개는 쓰레드가 실행하고 나머지 50개는 블록킹 큐에서 대기한다.
✅ Test : 테스트 코드 추가 1. BasicCounter 구현. 멀티 쓰레드로 카운터 동시 업데이트 불가 테스트 2. SynchronizedCounter 구현. 멀티 쓰레드로 카운터 동시 업데이트 가능 테스트. Synchronized만 사용했을 때는 0.5s 소요 3. Completable 사용하면 실행시간이 대폭 감소
1. SynchronizedCounter 테스트의 실질적 실행시간을 로깅하도록 리팩토링
✅ Test : 테스트 코드 추가 1. CompletableFuture를 이용한 카운터 작성 2. 카운터에 int가 아닌 CompletableFuture<Integer>를 저장 3. 작업의 완성본을 저장하지 않고 작업 진행 중인 Future 객체를 저장하는 점에서 추후 캐싱 시나리오에 도움될 것으로 보임
# Conflicts: # src/main/java/com/thread/concurrency/counter/BasicCounter.java # src/main/java/com/thread/concurrency/counter/Counter.java
1. 컨슈머는 브로커에게서 이벤트를 가져와 처리한다. 2. 프로듀서는 브로커에게 이벤트를 저장한다. 3. 브로커는 큐를 관리하고 큐에 이벤트 삽입과 제거를 담당한다.
1. 프로듀서-컨슈머 패턴을 이용한 카운터 구현을 위해 테스트를 작성 2. 시간 측정 결과 기존 CompletableFutureCounter에 2배 시간이 걸리는 걸로 나왔다. To Do CompletableFutureCounterTest와 QueueCounterTest에 쓰이는 쓰레드 수를 같게해서 다시 시간을 측정해보기
1. 브로커를 테스트에서 제거 2. 단일한 큐를 컨슈머와 프로듀서가 공유 3. 컨슈머가 카운터를 업데이트하는 역할을 가짐 To Do 컨슈머의 consumEvent를 실행하는 스레드와 show를 호출하는 메인 스레드 간 싱크가 맞지 않는다. 모든 consumEvent가 끝나고 show를 호출할 수 있는 방법이 필요하다.
1. 아직 프로듀서-컨슈머 문제해결 못함 2. consumer가 아직 이벤트를 처리 중임을 다른 스레드가 알 수 있거나 이벤트를 전부 끝냈다는 정보를 다른 스레드가 알 수 있게할 필요가 있다.
✅ Test : 테스트 코드 추가 1. 보기 쉽게 각 테스트들 정리
1. 밴치마크 결과 Readme에 작성
1. CounterConsumer의 System.out.println을 주석하면 데드락이 걸리는 건지 테스트가 진행이 안되는 문제.,.
✅ Test : 테스트 코드 추가 1. 테스트가 진행되지 않는 이유를 찾음 프로듀서가 큐에 작업을 넣는 속도 보다 컨슈머가 작업을 처리하는 속도가 더 빠름 그렇기 때문에 전체 작업을 하기도 전에 큐가 다 비어버림 큐가 빈것을 인지한 컨슈머가 작업을 끝냄. 더 이상 작업이 진행되지 않음 To Do 프로듀서의 작업 추가 속도를 올리기 컨슈머의 작업 처리 속도를 늦추기 혹은 다 처리해도 대기하기
✅ Test : 테스트 코드 추가 1. 프로듀서-컨슈머 패턴 구현 완료 2. 요구사항인 Integer.MAX_VALUE만큼 더하기 완료 To Do 메모리 누수 때문에 메모리 덤프가 생성됨 메모리 누수의 원인을 찾고 해결해야함
✅ Test : 테스트 코드 추가 1. 프로듀서 컨슈머 pr 준비
1. 프로듀서 컨슈머 패턴 테스트 정리
# Conflicts: # src/main/java/com/thread/concurrency/counter/CompletableFutureCounter.java # src/main/java/com/thread/concurrency/counter/SynchronizedCounter.java # src/test/java/com/thread/concurrency/CounterTest.java # src/test/java/com/thread/concurrency/queueCounter/QueueCounterTest.java
# Conflicts: # README.md # src/test/java/com/thread/concurrency/counter/AtomicCounterTest.java # src/test/java/com/thread/concurrency/counter/CompletableFutureCounterTest.java # src/test/java/com/thread/concurrency/counter/CounterTest.java # src/test/java/com/thread/concurrency/counter/SynchronizedCounterTest.java
✅ Test : 테스트 코드 추가 1. 프로듀서 컨슈머의 인터페이스 작성 2. 인터페이스를 이용해 테스트 리팩토링
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #36 +/- ##
=============================================
+ Coverage 94.54% 95.36% +0.81%
- Complexity 43 55 +12
=============================================
Files 8 12 +4
Lines 110 151 +41
Branches 6 8 +2
=============================================
+ Hits 104 144 +40
Misses 2 2
- Partials 4 5 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Closed
ooMia
approved these changes
Apr 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
개요
블로킹 큐를 이용한 프로듀서-컨슈머 패턴 구현 완료
구현에 따라 Integer.MAX_VALUE를 카운팅하는 요구사항 만족
변경 사항
[x] 🤖 Refactor : 코드 리팩토링
[x] ✅ Test : 테스트 코드 추가