Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Where does Jetty dispatch to worker thread happens.

Thanks Simone ! Also could you please confirm that the when socket connects and acceptor thread accepts the same, when does it go back to accepting new connections. Is it after registering ServerSocketChannel with selector and submitting to Selector queue (_changes.offer in SelectorManager.submit()). I assume the state in this SelectorManager.submit() in such case would be "PROCESS" and hence should come out immediately. 

 Is it ever possible that if my selectors are busy then my acceptor thread won't go back to accepting new connections?

On Friday, October 17, 2014 3:11 PM, Simone Bordet <sbordet@xxxxxxxxxxx> wrote:


On Fri, Oct 17, 2014 at 8:15 AM, Monish Gandhi <monishgandhi@xxxxxxxxx> wrote:
> I am trying to understand Jetty's Connector implementation which uses
> multiple acceptor/selectors to have non blocking implementation. I saw a
> post from Simone where its explained very clearly
> I could see the Jetty's  SelectorManager, AbstractConnector, ServerConnector
> implementing the same where we have n acceptor and m selector threads
> started. The acceptors are blocking on the ServerSocketChannels accept()
> call, each time when the socket connects, acceptor takes the socket and
> registers the channel with selector and submits the job to selector
> (ManagedSelector' ConcurrentArrayQueue) selector threads would poll the
> queue and run the changes. However i am somehow missing one thing, where is
> the actual dispatch happening to the Worker threads (the actual Server
> threads in QueuedThreadPool). Also let me know if I got some of above
> incorrectly

The dispatch happens when calling SelectChannelEndPoint.onSelected()
-> getFillInterest().fillable().
This goes back to the callback that the Connection registered with the
EndPoint, AbstractConnection.ReadCallback.
Here, the state goes (typically) from FILL_INTERESTED to FILLING, and
AbstractConnection.FillingState is where the dispatch happens, calling
Connection.onFillable() in the dispatched thread.

Simone Bordet
Developer advice, training, services and support
from the Jetty & CometD experts.
Intalio, the modern way to build business applications.

Back to the top