Search |
||
Sorry but i've toasted your petPosted by forax on February 10, 2008 at 5:00 PM PST
Introduction The idea is simple. I want to create a calendar service, like the server part of Google Calendar. I want to create a server that is able to parse a specific protocol allowing to query calendars and send a response using by example the ical format. GET mycalendar forax CAL/1.0 password: AjxHKRFkRwxx3j9lM2HMow== from: Sun Nov 6 08:49:37 1994 to: Mon Nov 7 12:34:31 1994 More formally, requests can be described by the following grammar using the Tatoo EBNF form.
? means zero or one, + means at least one and * means zero or more.
tokens:
service='GET'
uri= '([^ ])+'
user= '([a-z][A-Z])+'
protocol= 'CAL/1.0'
colon= ':'
header_key= '([^ :\r\n])+'
header_value= '[^ \r\n]([^\r\n])+'
eoln= '(\r)?\n'
blanks:
space= "( |\t)+"
productions:
start = request+
;
request = firstline 'eoln' header* 'eoln'
;
firstline = 'service' 'uri' 'user' 'protocol'
;
header = 'header_key' 'colon' 'header_value' 'eoln'
;
Now Tatoo, a parser generator we have developed is able to create a non-blocking push lexer/parser for that grammar. The semantics The semantics is specified by creating a class that inherits from ProtocolHandler. A ProtocolHandler is an object called each time a terminal is recognized (shifted) or a production is reduced. Furthermore, it provides an object that own some methods like asyncWrite() to send back data to the client or endRequest() to end the request.
public class CalendarProtocolHandler extends ProtocolHandler {
private String uri;
private String username;
private String header_key;
private String header_value;
private HashMap
Short explanation of the code above: shift(), if a specific terminal is found, decode the buffer to find its value. reduce() if we reduce a header key/value pair, store it into a map, if we readuce a request, call handle(). handle() verify the password and write a response Banzaï ! I know what you are thinking: Benchmarks So i've borrowed two DELLs (config) with ethernet Gigabit cards and a gigabit switch in my labs, plug them and play. java -server -cp classes:../../lib/tatoo-runtime.jar fr.umlv.tatoo.samples.httpserver.banzai.Main
First test: how many requests can be handled by banzai
Serving files of 4k, 8k, 16k and 32k with different numbers of concurrent connections (8, 16, 32 etc.). The value is a mean over 25 runs of 50 000 requests. Second test: comparing with the others
Serving a 4k with different concurrent connections What's next I think it's possible to integrate non blocking parsers technology directly into grizzly. Cheers »
Related Topics >>
Open JDK Comments
Comments are listed in date ascending order (oldest first)
Submitted by huntch on Mon, 2008-02-11 12:36.
+1 on sharing the Grizzly configuration. Would you be interested in participating, contributing and integrating non-blocking parsers technology into Grizzly? We would really like to have your participation. And, I'm sure OpenJDK would be interested in your patches too.
Submitted by forax on Mon, 2008-02-11 13:24.
Hi jean françois, hi charlie,
As specified on grizzly web site, I haven't written a conf, just type java -server -jar grizzly-http-webserver-1.7.1.jar Is there some hidden parameters ?
Submitted by jfarcand on Tue, 2008-02-12 10:36.
Yes :-) You might get better performance if you add: -Dcom.sun.grizzly.maxThreads=5 (default was 20, which is a bug :-)). For the kind of load you are doing, it can make a difference :-) A+
Submitted by rus3 on Mon, 2008-02-25 09:30.
Hello.
I can not understand why i can't post comment into your blog
http://weblogs.java.net/blog/forax/archive/2007/05/java_property_d.html
So i will post my comment here.
First i have to say thanks for all you done about Java properties.
And I would like to continue discussion about properties. I have something to add ))
Submitted by jfarcand on Wed, 2008-02-27 21:36.
Salut, we have found an issue with 1.7.1 when the bundle is used, which is the one you unfortunately used (significant performance regression). We released 1.7.2 which will probably changes the data (1.7.0 doesn't have the issue). Let us know :-)
|
||
|