-
Notifications
You must be signed in to change notification settings - Fork 388
[4단계 - Tomcat 구현하기] 비토(오상훈) 미션 제출합니다. #687
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
Changes from all commits
fed02f6
7e91356
44fc288
d67f1c1
b3dce92
be60e71
6dce489
7720393
3a447b7
7b3e067
98f4296
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,8 @@ handlebars: | |
|
|
||
| server: | ||
| tomcat: | ||
| accept-count: 1 | ||
| max-connections: 1 | ||
| accept-count: 2 | ||
| max-connections: 2 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. max-connections는 무엇을 의미하고 이것 또한 어떤 이유로 값을 2로 설정했나요?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
사실 위의 답글에 하지만 가능한 적은 변화로 테스트가 통과되길 원해서 |
||
| threads: | ||
| min-spare: 2 | ||
| max: 2 | ||
|
Comment on lines
9
to
10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. min-spare, max 또한 설명 부탁드려요!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
| import java.io.UncheckedIOException; | ||
| import java.net.ServerSocket; | ||
| import java.net.Socket; | ||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.Executors; | ||
| import org.apache.coyote.http11.Http11Processor; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
@@ -14,16 +16,19 @@ public class Connector implements Runnable { | |
|
|
||
| private static final int DEFAULT_PORT = 8080; | ||
| private static final int DEFAULT_ACCEPT_COUNT = 100; | ||
| private static final int DEFAULT_MAX_THREADS = 250; | ||
|
|
||
| private final ServerSocket serverSocket; | ||
| private final ExecutorService executor; | ||
| private boolean stopped; | ||
|
|
||
| public Connector() { | ||
| this(DEFAULT_PORT, DEFAULT_ACCEPT_COUNT); | ||
| this(DEFAULT_PORT, DEFAULT_ACCEPT_COUNT, DEFAULT_MAX_THREADS); | ||
| } | ||
|
|
||
| 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.executor = Executors.newFixedThreadPool(maxThreads); | ||
| this.stopped = false; | ||
| } | ||
|
|
||
|
|
@@ -38,10 +43,8 @@ private ServerSocket createServerSocket(final int port, final int acceptCount) { | |
| } | ||
|
|
||
| public void start() { | ||
| var thread = new Thread(this); | ||
| thread.setDaemon(true); | ||
| thread.start(); | ||
| stopped = false; | ||
| executor.execute(this); | ||
| log.info("Web Application Server started {} port.", serverSocket.getLocalPort()); | ||
| } | ||
|
|
||
|
|
@@ -66,7 +69,7 @@ private void process(final Socket connection) { | |
| return; | ||
| } | ||
| var processor = new Http11Processor(connection); | ||
| new Thread(processor).start(); | ||
| executor.execute(processor); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지난 변경 사항이 아니라서 여기다 코멘트 남겨요!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| public void stop() { | ||
|
|
@@ -75,6 +78,8 @@ public void stop() { | |
| serverSocket.close(); | ||
| } catch (IOException e) { | ||
| log.error(e.getMessage(), e); | ||
| } finally { | ||
| executor.shutdown(); | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accept-count는 무엇이고 어떤 이유로 값을 2로 설정했나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accept-count는max-connections이상의 요청이 들어왔을 때max-connections를 초과한 수만큼 큐에 담아두는데 이때 담는 큐의 사이즈를 의미합니다!지금 다시 생각해보니 굳이 바꿀 이유가 없었네요...