398467 Servlet 3.1 Non Blocking IO
cleaned up test harness
This commit is contained in:
parent
f03bc398f8
commit
ce662c7ddc
|
@ -64,7 +64,7 @@ public class HttpChannelState
|
|||
IDLE, // Idle request
|
||||
DISPATCHED, // Request dispatched to filter/servlet
|
||||
ASYNCWAIT, // Suspended and parked
|
||||
ASYNCIO, // Has been scheduled
|
||||
ASYNCIO, // Has been dispatched for async IO
|
||||
COMPLETING, // Request is completable
|
||||
COMPLETED // Request is complete
|
||||
}
|
||||
|
|
|
@ -642,10 +642,12 @@ write completed - - - ASYNC READY->owp
|
|||
return false;
|
||||
}
|
||||
|
||||
// TODO write comments
|
||||
if (!_complete && _len<BufferUtil.space(_aggregate) && _len<_aggregate.capacity()/4)
|
||||
{
|
||||
BufferUtil.append(_aggregate, _b, _off, _len);
|
||||
}
|
||||
// TODO write comments
|
||||
else if (_len>0 && !_flushed)
|
||||
{
|
||||
ByteBuffer buffer=ByteBuffer.wrap(_b, _off, _len);
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.net.Socket;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.ServletException;
|
||||
|
@ -115,15 +116,9 @@ public class AsyncServletIOTest
|
|||
@Test
|
||||
public void testBigWrites() throws Exception
|
||||
{
|
||||
List<String> list=process(102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400);
|
||||
int blocked=0;
|
||||
for (String line:list)
|
||||
{
|
||||
if ("-".equals(line))
|
||||
blocked++;
|
||||
}
|
||||
|
||||
Assert.assertThat(blocked,Matchers.greaterThan(1));
|
||||
_count.set(0);
|
||||
process(102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400,102400);
|
||||
Assert.assertThat(_count.get(),Matchers.greaterThan(1));
|
||||
}
|
||||
|
||||
|
||||
|
@ -207,7 +202,8 @@ public class AsyncServletIOTest
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static AtomicInteger _count = new AtomicInteger();
|
||||
|
||||
private static class AsyncIOServlet extends HttpServlet
|
||||
{
|
||||
|
@ -225,19 +221,16 @@ public class AsyncServletIOTest
|
|||
final ServletOutputStream out = response.getOutputStream();
|
||||
out.setWriteListener(new WriteListener()
|
||||
{
|
||||
byte[] _owp="-\n".getBytes("ISO-8859-1");
|
||||
int _w=0;
|
||||
|
||||
@Override
|
||||
public void onWritePossible() throws IOException
|
||||
{
|
||||
//System.err.println("OWP");
|
||||
out.write(_owp);
|
||||
_count.incrementAndGet();
|
||||
|
||||
while (writes!=null && _w< writes.length)
|
||||
{
|
||||
if (!out.isReady())
|
||||
return;
|
||||
int write=Integer.valueOf(writes[_w++]);
|
||||
|
||||
if (write==0)
|
||||
|
@ -253,9 +246,6 @@ public class AsyncServletIOTest
|
|||
if (!out.isReady())
|
||||
return;
|
||||
}
|
||||
|
||||
if (!out.isReady())
|
||||
return;
|
||||
|
||||
//System.err.println("COMPLETE!!!");
|
||||
async.complete();
|
||||
|
|
Loading…
Reference in New Issue