[NEX-954] Add Openstack API throttle #15
Open
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.
Add Openstack API throttle (동일한 openstack 호출은 1초에 1번으로 제한한다)
로직 설명
오픈스택 호출을 담당하는 OpenstackClient에 ConcurrentHashMap 타입의 urlCache를 필드로 선언합니다.
urlCache의 keyset에 openstack url을 캐싱합니다.
컨트롤러에 오픈스택 호출 요청이 들어오면 urlCache에 호출 url이 저장되어 있는지 확인합니다. (isTargetUrlAlreadyCached 메서드)
저장되어 있지 않으면 저장하고(updateUrlCache 메서드) 오픈스택을 호출합니다.
urlCache에 호출 url이 저장되어 있으면 오픈스택을 호출하지 않고 executeHttpRequest 메서드를 종료합니다.
(이 경우 INTERNAL_SERVER_ERROR 반환)
urlCache는 1초마다 초기화합니다. (clearUrlCache 메서드)
Junit 테스트와 swagger를 이용한 직접 테스트 모두 의도한대로 작동하는 것 확인했습니다.
의견 부탁드립니다.