[톰캣 구현하기 4단계] 호기(조호연) 미션 제출합니다.#728
Conversation
HyungHoKim00
left a comment
There was a problem hiding this comment.
고생하셨습니다 호기!! 요청 드린 변경사항도 많은데, 잘 적용해주신 것 같아요.
질문 남겨 놓았으니 확인해주세요~
| } | ||
| var processor = new Http11Processor(connection); | ||
| new Thread(processor).start(); | ||
| executorService.submit(() -> new Http11Processor(connection).run()); |
There was a problem hiding this comment.
| executorService.submit(() -> new Http11Processor(connection).run()); | |
| executorService.submit(new Http11Processor(connection)); |
Runnable을 인자로 받고 있어서, 위와 같이 수정해도 똑같이 동작해요~
There was a problem hiding this comment.
Future<?> 객체를 반환하는 submit() 함수를 사용하셨는데, 작업 결과를 이용하는 부분이 현재 코드에서는 없네요.
execute() 가 아닌 submit()을 선택하신 이유가 있을까요?
There was a problem hiding this comment.
ExecutorService 스팩을 보니 submit 메서드가 정의되어 있어 사용했습니다..!
깊게 찾아보지 않고 사용한것 같아요,,!
반환값이 굳이 필요하지 않다면 execute를 사용한 것이 좋아보입니다!
|
|
||
| private static final int DEFAULT_PORT = 8080; | ||
| private static final int DEFAULT_ACCEPT_COUNT = 100; | ||
| private static final int DEFAULT_MAX_THREADS = 250; |
There was a problem hiding this comment.
LMS 를 보고 따라쳤던게 끝이었던 것 같아요..!
명오 덕분에 톰켓 공식 문서에 들어가서 찾아봤습니다!
톰켓은 디폴트를 200개로 설정하고 있더라구요!
뿐만 아니라 스레드의 갯수를 어떤 지표를 보고 저울질을 해야할 까에 대한 공부를 했습니다!
cpu Bound, IO bound
| registry.addResourceHandler(PREFIX_STATIC_RESOURCES + "/" + version.getVersion() + "/**") | ||
| .addResourceLocations("classpath:/static/") | ||
| .setCacheControl(CacheControl.maxAge(Duration.ofDays(365)).cachePublic()); | ||
| .setCachePeriod(31536000) |
There was a problem hiding this comment.
setCachePeriod와 setCacheControl(CacheControl.maxAge)의 차이가 뭔가요?
There was a problem hiding this comment.
사실 동작하는 방식은 같다고 알고 있습니다!
하지만 setCachePeriod는 단순히 기간만 설정한다면
setCacheControl은 다양한 캐시 옵션을 조합할 수 있다고 알고 있습니다! (예: public/private, must-revalidate)
| accept-count: 1 | ||
| max-connections: 1 | ||
| accept-count: 0 | ||
| max-connections: 2 |
| } | ||
|
|
||
| public void matchService(HttpRequest request, HttpResponse response) throws Exception { | ||
| public void doService(HttpRequest request, HttpResponse response) throws Exception { |
There was a problem hiding this comment.
service() 라고만 작성하지 않고 do~를 붙이신 이유가 있나요?
There was a problem hiding this comment.
개인적으로는 메서드 이름이 중복 되는 것 같아 다르게 하자라는 마음밖에 없었던 것 같아요,,!
| } | ||
|
|
||
| public boolean hasCss() { | ||
| public boolean isCss() { |
There was a problem hiding this comment.
Files.probeContentType()을 사용하면 파일의 content-type을 가져올 수 있습니다. Apache Tika라는 라이브러리도 존재해요~
| body = "Hello world!"; | ||
| statusLine = new StatusLine(protocol, "200", "OK"); | ||
| httpHeader.putHeader(CONTENT_TYPE, TEXT_HTML_CHARSET_UTF_8); | ||
| statusLine = new StatusLine(protocol, Status.OK.getCode(), Status.OK.getMessage()); |
There was a problem hiding this comment.
StatusLine이 String code, String message 필드가 아닌 Status 필드로 가지고 있는 건 어떤가요?
There was a problem hiding this comment.
부랴부랴 리팩토링 하느랴 신경쓰지 못했는데 더 깔끔해진 것 같아요! 감사해요!
| @@ -26,7 +26,7 @@ public String getMethodType() { | |||
| } | |||
There was a problem hiding this comment.
method(GET, POST 등)도 enum이면 좋을 것 같아요~
| public Connector(final int port, final int acceptCount) { | ||
| public Connector(final int port, final int acceptCount, final int maxThreads) { | ||
| this.serverSocket = createServerSocket(port, acceptCount); | ||
| this.executorService = Executors.newFixedThreadPool(maxThreads); |
There was a problem hiding this comment.
ThreadPool의 종류가 여러개인데, 그 중 fixedThreadPool을 사용하신 이유가 뭔가요?
| @@ -0,0 +1,24 @@ | |||
| package org.apache.coyote.http11.response; | |||
|
|
|||
| public enum Status { | |||
HyungHoKim00
left a comment
There was a problem hiding this comment.
고생하셨습니다 호기~ 요청드린 수정사항도 잘 반영해주셔서 머지를 하려 했으나, 딱 한가지 마지막 요청사항이 존재합니다 ㅠㅠ.
빠르게 수정하실 수 있으니 수정해주시고 바로 리뷰요청 주세요~
| private final String protocol; | ||
| private final String statusCode; | ||
| private final String statusMessage; | ||
| // private final String statusCode; |




안녕하세요 명오!
4단계 구현해서 제출합니다!