-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: JBoss Cache in Tomcat: NO Cache Hits
PostPosted: Thu Apr 20, 2006 2:41 am 
Beginner
Beginner

Joined: Thu Dec 01, 2005 12:53 am
Posts: 21
Hibernate version: 3.1.2


I'm trying to use the JBoss Cache in Tomcat 5.0.x but I see zero cache HIT count in hibernate statistics ... the Cache MISS and PUT count keeps on increasing.

I'm sure I execute similiar queries and load same objects again and again without any updates or modifications. But hibernate seems to always have cache miss - never have cache hit.


Following is my treecache.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>

<server>

   <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar" />


   <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache">

      <depends>jboss:service=Naming</depends>
      <depends>jboss:service=TransactionManager</depends>

      <!--
         Configure the TransactionManager - No matter since  Hibernate will plug in   an "adapter" to its own TransactionManagerLookup strategy here
      -->

      <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>


      <!--
         Node locking scheme:
         OPTIMISTIC
         PESSIMISTIC (default)
      -->
      <attribute name="NodeLockingScheme">OPTIMISTIC</attribute>

      <!--
         Note that this attribute is IGNORED if your NodeLockingScheme above is OPTIMISTIC.
         
         Isolation level : SERIALIZABLE
         REPEATABLE_READ (default)
         READ_COMMITTED
         READ_UNCOMMITTED
         NONE
      -->
      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>

      <!--
         Valid modes are LOCAL
         REPL_ASYNC
         REPL_SYNC
         INVALIDATION_ASYNC
         INVALIDATION_SYNC
      -->
      <attribute name="CacheMode">LOCAL</attribute>

      <!--
         Just used for async repl: use a replication queue
      -->
      <attribute name="UseReplQueue">false</attribute>

      <!--
         Replication interval for replication queue (in ms)
      -->
      <attribute name="ReplQueueInterval">0</attribute>

      <!--
         Max number of elements which trigger replication
      -->
      <attribute name="ReplQueueMaxElements">0</attribute>

      <!-- Name of cluster. Needs to be the same for all clusters, in order
         to find each other
      -->
      <attribute name="ClusterName">TreeCache-Cluster</attribute>

      <!-- JGroups protocol stack properties. Can also be a URL,
         e.g. file:/home/bela/default.xml
         <attribute name="ClusterProperties"></attribute>
      -->

      <attribute name="ClusterConfig">
         <config>
            <!-- 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="228.1.2.3" bind_addr="127.0.0.1" 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" loopback="false" />
            <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" />-->
            <FD_SOCK />
            <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" down_thread="false" />
            <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="true" down_thread="true" />
         </config>
      </attribute>

      <!--
         Whether or not to fetch state on joining a cluster
         NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
      -->
      <attribute name="FetchInMemoryState">false</attribute>

      <!--
         Number of milliseconds to wait until all responses for a
         synchronous call have been received.
      -->
      <attribute name="SyncReplTimeout">20000</attribute>

      <!-- Max number of milliseconds to wait for a lock acquisition -->
      <attribute name="LockAcquisitionTimeout">15000</attribute>

      <!--
         The max amount of time (in milliseconds) we wait until the
         initial state (ie. the contents of the cache) are retrieved from
         existing members in a clustered environment
      -->
      <attribute name="InitialStateRetrievalTimeout">20000</attribute>

      <!--
         Indicate whether to use marshalling or not. Set this to true if you are running under a scoped
         class loader, e.g., inside an application server. Default is "false".
      -->
      <attribute name="UseMarshalling">false</attribute>

      <!-- Name of the eviction policy class. -->
      <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
      <!-- Specific eviction policy configurations. This is LRU -->
      <attribute name="EvictionPolicyConfig">
         <config>
            <!--  This is the interval (in seconds) to process the node events and also to perform sweeping for the size limit and age-out nodes. -->
            <attribute name="wakeUpIntervalSeconds">5</attribute>
            <!-- Cache wide default -->
            <region name="/_default_">
               <attribute name="maxNodes">5000</attribute>
               <attribute name="timeToLiveSeconds">1000</attribute>
               <!-- <attribute name="maxAgeSeconds">1000</attribute> -->
            </region>
         </config>
      </attribute>
   </mbean>
</server>


My hiberante settings:

NOTE: I'm using org.hibernate.transaction.JDBCTransactionFactory

