Hi Oleksiy Stashok:
Thanks for replying my mail. I will write a Filter customized for Protocols with multiple terminators.
Ming Qin
Cell Phone 858-353-2839
--- On Fri, 3/5/10, Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM> wrote:
From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Subject: Re: Grizzly 2dot0 : Smart String Filter with Multiple String Terminator Symbols
To: dev_at_grizzly.dev.java.net
Date: Friday, March 5, 2010, 9:13 AM
Hi Ming Qin,
I see your idea, in that case I guess it would make sense to create separate Filter (not SmartStringFilter) and implement that logic.
What do you think?
WBR,
Alexey.
> My intention is to pass StringFilter with a set of string paired-terminators , so StringDecoder’ parseWithTerminatinSeq can parse multiple paired-terminators which comprise a pair of starter and terminator.
>
> This feature can simplify the process of determining the ending of packet of request in certain protocol.
>
> To identify the end of http Request-Line and http-Request-header, we can apply above feature.
>
> For example: HTTP Request-Line is defined as :
> Request-Line = Method Space Request-URL Space HTTP-Version CRLF
> An example Request-Line would be:
>
> GET http://www.mailscloud.com/ HTTP/1.1
>
> GET is starter and CRLF is terminator
>
> HTTP Request-Header can be identified as
> Request-Header = HeaderName: SPACE ……CRLF AnEmptyLine CRLF
>
>
> Assuming Request-Header starting with Host header, an example Request-Header would be:
>
> Host: www.mailscloud.com[CRLF]
> Connection: close[CRLF]
> User-Agent: Web-sniffer/1.0.31 (+http://web-sniffer.net/)[CRLF]
> Accept-Encoding: gzip[CRLF]
> Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7[CRLF]
> Cache-Control: no[CRLF]
> Accept-Language: de,en;q=0.7,en-us;q=0.3[CRLF]
> Referer: http://web-sniffer.net/[CRLF]
> [CRLF]
>
> Host: is starter and CRLF AnEmptySpace CRLF is terminator
>
> HTTP might not be the best candidate to use paired-terminator StringFilter to identify the ending of packed request. Hopefully, those two examples show the usage of it.
>
>
> Below is Pseudo code implementation.
>
>
>
>
>
> TransformationResult<Buffer, String> parseWithTerminatingSeq ( AttributeStorage storage, Buffer input) {
> // set of string paired-terminator passed from StringFilter
> //StringFilter(Charset.forName("US-ASCII"), “ watchVideo|\r\n “ , //…… “listenMusic| //ABC “ )
>
> byte[] PairedTerminateBytes = StringFilter.getTerminator().getBytes();
>
> //allocating Starter from input
>
> byte[] CurrentStarter = CALL ValidateStarter (input, PariedTermniateBytes)
>
> // Get Matched Terminator by using Starter
> byte[] stringTermianteBytes = CALL RetrieveTerminator(CurrentStarter, PairedTerminateBytes )
>
>
> //Resume current implementation
> }
>
>
>
> Ming Qin
> Cell Phone 858-353-2839
>
> --- On Wed, 3/3/10, Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM> wrote:
>
> From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
> Subject: Re: Grizzly 2dot0 : Smart String Filter with Multiple String Terminator Symbols
> To: dev_at_grizzly.dev.java.net
> Date: Wednesday, March 3, 2010, 3:11 AM
>
> Hi Ming Qin,
>
> smart filters is something I didn't touch for a long time and wanted to come back to it sometime in future.
> So if you have interest to reimplement smart filters and make it working - you're welcome, will appreciate that.
>
> I'd look at SmartStringFilter as a part of SmartFilter. SmartFilter was originally intended to hide the parsing process, and make possible to serialize/deserialize POJO objects (sometimes with Java annotations help).
> So coming back to SmartStringFilter, as part of SmartFilter you can define following class:
>
> class MyCusomPacket {
> @CharSequence(terminate="\r\n")
> String a;
>
> @CharSequence(terminate="abc")
> String b;
> }
>
> and SmartFilter, using SmartStringFilter, should be able to serialize/deserialize correctly instances of MyCustomPacket class.
>
> Also, talking about SmartFilters, there is project google protobuf [1], which defines general protocol description language. It could be interesting to have Grizzly 2.0 support for that, for example Mina and Netty have it.
>
> Will appreciate your help.
>
> Thanks.
>
> WBR,
> Alexey.
>
> [1] http://code.google.com/p/protobuf/
>
> On Mar 3, 2010, at 9:06 , ming qin wrote:
>
>> Grizzly 2dot0 : Smart String Filter with Multiple String Terminator Symbols
>>
>>
>> Scenario:
>> In string-based protocol,
>> one intended string request is started with starter symbol-“ watchVideo” and ended with terminator symbol “\r#\n”,
>>
>> another intended string request is started with started symbol-“listenMusic” and ended with terminator symbol “\r&*ABC”
>>
>> Feature of SmartStringFilter
>>
>> Grizzly 2dot0’s Processor will be driven by SmartStringFiltor to constantly polling a Channel to read bytes till whole intended string request is read into memory-Grizzly CompoisteByte
>>
>> The tricky parts of above processor polling are :
>> Individual string request has unique starter and terminator symbols.
>> String requests are not flowed into server in unpredictable order.
>>
>> Proposal:
>> Can I implement above feature in Grizzly 2dot0 as
>> SmartStringFilter(Charset. Charset , String … stringStartingTerminatingSymbs );
>>
>>
>>
>> Below is my server main code to import this kind of smartStringFilter:
>>
>> public static void main(String[] args) throws IOException {
>> // Create a FilterChain using FilterChainBuilder
>> FilterChainBuilder filterChainBuilder = FilterChainBuilder.singleton();
>> // Add TransportFilter, which is responsible
>> // for reading and writing data to the connection
>> filterChainBuilder.add(new TransportFilter());
>> // StringFilter is responsible for parsing single string line
>> filterChainBuilder.add(new SmartStringFilter(Charset.forName("US-ASCII"), “ watchVideo|\r#\n “ , …… “listenMusic| r&*ABC “ ));
>>
>> ……
>> filterChainBuilder.add(new EchoFilter());
>>
>> …..
>>
>> transport.start();
>> ,,,,,,
>> ,,,,,
>>
>>
>>
>> Ming Qin
>> Cell Phone 858-353-2839
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: dev-help_at_grizzly.dev.java.net