« Return to Thread: [Community Feedback] Grizzly 2.0
Hi,Hi Alexey,finally I have some time to start talking about Grizzly 2.0, and gather community feedback :)
I specifically tend to give very meaningful & intuitive names for any new classes or interfaces. I agree with you on the existing controller and it's removal. The new "Transport" seems a good candidate. But, could the name be 'GrizzlyTransportManager' ? A typical transport is just a vehicle to provide a mode of transportation (of bits). So, the abstraction 'Transport' here with start, stop, pause does not really click with other developers when they encounter this class or it's api.
Main target for Grizzly 2.0 is improving Grizzly low level API, mostly it's grizzly-framework module.Grizzly 1.5+ was our first attempt to move HTTP oriented Grizzly framework, which was embedded to GlassFishV2, to separate project, remove HTTP dependancy, implement client side support and finally have good performed, extensible NIO framework. IMHO we did good work, which is confirmed by number of projects Grizzly is used in. However quite often we got feedback, that our API is not clear, difficult to use (because of following backwards compatibility with existing HTTP API, our mistakes... etc), especially for smaller projects, where people don't want to spend much time on performance optimization etc, but mostly interested in getting nice, simple high level API, which will hide all the NIO complexity.
So with Grizzly 2.0, we want provide new framework API, which will count with Grizzly 1.5+ experience we got, plus we will not be limited with backwards compatibility anymore.
Here is high level class diagram of Grizzly 2.0 [1] , which I propose, but for sure all of you are more than welcome to propose changes, improvements, etc.
For those, who used Grizzly 1.5+ API, this first Grizzly 2.0 propose looks similar, however there are several changes:
1) No Controller, Transport comesFrom Grizzly 1.5+ API I came to opinion, that attempts to unify protocol logic (for ex. TCP & UDP) didn't simplify things, but made them more difficult and less effective.Controller was the part of that unification, but in practice, Controller mostly was used just to start/stop Grizzly, other Controller's API become redundant.So instead of Controller API, which tried to unify transport logic, I propose Transport API, which is implementation of one single transport like TCP, UDP; and will have logic just for one specific transport.
Agree. No comments. :-)
2) Transport <-> SelectorHandler, SelectionKeyHandlerTransport <-> SelectorHandler have 1:1 relationshipTransport <-> SelectionKeyHandler have 1:1 relationship
I agree with drawbacks. I didn't like the cloning in the first place. :-)
In Grizzly 1.5+ SelectorHandler <-> SelectionKeyHandler has many-to-many relationship, which caused a lot of issues, we tried to fix that advising to use just 1:1 relationship without API change... in Grizzly 2.0 I propose to implement just possibility of 1:1 relationship to avoid problems we had before.
3) Multiple Selectors read threadsIn Grizzly 1.5+ we implemented multiple Selectors read threads by using ReadControllers, which in its case were copies of main Controller.ReadControllers implementation, IMHO, had several drawbacks:a) Making Controller clones and their control.Cloning Controller means cloning controller's artifacts like SelectorHandlers, SelectionKeyHandlers, state attributes etc. But cloning itself is not big problem, bigger problem is to keep
copies and original synchronized, which caused a lot of issues.
b) UDP?
As we talked before, Controller was an envelope over protocols, which tried to unify their usage. But "multiple Selectors read thread" implementation can work just for TCP. So,there is no reason to have it in a Controller and perform redundant clone/copy operation with UDP artifacts, which could be there also.
What does a NIOConnectionDistributor do ? The name tells me that, it would help in registering and deregistering a channel with a given selector. But, then it's relation should be with a Selector/SelectorRunner than with the transport here. Basically, I think, I'm missing some relationships in the class diagram here.
For Grizzly 2.0 I propose to move "multiple read threads" logic under transport, to let them implement their own logic, how they can distribute processing Channels among several Selectors (Threads) (see NIOConnectionDistributor, SelectorHandlerRunner).
We need to discuss this (=how we process events) at length; since we are starting afresh, in this area for Grizzly 2.0
4) Improve SelectionKey events processing
The challenge to me was, the way controller was executing the filter chain in the current Grizzly. The new proposal looks good to me. (lines: regardless of channel type: client or server). Does that mean, say if my app. is interested in a particular event, and uses a callbackhandler; can it still executes filters too? Is the otherway possible too?In Grizzly 2.0 each transport will have EventProcessorSelector, which will be able to add/modify EventProcessor(s) chain, which will process event occurred on a channel.For example EventProcessorSelector could decide to let FilterChain to process all incoming SelectionKey events, regardless of channel type: client or server.Currently in Grizzly 2.0 there are 2 EventProcessor implementations: FilterChain, CallbackHandler.
These are original 2.0 changes I can propose.Will appreciate your feedback and contributions!
Thanks.
WBR,Alexey.
« Return to Thread: [Community Feedback] Grizzly 2.0
| Free embeddable forum powered by Nabble | Forum Help |