[ http://issues.apache.org/jira/browse/DIRMINA-299?page=all ]

Mark Webb updated DIRMINA-299:
------------------------------

    Attachment: jmx.diff

This patch updates the following files:
integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManager.java
integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManagerMBean.java
core/src/main/java/org/apache/mina/management/StatCollector.java

What I did was use internal AtomicLong objects in StatCollector to store the 
values that were previously being computed on the fly.  I chose AtomicLong to 
ensure thread safety.  I also used a variant of the httpserver example to test 
the patch.  Below is the code:

--BEGIN--
        IoAcceptor acceptor = new SocketAcceptor();

        // JMX Setup
        IoServiceManager serviceManager = new IoServiceManager( acceptor );
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); 
                ObjectName name = new 
ObjectName("org.apache.mina.example.jmx:type=JmxTestMain");  
                mbs.registerMBean(serviceManager, name); 
        
        // Bind
        acceptor.setLocalAddress( new InetSocketAddress( PORT ) );
        acceptor.setHandler( new HttpProtocolHandler() );
        acceptor.bind();
--END--

Compile and run this application.  Start jconsole, click on the MBeans tab, 
select the proper bean name, select the Operations tab, and click 
startCollectingStats.  Go back to the Attributes tab and click refresh.  You 
will see the values being updated.

If you were to run the above scenario without the attached patch, you would get 
no values shown in the attribute tab.

> innacurate JMX statistics
> -------------------------
>
>                 Key: DIRMINA-299
>                 URL: http://issues.apache.org/jira/browse/DIRMINA-299
>             Project: Directory MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.1
>         Environment: Fedora Core 5, Eclipse 3.2 using Java 1.4 compiler 
> settings.
>            Reporter: Mark Webb
>            Priority: Minor
>         Attachments: jmx.diff
>
>
> The  class org.apache.mina.integration.jmx.IoServiceManager computes the 
> bytes read/written using the service's managed sessions using the method 
> IoService.getManagedSessions().  This method returns a java.util.Set object, 
> which only contains the sessions currently active.  
> The IoServiceManager class uses org.apache.mina.management.StatCollector 
> class to assist with tracking data throughput.  The StatCollector class only 
> operates on active sessions.
> The problem is that the values returned from the managed bean interface is 
> computed only on the currently active sessions.  Based on the names of the 
> methods, the values returned should be running totals, to include sessions 
> that are no longer active.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to