Hi Raffaele,
On 04/17/2012 02:39 PM, Raffaele Marcello wrote:
> **i'm new in Grizzly framework and i'm studying it. In my next project
> I need to develop a "TCP multiplexer", a module that accept n socket
> and forward each packet in one of m socket (output) with n>>m.
there is one sample (TunnelServer), which might be a good start for you.
http://java.net/projects/grizzly/sources/git/show/samples/framework-samples/src/main/java/org/glassfish/grizzly/samples/tunnel/
> My forwarder need to do these:
>
> * During the forward, i need to add an header(add an packet id) to
> each packet
>
You'll probably need to implement some kind of Filter to encode/decode
custom messages to/from Buffers.
See our simple GIOP example
http://java.net/projects/grizzly/sources/git/show/samples/framework-samples/src/main/java/org/glassfish/grizzly/samples/filterchain
> * manage anwers: all packet have an answer packet, so i need to
> answer to the right socket (using the packet id)
>
It's something you'll need to implement :)
> * manage permanent sockets: never close sockets
>
That's ok, by default we don't close connection.
> * manage timeouts: if i have a timeout, i need to notify it and
> manage (doing something)
>
Depends on specific requirements, you may either use Grizzly IdleFilter,
which will just detect idle connections and close them, or if you need
smarter logic - then you'll probably need to implement it yourself.
> * Performance Optimization: open socket, and high number
> transaction->thread management->memory management
>
Our TunnelServer sample is completely non-blocking and IMO there
shouldn't be any performance related issues.
> * (optional) load balance between output socket
>
It's also something you'll need to implement. Shouldn't be difficult.
> Is there a ready component that do it?
As I said there is the TunnelServer sample, which may help you.
> What can i use to develop something like this? Can you suggest some class?
>
> Which is the best way to pack it? I'm thinking about:
>
> * stand alone jar: simple and light
> * web application: i can add also web pages for management ad
> display current state (statistics)
>
Everything is doable, you can use Grizzly HttpServer API (which is
similar to Server API) to implement web interface.
http://java.net/projects/grizzly/sources/git/content/samples/http-server-samples/src/main/java/org/glassfish/grizzly/samples/httpserver/blockinghandler/BlockingHttpHandlerSample.java
> i hope that you can help me
>
We'll try :)
WBR,
Alexey.
> Thanks
>
> Raffaele
>