Hi Julien, Great work! What we need to do now is to create a new subproject 'integration-jmx' and include these code. You can do it by yourself and ask me any questions if you have any problem with creating a Maven subproject.
JDK 1.4 doesn't provide JMX API out of the box, so we will need a dependency. IIRC, MX4J provides JMX API. HTH, Trustin On 9/5/06, Julien Vermillard <[EMAIL PROTECTED]> wrote:
Hi (sorry for HTML email, I hate it too, but there is some code in the message) Today with Trustin mod on IoService for adding session life cycle listening, I made a StatCollector class for collecting stats on session throughput in bytes and in PDU (note to Emmanuel : no it's not for you this one ;) ). Second addition is an IoService MBean and an IoSessionMBean for displaying stats and utility function with JMX. It's commited in my sandbox and work with last MINA's trunk : http://svn.apache.org/viewvc/directory/sandbox/jvermillard/jmx/src/ How to add the MBean to an IoService : acceptor = new SocketAcceptor(); // JMX instrumentation try { IoServiceManager iosm=new IoServiceManager(acceptor); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName(" com.acme.test:type=IoServiceManager,name=MyMINAServer"); mbs.registerMBean(iosm, name); } catch (JMException e) { logger.error("JMX Exception : ",e); } Now if for each session of the service you want a MBean binded to the session for managing it individualy add : acceptor.addListener(new IoServiceListener() { public void serviceActivated( IoService service, SocketAddress serviceAddress, IoHandler handler, IoServiceConfig config ) { } public void serviceDeactivated( IoService service, SocketAddress serviceAddress, IoHandler handler, IoServiceConfig config ) { } public void sessionCreated( IoSession session ) { try { IoSessionManager sessMgr=new IoSessionManager(session); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName(" com.acme.test.session:type=IoSessionManager ,name="+session.getRemoteAddress().toString().replace(':','/')); mbs.registerMBean(sessMgr, name); } catch (JMException e) { logger.error("JMX Exception : ",e); } } public void sessionDestroyed( IoSession session ) { try { ObjectName name = new ObjectName(" com.acme.test.session:type=IoSessionManager ,name="+session.getRemoteAddress().toString().replace(':','/')); ManagementFactory.getPlatformMBeanServer ().unregisterMBean(name); } catch (JMException e) { logger.error("JMX Exception : ",e); } } }); When your server is started, you can fire JConsole (installed with jdk 1.5) click on MBeans tab and got to you can see your IoServiceManagerBeam. For start collecting stats click on "startCollectingStats" and giving a polling time in milliseconds (5000 is a good value). The IoSession MBean will display the stats related to the session, a list of currently installed filter, some other stat and the possiblity to add/remove a LoggingFilter at the begining or end of the filter. The stat collecting is a huge subject and I usualy have only 2 or 3 connections on my tiny embedded servers ;) So any code review, test, critisim and idea welcomed and helpfull ! Julien P.S : Rumors of MINA 1.0 without JMX support are greatly exagerated ;)
-- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP key fingerprints: * E167 E6AF E73A CBCE EE41 4A29 544D DE48 FE95 4E7E * B693 628E 6047 4F8F CFA4 455E 1C62 A7DC 0255 ECA6