Code:
imsite.hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory
imsite.hibernate.connection.provider_class=com.xxx.hibernate.MyHibernateConnectionProvider
imsite.hibernate.dialect=org.hibernate.dialect.MySQLDialect
imsite.hibernate.show_sql=false
imsite.hibernate.use_outer_join=true
imsite.hibernate.use_sql_comments=false
imsite.hibernate.generate_statistics=true

imsite.hibernate.cache.use_minimal_puts=true
imsite.hibernate.cache.use_second_level_cache=true
imsite.hibernate.cache.use_query_cache=true
imsite.hibernate.cache.provider_class=org.hibernate.cache.TreeCacheProvider


Some hibernate logs at initialization.

Code:
LOG: Using dialect: org.hibernate.dialect.MySQLDialect
LOG: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
LOG: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)


Some log from JBoss cache:

Code:
JBossCache DEBUG:  Start requested before create, calling create now
JBossCache DEBUG:  Creating TreeCache
JBossCache ERROR:  binding of DummyTransactionManager failed
javax.naming.NamingException: Context is read only
   at org.apache.naming.NamingContext.checkWritable(NamingContext.java:901)
   at org.apache.naming.NamingContext.bind(NamingContext.java:829)
   at org.apache.naming.NamingContext.bind(NamingContext.java:169)
   at org.apache.naming.NamingContext.bind(NamingContext.java:185)
   at org.apache.naming.SelectorContext.bind(SelectorContext.java:170)
   at javax.naming.InitialContext.bind(InitialContext.java:355)
   at org.jboss.cache.transaction.DummyTransactionManager.getInstance(DummyTransactionManager.java:33)
........
........
........
........



