cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <ning.ji...@iona.com>
Subject Re: Port HttpTransport from Jetty5 toJetty6
Date Thu, 14 Dec 2006 06:19:18 GMT
Hi

Just do a quick look at the AsyncWeb[1] and Jetty's code try to get to 
know the AsyncWeb's break point.
These two projects are based on Java NIO now. As Eoghan has said, 
AsyncWeb privdes a non-blocking behaviour throughout.
I digged out the Jetty's code ,  and found the 
HTTPRequest.getInputStream().read() provide the two types reading (block 
and no-block).
 
        public int read(byte[] b, int off, int len) throws IOException
        {
            int l=-1;
            if (blockForContent())
                l= _content.get(b, off, len);
            return l;
        }
       
        private boolean blockForContent() throws IOException
        {
            if (_content.length()>0)
                return true;
            if (_parser.isState(HttpParser.STATE_END))
                return false;
           
            // Handle simple end points.
            if (_endp==null)
                _parser.parseNext();
           
            // Handle blocking end points
            else if (_endp.isBlocking())
            {
                try
                {
                    long filled=_parser.parseNext();

                    // parse until some progress is made (or IOException 
thrown for timeout)
                    while(_content.length() == 0 && filled!=0 && 
!_parser.isState(HttpParser.STATE_END))
                    {
                        // Try to get more _parser._content
                        filled=_parser.parseNext();
                    }
                }
                catch(IOException e)
                {
                    _endp.close();
                    throw e;
                }
            }
            // Handle non-blocking end point
            else
            {
                _parser.parseNext();
               
                // parse until some progress is made (or IOException 
thrown for timeout)
                while(_content.length() == 0 && 
!_parser.isState(HttpParser.STATE_END))
                {
                    if (!_endp.blockReadable(_maxIdleTime))
                    {
                        _endp.close();
                        throw new EofException("timeout");
                    }

                    // Try to get more _parser._content
                    _parser.parseNext();
                }
            }
           
            return _content.length()>0;
        }      
I think we can still base on Jetty6 for http transport now :).  
I also found some interesting things about Web2.0 which Jetty can 
provide [1].
There are also some useful links about the Asynchronouse Servlet API [2] 
[3] from Jetty guy's blog.

Sure, before I commit the porting code, I will give your guys the 
performance test result.    
Cheers,
Willem.

[1] http://www.webtide.com/downloads/whitePaperAjaxJetty.html
[2] http://blogs.webtide.com/gregw/2006/05/18/1147978560000.html
[3] http://blogs.webtide.com/gregw/2006/07/25/1153845234453.html

Glynn, Eoghan wrote:

>It depends on whether Jetty6 provides a truly asynchronous API for
>processing incoming HTTP requests.
>
>In any case, I don't know if Jetty6 provides a non-blocking API
>throughout (e.g. whether HTTPRequest.getInputStream().read() is
>non-blocking). If it does, then we'd have the tools to fully address
>CXF-228. Otherwise we'd need to look at something like AsyncWeb[1].
>
>Cheers,
>Eoghan
>
>[1] http://docs.safehaus.org/display/ASYNCWEB/Home
>
>  
>
>>-----Original Message-----
>>From: Bozhong Lin [mailto:blin@iona.com] 
>>Sent: 13 December 2006 10:40
>>To: cxf-dev@incubator.apache.org
>>Subject: Re: Port HttpTransport from Jetty5 toJetty6
>>
>>Willem,
>>
>>Does this mean that ApacheCXF will get asynchronous HTTP 
>>support [1] automatically by doing this porting? Will porting 
>>have any performance implication to Apache CXF? If so, it 
>>might be a good idea to measure performance before we commit 
>>any porting code.
>>
>>Regards,
>>Bo
>>
>>[1] https://issues.apache.org/jira/browse/CXF-228
>>
>>Willem Jiang wrote:
>>    
>>
>>>Hi ,
>>>Since Jetty6 provides NIO support, I'd like to port the 
>>>      
>>>
>>HttpTransport 
>>    
>>
>>>from Jetty5 to Jetty6 [1].
>>>
>>>I just went through the http code, here is something that I just 
>>>figured out.
>>>Please point out if I am wrong.
>>>
>>>Porting
>>>1. In HttpTransport the mainly class related with Jetty5 is 
>>>JettyHTTPServerEngine, JettyHttpDestination, JettySslListenerFactory
>>>
>>>2. Replace the Jetty5 class with Jetty6
>>>Jetty 5                                       Jetty 6
>>>SocketListener                      SelectChannelConnector
>>>SslListener                            SSLSelectChannelConnector
>>>HttpHandler                          Handler
>>>HttpContext                          ContextHandler
>>>
>>>[1]
>>>
>>>      
>>>
>>http://docs.codehaus.org/display/JETTY/Porting+from+jetty5.x+to+jetty6
>>    
>>
>>>Cheers,
>>>Willem.
>>>      
>>>
>
>  
>


Mime
View raw message