9 Replies Latest reply on Oct 26, 2006 12:39 AM by Ben Wang

    statistics not refreshing

    jan zimmek Newbie

      We are currently integrate jboss-cache in our project and it works really good. But the only thing not working is the statistic-mbeans (neither in jmx-console nor in jconsole). The only attribute which refreshes is the time elapsed since starting/reset.

      This is our environment:

      - Linux
      - JBossCache-1.4.0.SP1
      - Sun JDK 1.5
      - jboss-4.0.4.GA-ejb3

      And this is out configuration (this is very similar to 'local-service.xml'):

      <?xml version="1.0" encoding="UTF-8"?>
       <mbean code="org.jboss.cache.aop.PojoCache" name="jboss.cache:service=TreeCacheXX">
       <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
       <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
       <attribute name="CacheMode">LOCAL</attribute>
       <attribute name="ClusterName">TreeCache-Cluster</attribute>
       <attribute name="ClusterConfig">
       <!-- UDP: if you have a multihomed machine,
       set the bind_addr attribute to the appropriate NIC IP address -->
       <!-- UDP: On Windows machines, because of the media sense feature
       being broken with multicast (even after disabling media sense)
       set the loopback attribute to true -->
       <UDP mcast_addr="" mcast_port="48866"
       ip_ttl="64" ip_mcast="true"
       mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
       ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
       <PING timeout="2000" num_initial_members="3"
       up_thread="false" down_thread="false"/>
       <MERGE2 min_interval="10000" max_interval="20000"/>
       <FD shun="true" up_thread="true" down_thread="true"/>
       <VERIFY_SUSPECT timeout="1500"
       up_thread="false" down_thread="false"/>
       <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
       max_xmit_size="8192" up_thread="false" down_thread="false"/>
       <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
       <pbcast.STABLE desired_avg_gossip="20000"
       up_thread="false" down_thread="false"/>
       <FRAG frag_size="8192"
       down_thread="false" up_thread="false"/>
       <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
       shun="true" print_local_addr="true"/>
       <pbcast.STATE_TRANSFER up_thread="false" down_thread="false"/>
       <attribute name="InitialStateRetrievalTimeout">20000</attribute>
       <attribute name="SyncReplTimeout">20000</attribute>
       <attribute name="LockAcquisitionTimeout">5000</attribute>
       <attribute name="EvictionPolicyClass"></attribute>
       <attribute name="EvictionPolicyConfig">
       <attribute name="wakeUpIntervalSeconds">5</attribute>
       <!-- Cache wide default -->
       <region name="/bookmarks">
       <attribute name="maxNodes">5000</attribute>
       <attribute name="timeToLiveSeconds">1000</attribute>
       <region name="/friendships">
       <attribute name="maxNodes">5000</attribute>
       <attribute name="timeToLiveSeconds">1000</attribute>
       <attribute name="UseRegionBasedMarshalling">false</attribute>

      In our tests have simply get/put some java.lang.String objects in the cache:

      We have used both ways (jndi & programmatic) to embedd the cache in jboss, but without any difference.

      Object x = cache.getObject(Fqn.fromString("/a1"));
      cache.putObject(Fqn.fromString("/a1"), "hello world");
      x = cache.getObject(Fqn.fromString("/a1"));

      It would be really great if someone can help me, because we cannot do any production-planning without any statistics.

      Jan Zimmek

        • 1. Re: statistics not refreshing
          Manik Surtani Master

          Have you tried explicitly setting the UseInterceptorMbeans attribute to true?

          Also, how do you try to connect to the MBeans, did you try using jconsole?


          • 2. Re: statistics not refreshing
            jan zimmek Newbie

            i have added:

            <attribute name="UseInterceptorMbeans">true</attribute>

            to my config, but without any visible effect.

            i have tried jconsole, but i cannot see any mbean of jboss-cache.

            • 3. Re: statistics not refreshing
              Jerry Gauthier Apprentice

              If you see the CacheMgmtInterceptor mbean in your JBoss JMX Console display, then UseInterceptorMbeans is definitely enabled.

              The main TreeCache mbean (e.g., service=TreeCacheXX) and the CacheMgmtInterceptor mbean both have attributes named "Number of Nodes" and "Number of Attributes." Are these entries non-zero and correct in both mbeans? The CacheMgmtInterceptor mbean obtains this information directly from the TreeCache mbean so the values should be identical.

              I added the JBossCache 1.4SP1 jar to my JBossAS 4.0.4GA server and found that the tomcat cache instance did successfully display statistics. I just used the cache's mbean to add and retrieve some nodes; the statistics mbean displayed the expected results.

              • 4. Re: statistics not refreshing
                jan zimmek Newbie

                After some stuggling I can see the following attributes refreshing:

                - NumberOfNodes
                - Stores
                - NumberOfAttributes

                But the following are still not refreshing:

                - HitMissRatio : 0
                - Misses : 0
                - Evictions : 0

                I have digged in the class CacheMgmtInterceptor and it seams that

                PojoCacheIfc pojoCache = // lookup via jndi
                return pojoCache.getObject(Fqn.fromString(fqn));

                does not result in a CacheMgmtInterceptor.invoke() call.

                • 5. Re: statistics not refreshing
                  Jerry Gauthier Apprentice

                  I suppose it's possible that PojoCache isn't using TreeCache under some circumstances. I haven't looked at the PojoCache code to see if this is the case.

                  I did try a quick test using the TomcatClusteringCache service and I didn't note any problems there. It uses TreeCacheAop rather than PojoCache though. TreeCacheAop is a legacy wrapper around PojoCache so it should exhibit the same behavior.

                  I started the "all" server and then accessed the mbean for service=TomcatClusteringCache. The underlying implelementation here is org.jboss.cache.aop.TreeCacheAop so that should be similar to what you're using. I issued some put (String, Object, Object) and get(String, Object) operations using the mbean. I then accessed the service=TomcatClusteringCache,treecache-interceptor=CacheMgmtInterceptor
                  mbean and found the statistics were correct. Hits, misses stores and the hit/miss ratio correctly reflected the put and get operations that I executed.

                  • 6. Re: statistics not refreshing
                    Jerry Gauthier Apprentice

                    I took a quick look at the PojoCache implementation and it looks like you may be correct that the CacheMgmtInterceptor isn't invoked when an aop method such as getObject() or putObject() is invoked. Statistics would be accumulated when a TreeCache method such as put() or get() is invoked.

                    You should probably open a JIRA issue so that this can be tracked.

                    • 7. Re: statistics not refreshing
                      Ben Wang Master

                      PojoCache should still have some form of stats though, afterall it is using TreeCache get/put underneath so I am not sure what exactly is going on? Do you have a unit test for this?

                      • 8. Re: statistics not refreshing
                        Jerry Gauthier Apprentice

                        The unit tests for statistics are located in org.jboss.cache.mgmt. The MgmtCoreTest class is the one that tests puts, gets, evictions, etc.

                        I've only executed tests against TreeCache, not PojoCache (or TreeCacheAop). AFAIK, there was no discussion of PojoCache when we implemented cache statistics.

                        I think that statistics will work for PojoCache when you use the put() and get() methods. These should be handled by the underlying TreeCache and the associated statistics will be correct. I've validated this to some degree by using the TomcatClusteringCache mbean to put and get cache entries. The statistics are correct after these operations.

                        However this issue states that statistics don't work when PojoCache uses the putObject() method. I haven't tested it personally but I have looked at the code and it doesn't look like this method is delegated to TreeCache or one of its interceptors.

                        Unless I'm mistaken, this is an area that we never discussed. Maybe PojoCache should provide its own interceptor containing statistics that are unique to it?

                        • 9. Re: statistics not refreshing
                          Ben Wang Master

                          I do start a simple jmx mbean in the 2.0 release. Jerry, if you have time to help out, ping me.

                          But again, for the simple cache stats, I don't see why it won't work though?