JBossCache DEBUG: registering for TX completion: SynchronizationHandler(TxInterceptor.LocalSynchronizationHandler(gtx=GlobalTransaction:<null>:137, tx=org.jboss.cache.transaction.DummyTransaction@19e1b2f))
JBossCache INFO: CRUD Method _put(GlobalTransaction:<null>:137, /JBossCache/com/foo/Bar/com.foo.Bar#1, item, CacheEntry(com.foo.Bar)[1,202,#312 Cherrybrook Business Park,null], true, 0) called - don't know how to handle!
JBossCache DEBUG: Adding Method _put(GlobalTransaction:<null>:137, /JBossCache/com/foo/Bar/com.foo.Bar#1, item, CacheEntry(com.foo.Bar)[1,202,#312 Cherrybrook Business Park,null], true, 0) to modification list
JBossCache DEBUG: processing beforeCompletion for tx=org.jboss.cache.transaction.DummyTransaction@19e1b2f, handlers=[TxInterceptor.LocalSynchronizationHandler(gtx=GlobalTransaction:<null>:137, tx=org.jboss.cache.transaction.DummyTransaction@19e1b2f)]
JBossCache DEBUG: Running beforeCompletion on gtx GlobalTransaction:<null>:137
JBossCache DEBUG: Calling lockNodes() with gtx GlobalTransaction:<null>:137
JBossCache DEBUG: locking nodes
JBossCache DEBUG: validating nodes
JBossCache DEBUG: validated nodes
JBossCache DEBUG: processing afterCompletion for tx=org.jboss.cache.transaction.DummyTransaction@19e1b2f, handlers=[TxInterceptor.LocalSynchronizationHandler(gtx=GlobalTransaction:<null>:137, tx=org.jboss.cache.transaction.DummyTransaction@19e1b2f)]
JBossCache DEBUG: calling aftercompletion for GlobalTransaction:<null>:137
JBossCache DEBUG: Running commit phase.  One phase? false
JBossCache DEBUG:  running commit for GlobalTransaction:<null>:137
JBossCache DEBUG: Found local TX=org.jboss.cache.transaction.DummyTransaction@19e1b2f, global TX=GlobalTransaction:<null>:137
JBossCache DEBUG: commiting validated changes
JBossCache DEBUG: Finished local commit/rollback method for GlobalTransaction:<null>:137
JBossCache DEBUG: Finished commit phase
JBossCache DEBUG: (null) call on method [_get(/JBossCache/com/foo/Bar/com.foo.Bar#1, item, true)]
JBossCache DEBUG: Creating transaction for thread Thread[http-8080-Processor24,5,main]
JBossCache DEBUG:  local transaction exists - registering global tx if not present for Thread[http-8080-Processor24,5,main]
JBossCache DEBUG: Associated gtx in txTable is null
JBossCache DEBUG: created new GTX: GlobalTransaction:<null>:138, local TX=org.jboss.cache.transaction.DummyTransaction@10efb8a
JBossCache DEBUG: Registering sync handler for tx org.jboss.cache.transaction.DummyTransaction@10efb8a, gtx GlobalTransaction:<null>:138
JBossCache DEBUG: registering synchronization handler tx=org.jboss.cache.transaction.DummyTransaction@10efb8a, handlers=[]
JBossCache DEBUG: registering for TX completion: SynchronizationHandler(TxInterceptor.LocalSynchronizationHandler(gtx=GlobalTransaction:<null>:138, tx=org.jboss.cache.transaction.DummyTransaction@10efb8a))
JBossCache DEBUG: unable to find node /JBossCache/com/foo/Bar/com.foo.Bar#1 in workspace.
JBossCache DEBUG: processing beforeCompletion for tx=org.jboss.cache.transaction.DummyTransaction@10efb8a, handlers=[TxInterceptor.LocalSynchronizationHandler(gtx=GlobalTransaction:<null>:138, tx=org.jboss.cache.transaction.DummyTransaction@10efb8a)]
JBossCache DEBUG: Running beforeCompletion on gtx GlobalTransaction:<null>:138
JBossCache DEBUG: No modifications in this tx.  Skipping beforeCompletion()
JBossCache DEBUG: processing afterCompletion for tx=org.jboss.cache.transaction.DummyTransaction@10efb8a, handlers=[TxInterceptor.LocalSynchronizationHandler(gtx=GlobalTransaction:<null>:138, tx=org.jboss.cache.transaction.DummyTransaction@10efb8a)]
JBossCache DEBUG: calling aftercompletion for GlobalTransaction:<null>:138
JBossCache DEBUG: Running commit phase.  One phase? false
JBossCache DEBUG:  running commit for GlobalTransaction:<null>:138
JBossCache DEBUG: Found local TX=org.jboss.cache.transaction.DummyTransaction@10efb8a, global TX=GlobalTransaction:<null>:138
JBossCache DEBUG: commiting validated changes
JBossCache DEBUG: Finished local commit/rollback method for GlobalTransaction:<null>:138
JBossCache DEBUG: Finished commit phase


I tried removing the <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute> from treecache.xml but got following exception:

Code:
JBossCache DEBUG: Creating transaction for thread Thread[http-8080-Processor23,5,main]
JBossCache DEBUG:  There was a problem handling this request
java.lang.Exception: Failed to create local transaction; TransactionManager is null
   at org.jboss.cache.interceptors.TxInterceptor.createLocalTx(TxInterceptor.java:861)
   at org.jboss.cache.interceptors.TxInterceptor.handleNonTxMethod(TxInterceptor.java:313)
   at org.jboss.cache.interceptors.TxInterceptor.invoke(TxInterceptor.java:136)
   at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:67)
   at org.jboss.cache.interceptors.CacheMgmtInterceptor.invoke(CacheMgmtInterceptor.java:133)
   at org.jboss.cache.TreeCache.invokeMethod(TreeCache.java:4804)
   at org.jboss.cache.TreeCache.get(TreeCache.java:3040)
   at org.jboss.cache.TreeCache.get(TreeCache.java:3021)
   at org.hibernate.cache.TreeCache.read(TreeCache.java:54)
   at org.hibernate.cache.TreeCache.get(TreeCache.java:45)
   at org.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:96)


I'm out of options now :-(


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 20, 2006 3:48 pm 
Beginner
Beginner

Joined: Thu Dec 01, 2005 12:53 am
Posts: 21
No one yet to answer this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 21, 2006 2:48 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Better ask on a JBoss Cache forum.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 21, 2006 9:06 pm 
Beginner
Beginner

Joined: Thu Dec 01, 2005 12:53 am
Posts: 21
using pessimistic locking schme fixed it ...

Code:
<attribute name="NodeLockingScheme">PESSIMISTIC</attribute>


Now question is ... why Hibernate is not able to see any cache HITs when using OPTIMISTIC locking scheme. I see OptimisticTreeCacheProvider in hibrnate source tree in trunk. But its not available in Hibernate 3.1.2 release.

When using OPTIMISTIC TreeCahce locking scheme, are we supposed to use different cache provider if yes which release will this provider be provided in?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 21, 2006 9:25 pm 
Beginner
Beginner

Joined: Thu Dec 01, 2005 12:53 am
Posts: 21
Here is it discussed on JBossCache forum - http://www.jboss.org/index.html?module= ... ic&t=80192


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.