Skip to content

Conversation

chunghyeon-kimm
Copy link
Contributor

@chunghyeon-kimm chunghyeon-kimm commented Dec 13, 2021

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를 이용한 직접 테스트 모두 의도한대로 작동하는 것 확인했습니다.

의견 부탁드립니다.

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.

1 participant