Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
magnus-larsson committed Oct 21, 2014
1 parent b12ef5b commit ce5ce1b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 37 deletions.
@@ -1,5 +1,8 @@
server.port = 9090
servlet.container.maxThreads=50

#THE DEFAULT VALUE FOT THREAD POOL SIZE IN TOMCAT
servlet.container.maxThreads=200
#servlet.container.maxThreads=50 FOR NON-BLOCKING TESTS
#servlet.container.maxThreads=500 FOR BLOCKING TESTS

statistics.requestsPerLog=5000
Expand Down
2 changes: 1 addition & 1 deletion spring-mvc-asynch-teststub/src/main/resources/logback.xml
Expand Up @@ -15,7 +15,7 @@
</encoder>
</appender>

<logger name="se.callista.springmvc.asynch.teststub" level="DEBUG"/>
<logger name="se.callista.springmvc.asynch.teststub" level="INFO"/>

<root level="INFO">
<appender-ref ref="stdout"/>
Expand Down
Expand Up @@ -86,7 +86,7 @@ public void logExceptionNonBlocking(Throwable t) {

public void logLeaveThreadNonBlocking() {

long concReqs = concurrentRequests.getAndDecrement();
long concReqs = concurrentRequests.get();

log.debug("{}: Processing of non-blocking {} request #{}, leave the request thread", concReqs, name, reqId);
}
Expand Down
7 changes: 6 additions & 1 deletion spring-mvc-asynch/src/main/resources/application.properties
@@ -1,5 +1,10 @@
server.port=9080
servlet.container.maxThreads=50


#THE DEFAULT VALUE FOT THREAD POOL SIZE IN TOMCAT
servlet.container.maxThreads=200
#servlet.container.maxThreads=50 FOR NON-BLOCKING TESTS
#servlet.container.maxThreads=500 FOR BLOCKING TESTS

threadPool.db.init_size=5
threadPool.db.max_size=50
Expand Down
2 changes: 1 addition & 1 deletion spring-mvc-asynch/src/main/resources/logback.xml
Expand Up @@ -15,7 +15,7 @@
</encoder>
</appender>

<logger name="se.callista.springmvc.asynch" level="DEBUG"/>
<logger name="se.callista.springmvc.asynch" level="INFO"/>

<root level="INFO">
<appender-ref ref="stdout"/>
Expand Down
Expand Up @@ -47,7 +47,8 @@ public void setup(){

@Test
public void testRouterBlocking() throws Exception{
this.mockMvc.perform(get("/router-blocking?minMs=2000&maxMs=2000"))
String url = "/router-blocking?minMs=2000&maxMs=2000";
this.mockMvc.perform(get(url))
.andExpect(status().isOk())
.andExpect(content().contentType("text/plain;charset=ISO-8859-1"))
.andExpect(content().string(expectedResult));
Expand All @@ -56,53 +57,34 @@ public void testRouterBlocking() throws Exception{
@Test
public void testRouterNonBlockingCallback() throws Exception {

MvcResult mvcResult = this.mockMvc.perform(get("/router-non-blocking-callback?minMs=2000&maxMs=2000"))
.andExpect(request().asyncStarted())
.andReturn();

mvcResult.getAsyncResult();

this.mockMvc.perform(asyncDispatch(mvcResult))
.andExpect(status().isOk())
.andExpect(content().contentType("text/plain;charset=ISO-8859-1"))
.andExpect(content().string(expectedResult));
String url = "/router-non-blocking-callback?minMs=2000&maxMs=2000";
testNonBlocking(url);
}

@Test
public void testRouterNonBlockingAnonymous() throws Exception {

MvcResult mvcResult = this.mockMvc.perform(get("/router-non-blocking-anonymous?minMs=2000&maxMs=2000"))
.andExpect(request().asyncStarted())
.andReturn();

mvcResult.getAsyncResult();

this.mockMvc.perform(asyncDispatch(mvcResult))
.andExpect(status().isOk())
.andExpect(content().contentType("text/plain;charset=ISO-8859-1"))
.andExpect(content().string(expectedResult));
String url = "/router-non-blocking-anonymous?minMs=2000&maxMs=2000";
testNonBlocking(url);
}

@Test
public void testRouterNonBlockingLambda() throws Exception {

MvcResult mvcResult = this.mockMvc.perform(get("/router-non-blocking-lambda?minMs=2000&maxMs=2000"))
.andExpect(request().asyncStarted())
.andReturn();

mvcResult.getAsyncResult();

this.mockMvc.perform(asyncDispatch(mvcResult))
.andExpect(status().isOk())
.andExpect(content().contentType("text/plain;charset=ISO-8859-1"))
.andExpect(content().string(expectedResult));
String url = "/router-non-blocking-lambda?minMs=2000&maxMs=2000";
testNonBlocking(url);
}

@Test
public void testRouterNonBlockingSpring() throws Exception {

// NOTE: Today's implementation in Spring of the AsyncRestTemplate is thread-blocking and therefore doesn't scale
MvcResult mvcResult = this.mockMvc.perform(get("/router-non-blocking-anonymous?minMs=2000&maxMs=2000"))
String url = "/router-non-blocking-anonymous?minMs=2000&maxMs=2000";
testNonBlocking(url);
}

private void testNonBlocking(String url) throws Exception {
MvcResult mvcResult = this.mockMvc.perform(get(url))
.andExpect(request().asyncStarted())
.andReturn();

Expand All @@ -113,4 +95,6 @@ public void testRouterNonBlockingSpring() throws Exception {
.andExpect(content().contentType("text/plain;charset=ISO-8859-1"))
.andExpect(content().string(expectedResult));
}


}

0 comments on commit ce5ce1b

Please sign in to comment.