usage of ioprocessor
Hi list, Trying to figure something out here and I know it's my first post so please bare with me. Excuse me if my question sounds noobish, but I have been unable to find anything relating to my question, so here goes. I am currently writing a program that spontaniously creates multiple sockets for outgoing as well as incoming connections. In the implementation for NioProcessor I see the option to set a specific ioProcessor. I would like my program to just use 1 ioProcessor at all times. In this scenario do I have to create my own ioProcessor and feed that to the creation of a NioSocket or does mina do this for me? Any explanations on this subject would be very much appreciated. Any examples to make it more clear would be welcome too. Thanks in advance! Kind regards, Mike
Re: usage of ioprocessor
On 11-1-2012 10:42, Emmanuel Lecharny wrote: On 1/11/12 10:11 AM, Mike van Goor wrote: On 11-1-2012 0:03, Emmanuel Lecharny wrote: On 1/10/12 9:31 PM, Mike van Goor wrote: Hi list, Trying to figure something out here and I know it's my first post so please bare with me. Excuse me if my question sounds noobish, but I have been unable to find anything relating to my question, so here goes. I am currently writing a program that spontaniously creates multiple sockets for outgoing as well as incoming connections. In the implementation for NioProcessor I see the option to set a specific ioProcessor. I would like my program to just use 1 ioProcessor at all times. Why would you do that ? In this scenario do I have to create my own ioProcessor and feed that to the creation of a NioSocket or does mina do this for me? You can specify the number of IoProcessor to use, and set it to 1 if needed. But again, why would you do that ? Hi Emmanuel, Firstly thanks for responding. I am looking for a way to only use 1 selector in my setup. The reason is that I would like as less threads as possible. Ok. When you create your Connector/Acceptor, you just have to pass as a parameter the number of IoProcessor you ant to use. Juts pass 1 : SocketAcceptor acceptor = new NioSocketAcceptor( 1 ); Just curious : any reason to limit the number of threads to the minimum ? Also which version of MINA/JVM/OS are you using ? I am writing a home automation server in java and want it to run on single core 500Mhz system with very low processing power. mina-core-2.0.4.jar java version 1.6.0_21 Debian linux atm. Regards, Mike
Re: Forcing the closure of any open session when mina server shuts down
Hello, In short: You are responsible for every session that has been created after MINA accepted it. If you do not close them upon shutdown, they will remain in a to-be-closed state for 2 minutes (I thought this was FIN-Wait, not sure). To make sure the sessions are closed you should close them and then unbind the port. You can accomplish this by using a shutdownhook added to runtime. Like before declaring the acceptor you do: Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { for(IoSession sess : _nioAcceptor.getManagedSessions().values()) { sess.close(false); // Make this true if you want to force the closure } nioAcceptor.unbind(); } }); Op 20-8-2012 11:49, Harakiri schreef: Hello, i read the FAQ entry about closing sessions here mina.apache.org/faq.html and also through the mailling list. However im not sure how i should apply it to my use case. I've created a very simple policy service similar to this example http://jglatre.blogspot.de/2009/03/implementing-greylist-for-postfix-with.html The faq states something about ConnectFuture cf = connector.connect(new InetSocketAddress(localhost, 8080)); but i dont see how this applies to an IoAcceptor - i start my service like in the above example IoAcceptor acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast(codec, new ProtocolCodecFilter(new ApdCodecFactory())); acceptor.setHandler( new DummyApdHandler() ); acceptor.getSessionConfig().setReadBufferSize( 2048 ); acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, 10 ); acceptor.bind( new InetSocketAddress() ); i would expect that upon VM shutdown that all open sessions are closed - however they are not - my postfix server keeps a session open for quiet a while - so when i restart my java server (standalone service) i get the bind error - address already in use. Any hints? I tried a shutdown hook and manually do a acceptor.unbind() but that didnt do the trick either! Thanks
Re: Forcing the closure of any open session when mina server shuts down
Hi, I am (for now) ignoring this line as it exists before exit and after: tcp0 0 127.0.0.1:56901 127.0.0.1:10027 TIME_WAIT Apart from that the acceptor tcp ports have been closed (as there is no LISTEN in your second output. As for the remaining session (the 2 listings are the same session): If you use close(true) then the traditional close handshake (FIN -- FIN-ACK) does not take place in the correct way. Thus this would leave the port in the CLOSE_WAIT and other end FIN_WAIT2 state. To solve this you normally use close(false) and wait for the session to shutdown gracefully. You could built in a sleep of a few seconds to give the system the time to close the sessions. I haven't found a better way of doing this than doing a close(false) on all sessions, wait for example 30 seconds, and then a close(true). If anyone has a better way of handling this let me know as I cannot find a good way to handle these situations all over the internet. Maybe Emnanuel has a good solution for this. Hope my comments help you Regards, Mike Op 20-8-2012 13:56, Harakiri schreef: Hello, thanks for the suggestion - i tried it out but it does not seem to work - the server listener port is closed (this worked for me before) however the client who connects still has the sessions opened. After doing a close(true) on all sessions - and confirming with acceptor.getManagedSessions().size() that there are indeed 0 sessions left - im puzzled who is to blame - the mina server or postfix ? Here is the netstat output after at least one session has been created (there are 2 mina services running, at 10027 and 10028) tcp0 0 127.0.0.1:10027 0.0.0.0:* LISTEN tcp0 0 127.0.0.1:10028 0.0.0.0:* LISTEN tcp0 0 127.0.0.1:54751 127.0.0.1:10028 ESTABLISHED tcp0 0 127.0.0.1:56901 127.0.0.1:10027 TIME_WAIT tcp0 0 127.0.0.1:10028 127.0.0.1:54751 ESTABLISHED after i shutdown the server and a debug output confirmed that the address was unbind, and 0 sessions are left - im left with this tcp1 0 127.0.0.1:54751 127.0.0.1:10028 CLOSE_WAIT tcp0 0 127.0.0.1:56901 127.0.0.1:10027 TIME_WAIT tcp0 0 127.0.0.1:10028 127.0.0.1:54751 FIN_WAIT2 the client is still connecting to 10027 and 28, and for some reason the server port for 10028 is still open but on fin_wait2. I also tried adding acceptor.dispose(); after unbind - no dice. Any further ideas? Thanks
API Website url
Hello, I am trying to find the mina API web reference. The link I had was this: http://mina.apache.org/report/trunk/apidocs/ Is there a new url? Thanks in advance. Best regard, Mike van Goor
Re: API Website url
Thanks Emannuel Op 14-11-2012 21:41, Emmanuel Lécharny schreef: Le 11/12/12 7:47 PM, Mike van Goor a écrit : Hello, I am trying to find the mina API web reference. The link I had was this: http://mina.apache.org/report/trunk/apidocs/ Is there a new url? Thanks in advance. Best regard, Mike van Goor The API is now available here : http://mina.apache.org/mina/javadocs/index.html I have added a new entry on the mina left menu (API Javadoc)
Re: API Website url
Hi, Maybe I joyed too early. I seem to be missing org.apache.transport.serial? Maybe more, but I use that one. Best regard, Mike Op 14-11-2012 21:42, Mike van Goor schreef: Thanks Emannuel Op 14-11-2012 21:41, Emmanuel Lécharny schreef: Le 11/12/12 7:47 PM, Mike van Goor a écrit : Hello, I am trying to find the mina API web reference. The link I had was this: http://mina.apache.org/report/trunk/apidocs/ Is there a new url? Thanks in advance. Best regard, Mike van Goor The API is now available here : http://mina.apache.org/mina/javadocs/index.html I have added a new entry on the mina left menu (API Javadoc)
Re: API Website url
Thanks, I´ll keep an eye out :) Op 15-11-2012 1:53, Emmanuel Lécharny schreef: Le 11/14/12 9:45 PM, Mike van Goor a écrit : Hi, Maybe I joyed too early. I seem to be missing org.apache.transport.serial? Maybe more, but I use that one. I have updated the web site, it might take a few hours for the serial API to be available.
Re: API Website url
Thank you Emmanuel :) Op 15-11-2012 10:05, Emmanuel Lécharny schreef: Le 11/15/12 7:28 AM, Mike van Goor a écrit : Thanks, I´ll keep an eye out :) Ok, done ! The serial javadocs are there.
Re: Logging org.apache.mina?
Hi, In the filterchain you need to add a logfilter. This will dramatically increase the logging for Mina. Regards, Mike Op 5-2-2013 19:32, Andrew Cagney schreef: Hi, Is there anything special that needs to be done when enabling SLF4J logging in mina-core? To keep things simple, I'm using slf4j-simple. with the following properties: sysproperty key=org.slf4j.simpleLogger.defaultLogLevel value=debug/ sysproperty key=org.slf4j.simpleLogger.showDateTime value=true/ sysproperty key=org.slf4j.simpleLogger.dateTimeFormat value=[HH:mm:ss.SSS]/ Both my code and and SSHD (org.apache.sshd) are logging just fine, but I don't see anything from mina-core (org.apache.mina.core/). I guess there's something obvious I've missed? Andrew
Re: MIA for a while...
Op 2-3-2017 om 15:15 schreef Emmanuel Lécharny: I may be MIA for a while, or at least way less responsive : My wife just gave birth to our wonderful daughter today, and I'm afraid it's going to be our priority number one in the next few weeks:-) Congratulations! Enjoy Emmanuel.