users@grizzly.java.net

Re: Java New I/O, Multiplexing and Mixing/Splitting of Channels

From: charlie hunt <charlie.hunt_at_sun.com>
Date: Wed, 05 Dec 2007 13:39:44 -0600

Example source code how to use Grizzly transport can be found in the
unit test cases. There's also some examples in the presentations on the
home page of Project Grizzly (http://grizzly.dev.java.net). I have to
admit that this is an area where we don't have the best artifacts to offer.

To dynamically duplicate a stream, in a handler which you would
implement you would need need to send the same stream of bytes to some
additional destination which would be a piece of information you'd have
supply to the handler.

The multi-plexing I am talking about is the multi-plexing of multiple
clients sharing the same connection (SocketChannel). Again, it's the
protocol that dictates whether the bytes being transfered are
multiplexed. This is something we call a multiplexed protocol versus
HTTP which is a simplex protocol. If you want to see an example of a
multiplex protocl you can look at GlassFish CORBA,
(http://glassfish-corba.dev.java.net). Although GlassFish CORBA is
currently not using Grizzly's transport, work is under way to migrate to
using.

So, the multiplexing and de-multiplexing is something you will have to
build on top of Grizzly.

hths,

charlie ..

Miroslav Nachev wrote:
> Yes, at the moment I am looking just for transport layer (bytes is
> enough). Are there any examples how this can be done?
>
> How dynamically one stream (channel) can be duplicated? Or it is not
> possible this to be done dynamically?
>
> Are there another examples for multiplexing and de-multiplexing? I
> suppose that is possible this to be done dynamically.
>
>
> Miro.
>
>
> On 12/5/07, * charlie hunt* <charlie.hunt_at_sun.com
> <mailto:charlie.hunt_at_sun.com>> wrote:
>
> Miro,
>
> The implementation details of what you want to do in the 2 use
> cases you
> describe is something you would implement.
>
> Grizzly (framework) is a transport and is intended to be protocol
> specific.
>
> In your first use case, you would implement a handler of some kind to
> handle the "start recording" stimulus and begin to duplicate the
> stream
> of bytes coming through the Grizzly transport. Grizzly only sees a
> stream of bytes.
>
> In the second use case, Grizzly has the ability to multiplex multiple
> clients across the same physical connection. But, again grizzly only
> sees a bytes stream at the connection. It's up to an implementor
> of a
> ProtocolParser to take the stream of bytes and parse them into
> meaningful message along with using ProtocolFilters executing in a
> ProtocolChain to process those messages.
>
> So, yes at the transport level Grizzly can do this. You will need to
> provide the protocol implementation details.
>
> Btw, if you wanted the transfer of bytes to be secure, you could use
> Grizzly's SSL. Again, Grizzly only sees a stream of bytes and it can
> put that stream in SSL.
>
> hths,
>
> charlie ...
>
> Miroslav Nachev wrote:
> > OK. May I ask another question. Let's forget for Real-Time and focus
> > on splitting one channel to many channels and vice versa. This
> is very
> > useful for both cases:
> > - In one telephone conversation for some reason one of the party
> > decide to start recording the conversation. In this case the channel
> > must be splited on 2 channels.
> > - In voice conferences there are many parties and each channel
> must be
> > mixed and splited to the other channels.
> >
> > Is it possible this to be done using Grizzly?
> >
> >
> > Miro.
> >
> >
> > charlie hunt wrote:
> >> Sailfin project is a good example of a pause time constraint
> >> application which uses Grizzly.
> >>
> >> On MINA ... it is a good general purpose NIO based framework.
> >> Grizzly in contrast to MINA focuses on performance and scalability
> >> first where I'd claim MINA's emphasis is more so on a general
> purpose
> >> framework. Also, at the URL I posted below you'll see a
> comparison
> >> of AsyncWeb running on top of Grizzly versus MINA. You can look at
> >> the slides and draw your own conclusion(s).
> >>
> >> It has been a little while since I last looked at javolution's
> >> library. So, I don't think I can fairly comment on its current
> >> performance versus what's available in JDK 6 (or JDK 5) SE class
> >> libraries or via Grizzly.
> >>
> >> charlie ...
> >>
> >> Xasima Xirohata wrote:
> >>> Miro, If you need time-deterministic utility classes, but
> don't want
> >>> to fully migrate to Sun's Real Time Java, then
> >>> you may try the http://javolution.org/ library. If you want
> to find
> >>> the other possible place to try out the NIO-related classes, than
> >>> check http://mina.apache.org/ project. I suspect that you may
> have a
> >>> look to https://sailfin.dev.java.net/
> >>> < https://sailfin.dev.java.net/> project as on one of the real
> >>> project that uses grizzly, nio and that is dealt with 'work with
> >>> voice, video, audio' conference topic (I think it worth to look
> >>> although I don't know the nature of the project well) . Probably,
> >>> you have to investigate some issues related on architecture and
> >>> algorithms (besides NIO) on
> >>> http://www.highscalability.com/start-here
> >>> <http://www.highscalability.com/start-here> if you are going to
> >>> build some "useful Realtime application" mentioned by you earlier.
> >>>
> >>> If I miss something in explanation I hope someone from the list
> >>> makes some notices, fixes and add further explanations.
> >>>
> >>> On Dec 5, 2007 2:52 PM, charlie hunt <charlie.hunt_at_sun.com
> <mailto:charlie.hunt_at_sun.com>
> >>> <mailto:charlie.hunt_at_sun.com <mailto:charlie.hunt_at_sun.com>>>
> wrote:
> >>>
> >>> Miro,
> >>>
> >>> As you know, Project Grizzly is pure Java. But, Project
> Grizzly's
> >>> emphasis is on performance. Also, if you look at the JavaOne
> >>> presentation
> >>> (
> >>>
> >>>
> http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-2992&yr=2007&track=5
> <http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-2992&yr=2007&track=5>
> >>>
> >>>
> >>>
> <http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-2992&yr=2007&track=5
> <http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-2992&yr=2007&track=5>>),
> >>>
> >>> you will see that Grizzly out performs both Java based
> >>> applications and
> >>> native implementations. That presentation also provides
> many of
> >>> the
> >>> tips & tricks we applied to using Java NIO effectively to
> realize
> >>> performance and scalability.
> >>>
> >>> If you have "true" real time requirements with
> deterministic pause
> >>> times, then Java SE itself may not be able to meet those
> >>> requirements.
> >>> In that case you will either need to look at real time Java
> >>> solution
> >>> such Sun's Real Time Java or a native real time solution.
> Fwiw,
> >>> migrating Grizzly to run / work in a Sun's Real Time JVM would
> >>> probably
> >>> not be too difficult.
> >>>
> >>> hths,
> >>>
> >>> charlie ...
> >>>
> >>> Miroslav Nachev wrote:
> >>> > Hi,
> >>> >
> >>> > I am writing my question here because I can not find
> another
> >>> suitable
> >>> > Mail list where are so familiar with Java NIO and in the
> same
> >>> time
> >>> > Grizzly project is very close to my question.
> >>> >
> >>> > We try to realize in pure Java code Multiplexing and
> >>> Mixing/Splitting
> >>> > of Channels but the delay is too big and that's why we are
> >>> looking for
> >>> > some library or utility where this can be done faster
> using C
> >>> language
> >>> > and JNI. Can we use for that purposes Java NIO and how?
> Are such
> >>> > capabilities provided in Grizzly project?
> >>> >
> >>> > Some useful Real-time applications where the above
> technics are
> >>> need are:
> >>> > - Audio/Video Conferences;
> >>> > - Voice/Video Recording/Tapping;
> >>> > - Voice/Audio/Video Compression and Decompression;
> >>> > - Echo Cancellation (Line, Acoustic).
> >>> >
> >>> > Thank you in advance.
> >>> >
> >>> >
> >>> > Regards,
> >>> > Miro.
> >>> >
> >>> >
> >>>
> >>>
> ---------------------------------------------------------------------
> >>> > To unsubscribe, e-mail:
> users-unsubscribe_at_grizzly.dev.java.net
> <mailto:users-unsubscribe_at_grizzly.dev.java.net>
> >>> <mailto: users-unsubscribe_at_grizzly.dev.java.net
> <mailto:users-unsubscribe_at_grizzly.dev.java.net>>
> >>> > For additional commands, e-mail:
> users-help_at_grizzly.dev.java.net
> <mailto:users-help_at_grizzly.dev.java.net>
> >>> <mailto: users-help_at_grizzly.dev.java.net
> <mailto:users-help_at_grizzly.dev.java.net>>
> >>> >
> >>>
> >>>
> >>>
> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail:
> users-unsubscribe_at_grizzly.dev.java.net
> <mailto:users-unsubscribe_at_grizzly.dev.java.net>
> >>> <mailto: users-unsubscribe_at_grizzly.dev.java.net
> <mailto:users-unsubscribe_at_grizzly.dev.java.net>>
> >>> For additional commands, e-mail:
> users-help_at_grizzly.dev.java.net
> <mailto:users-help_at_grizzly.dev.java.net>
> >>> <mailto: users-help_at_grizzly.dev.java.net
> <mailto:users-help_at_grizzly.dev.java.net>>
> >>>
> >>>
> >>>
> >>>
> >>> --
> >>> Best regards,
> >>> ~ Xasima Xirohata ~
> >>
> >>
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> <mailto:users-unsubscribe_at_grizzly.dev.java.net>
> >> For additional commands, e-mail:
> users-help_at_grizzly.dev.java.net
> <mailto:users-help_at_grizzly.dev.java.net>
> >>
> >>
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> <mailto:users-unsubscribe_at_grizzly.dev.java.net>
> > For additional commands, e-mail: users-help_at_grizzly.dev.java.net
> <mailto:users-help_at_grizzly.dev.java.net>
> >
>
> --
>
> Charlie Hunt
> Java Performance Engineer
>
> <http://java.sun.com/docs/performance/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> <mailto:users-unsubscribe_at_grizzly.dev.java.net>
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
> <mailto:users-help_at_grizzly.dev.java.net>
>
>

-- 
Charlie Hunt
Java Performance Engineer
<http://java.sun.com/docs/performance/>