Hello all !

Well, after some rewriting (but no test up to now), I get the following
bootstraping code.
I know that it could be dizzy to help on this kind of "very long" code,
but what I am thinking is that such a code in a manual web page of Mina
could help, of course, once we correct it (since I'm sure it is not perfect).

So here it is, beginning by the server part:
// Create service
NioSocketAcceptor acceptor = new NioSocketAcceptor(myNumberOfCpuPlusOne);
// It implies "myNumberOfCpuPlusOne" IoAcceptor using an internal 
newCachedThreadPool

SocketSessionConfig socketSessionConfig = (SocketSessionConfig) 
acceptor.getSessionConfig();
socketSessionConfig.setReuseAddress(true);
//XXX VISTA BUG ? => I need to remove setSoLinger(x) and KeepAlive(true)
socketSessionConfig.setSoLinger(1);
socketSessionConfig.setKeepAlive(false); //Not sure
socketSessionConfig.setTcpNoDelay(true);
socketSessionConfig.setReceiveBufferSize(myTCPBLOCKSIZE);
socketSessionConfig.setSendBufferSize(myTCPBLOCKSIZE);
socketSessionConfig.setIdleTime(IdleStatus.BOTH_IDLE, myTIMEOUT);

// Create IoHandler (I am using an extension of DemuxingIoHandler)
MyDemuxingIoHandler myDemuxingIoHandler =  new MyDemuxingIoHandler();
// Create for each class one message handler
// MyMessage
MyMessageHandler myMessageHandler = new MyMessageHandler();
myDemuxingIoHandler.addMessageHandler(MyMessage.class, myMessageHandler);
...

// Configuration of the filter chain
DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
// Compression
CompressionFilter compression =
                new CompressionFilter(COMPRESSIONCLIENT,
                        COMPRESSIONSERVER,
                        CompressionFilter.COMPRESSION_MAX);
chain.addLast("Compression",compression);
// Serialization : I add a pool of Executor since serizalisation is not free of 
CPU and after that my protocol
// implies some extra codes (like JDBC calls)
ProtocolCodecFactory codec =  new ObjectSerializationCodecFactory();
// Was Executors.newCachedThreadPool();
ExecutorService executorSerialize = new 
OrderedThreadPoolExecutor(LSDConstants.SERVER_THREAD);
chain.addLast("SerializePool",  new ExecutorFilter(executorSerialize));
chain.addLast("Serialize", new ProtocolCodecFilter(codec));

// Set port
InetSocketAddress inetSocketAddress =  new InetSocketAddress(mySERVER_PORT);


// All together
acceptor.setLocalAddress(inetSocketAddress);
acceptor.setHandler(myDemuxingIoHandler);

// When Unbind, do not disconnect already connected client
acceptor.setDisconnectOnUnbind(false);
try {
    acceptor.bind();
} catch (IOException e) {
    myLogger.error("Cannot Bind Service "+myname, e);
    return false;
}

When shutting down:
// I use a complicated way (which I do not include here since too long)
// to wait that all sessions are really closed before exiting the acceptor
// (looping on ioAcceptor.getManagedSessions() to see if requests are pending)
// But if you know a good way to do that (clean shutdown), I will take it !
// Then realy closed if any session are still opened
acceptor.setDisconnectOnUnbind(true);
acceptor.unbind();
if (executorSerialize != null) {
   executorSerialize.shutdownNow();
   executorSerialize = null;
}
// Did I forgot something ?

I will post a second message for the client part... ;-)
Of course, any comment or correction are most welcomed !
Frederic

----- Original Message ----- 
From: "Frédéric Brégier"
Sent: Tuesday, November 20, 2007 7:55 PM
Subject: Re: [jira] Created: (DIRMINA-477) Update page about differences 
between1.x and 2.x


Hi Trustin and all of you !
I come back to MINA since I feel that MINA 2 is on the way to get out.
And I start to look what could be my effort to switch from beta 2 (trunk)
from 6 months ago to the current status of trunk.
I found some points that might be good to add on the page you started to
write.
As a beginning :
- change from get/set Attachment to get/setAttribute (OK there are still
there but deprecated)
    It is not a big deal, of course, if you except the flag in Eclipse ;-)

- a full example on thread, in fact an example with both levels
(SocketAcceptor and ExecutorFilter)
    since they are now really different with the introduction of
Unordered/OrderedThreadPoolExecutor.

    Specially since from before in SocketAcceptor (now NioSocketAcceptor
right ?), the interface is different
    with an Executor at first and IoProcessor at second, which I don't know
at all what to do with it.

    I think, like others, I use Mina on multiprocessor server, so I can
afford multiple thread on
    NioSocketAcceptor and other threads (if needed but I need it since I do
Oracle) in filter.

    Just a question I've just thinking about : Am I correct if I say
Executors.newCachedThreadPool()
    will no more allows order as it is point in this page of transition in
filter ?
    Of course, page in "configuring thread model" is no more correct for V2
(as far as I understand).

- an example of how to configure Read and Write ThrottleFilter and what
could be a good default (if one
    can say of course)

I will come back if I see anything else...

Just a question perhaps stupid :
I have the idea to perhaps use StreamWriteFilter or StreamIoHandler to
transfer some files
but with a protocol exchange before and after the file transfer (to verify
the access, the rules,
to make some pre or post operations, probably making an MD5 check of the
transfered file...).
I have look at the mailing list but I didn't find a good example of what
could be the best
but also I didn't understand how to "get" the file on the other side.
That is to say : I saw some code to send file (using StreamWF) but no on
receiving this file?
I'm surely missing something, obviously...

As always, Mina is going better and better... Just I feel like almost a new
user to Mina
after 6 months without coding Mina stuff, even If I read all the mailing
list (great one !).

Frederic
----- Original Message ----- 
From: "Trustin Lee (JIRA)"
Sent: Wednesday, November 14, 2007 8:08 AM
Subject: [jira] Created: (DIRMINA-477) Update page about differences
between1.x and 2.x


Update page about differences between 1.x and 2.x
-------------------------------------------------

                 Key: DIRMINA-477
                 URL: https://issues.apache.org/jira/browse/DIRMINA-477
             Project: MINA
          Issue Type: Task
          Components: Web Site / Documentation
            Reporter: Trustin Lee
             Fix For: 2.0.0-M1


Our current web site doesn't describe what have been changed in 2.x
comparing to 1.x.  We need to carefully put all changes together there so
people can migrate more easily.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



Reply via email to