[undertow-dev] Undertow and non-blocking File IO

Andrew Brampton me at bramp.net
Wed Nov 25 00:13:03 EST 2015


I just started playing with Undertow, but I had a couple of questions about
the use of non-blocking operations vs using the worker thread pool.

In the ResourceHandler.java
<https://github.com/undertow-io/undertow/blob/master/core/src/main/java/io/undertow/server/handlers/resource/ResourceHandler.java#L320>
it
appears to dispatch itself onto a worker thread, and then uses blocking
file IO to actually read the file. I'm curious why a AsynchronousFileChannel
<https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousFileChannel.html>
wasn't used to read from the file in a non-blocking way? This would be in
keeping with the non-blocking IO threads.

I wrote a quick HttpHandler that used the AsynchronousFileChannel
<https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousFileChannel.html>
and
it worked really well. However, when creating AsynchronousFileChannel
<https://docs.oracle.com/javase/7/docs/api/java/nio/channels/AsynchronousFileChannel.html>
you
have to specify the ExecutorService to be used to schedule the completion
handler callback on. I was able to use exchange.getIoThread().getWorker(),
but I'm curious if there is a way to schedule it back on the IO Threads? It
just seems "purer" keeping everything on a single IO thread per core.

thanks
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20151124/649ada98/attachment.html 


More information about the undertow-dev mailing list