5 Replies Latest reply on Sep 27, 2007 1:46 PM by brian.stansberry

    Cache 1.4.1 region problems on jboss-ea-4.2.0

    loumaus

      Im experiencing some problems with my current region configuration.

       <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
      
       <!-- Specific eviction policy configurations. This is LRU -->
       <attribute name="EvictionPolicyConfig">
       <config>
       <attribute name="wakeUpIntervalSeconds">5</attribute>
       <!-- Cache wide default -->
       <region name="/_default_">
       <attribute name="maxNodes">5000</attribute>
       <attribute name="timeToLiveSeconds">0</attribute>
       <attribute name="maxAgeSeconds">60</attribute>
       </region>
       <region name="/catalog/persistent">
       <attribute name="maxNodes">5000</attribute>
       <attribute name="timeToLiveSeconds">0</attribute>
       <attribute name="maxAgeSeconds">7200</attribute>
       </region>
       </config>
       </attribute>
      


      As quite obvious I setup two regions, the default one whose nodes expire after 60 secs and the persistent one whose nodes expire after 7200 seconds.

      One corresponding entity looks like:
      
      @Entity
      @Cache(usage = CacheConcurrencyStrategy.READ_ONLY, region = "/catalog/persistent", include="all")
      


      The server log reveals that both regions have been properly setup:
      2007-09-27 12:19:29,938 DEBUG [org.jboss.cache.TreeCache] Creating jboss.cache:service=EJB3EntityTreeCache
      
      2007-09-27 12:19:29,962 DEBUG [org.jboss.cache.TreeCache] Using deprecated configuration element 'EvictionPolicyProvider'. This is only provided for 1.
      
      2.x backward compatibility and may disappear in future releases.
      
      2007-09-27 12:19:29,970 DEBUG [org.jboss.cache.eviction.LRUConfiguration] parseConfig: name -- /_default_ maxNodes -- 5000 timeToLiveSeconds -- 0 maxAge
      
      Seconds -- 60
      
      2007-09-27 12:19:29,970 DEBUG [org.jboss.cache.eviction.RegionManager] createRegion(): creating region for fqn- /_default_
      
      2007-09-27 12:19:29,974 DEBUG [org.jboss.cache.eviction.LRUConfiguration] parseConfig: name -- /catalog/persistent maxNodes -- 5000 timeToLiveSeconds --
      
       0 maxAgeSeconds -- 7200
      
      2007-09-27 12:19:29,974 DEBUG [org.jboss.cache.eviction.RegionManager] createRegion(): creating region for fqn- /catalog/persistent
      
      2007-09-27 12:19:29,992 INFO [org.jboss.cache.factories.InterceptorChainFactory] interceptor chain is:
      
      


      The problem I am facing is that the cache nodes always expire after 60secs which means that no entities have been assigned to the region /catalog/persistent although we configured them accordingly.

      Any idea on howto to help me on this issue ???



        • 1. Re: Cache 1.4.1 region problems on jboss-ea-4.2.0
          brian.stansberry

          Where are the nodes assigned; i.e. what does their FQN look like?

          • 2. Re: Cache 1.4.1 region problems on jboss-ea-4.2.0
            loumaus

            does this help ???

            2007-09-27 14:25:36,929 DEBUG [org.hibernate.cache.CacheFactory] instantiating cache region: cat_ear,service-ejb-catalog-SNAPSHOT_jar,JpaPersistence./ca
            
            talog/persistent usage strategy: read-only
            
            2007-09-27 14:25:36,929 WARN [org.hibernate.cache.CacheFactory] read-only cache configured for mutable class: cat_ear,service-ejb-catalog-SNAPSHOT_jar,
            
            JpaPersistence./catalog/persistent
            
            2007-09-27 14:25:36,944 DEBUG [org.jboss.cache.marshall.RegionManager] createRegion(): creating region for fqn- /cat_ear,service-ejb-catalog-SNAPSHOT_ja
            
            r,JpaPersistence/catalog/persistent
            
            2007-09-27 14:25:36,945 DEBUG [org.jboss.cache.TreeCache] activating /cat_ear,service-ejb-catalog-SNAPSHOT_jar,JpaPersistence/catalog/persistent
            
            2007-09-27 14:25:36,945 DEBUG [org.jboss.cache.TreeCache] forcing release of locks in /
            
            2007-09-27 14:25:36,945 DEBUG [org.jboss.cache.TreeCache] forcing release of locks in /cat_ear,service-ejb-catalog-SNAPSHOT_jar,JpaPersistence
            
            2007-09-27 14:25:36,945 DEBUG [org.jboss.cache.TreeCache] forcing release of locks in /cat_ear,service-ejb-catalog-SNAPSHOT_jar,JpaPersistence/catalog
            


            • 3. Re: Cache 1.4.1 region problems on jboss-ea-4.2.0
              brian.stansberry

              Yep; it's what I suspected. The code is prepending the deployment name to Fqn. It's only supposed to do that if you don't specify a region. As a workaround, you can:

               <!-- Specific eviction policy configurations. This is LRU -->
               <attribute name="EvictionPolicyConfig">
               <config>
               <attribute name="wakeUpIntervalSeconds">5</attribute>
               <!-- Cache wide default -->
               <region name="/_default_">
               <attribute name="maxNodes">5000</attribute>
               <attribute name="timeToLiveSeconds">0</attribute>
               <attribute name="maxAgeSeconds">60</attribute>
               </region>
               <region name="/cat_ear,service-ejb-catalog-SNAPSHOT_jar,JpaPersistence/catalog/persistent">
               <attribute name="maxNodes">5000</attribute>
               <attribute name="timeToLiveSeconds">0</attribute>
               <attribute name="maxAgeSeconds">7200</attribute>
               </region>
               </config>
               </attribute>


              • 4. Re: Cache 1.4.1 region problems on jboss-ea-4.2.0
                loumaus

                thanks for the help ..

                it works ..

                Without looking at the sources I thought that the responsible eviction handler would already prepend the deployment name as it is properly configured in the hibernate part:

                 Properties [
                
                 hibernate.cache.use_minimal_puts: true
                
                 hibernate.jndi.java.naming.factory.url.pkgs: org.jboss.naming:org.jnp.interfaces
                
                 hibernate.cache.provider_class: org.jboss.ejb3.entity.TreeCacheProviderHook
                
                 hibernate.jndi.java.naming.factory.initial: org.jnp.interfaces.NamingContextFactory
                
                 hibernate.transaction.manager_lookup_class: org.hibernate.transaction.JBossTransactionManagerLookup
                
                 hibernate.cache.use_query_cache: true
                
                 hibernate.cache.use_second_level_cache: true
                
                 hibernate.jacc.ctx.id: service-ejb-catalog-SNAPSHOT.jar
                
                 hibernate.cache.region_prefix: cat_ear,service-ejb-catalog-SNAPSHOT_jar,JpaPersistence
                
                 hibernate.session_factory_name: persistence.units:ear=cat.ear,jar=service-ejb-catalog-SNAPSHOT.jar,unitName=JpaPersistence
                
                 hibernate.bytecode.use_reflection_optimizer: false
                
                 hibernate.treecache.mbean.object_name: jboss.cache:service=EJB3EntityTreeCache
                
                


                The way I have to use it right now limits the application area very strongly.
                Am I the first one to face this problem or am I using the region config in a wrong way ???


                • 5. Re: Cache 1.4.1 region problems on jboss-ea-4.2.0
                  brian.stansberry

                   


                  Without looking at the sources I thought that the responsible eviction handler would already prepend the deployment name as it is properly configured in the hibernate part:


                  That's an interesting suggestion -- the Hibernate/JBC code could be smarter about checking the cache's eviction configuration and programatically creating regions that use the settings defined there.

                  Also possible improvement is to have an annotation on the bean to configure this, so it doesn't require using XML and understanding how the cache stores the data.

                  Note that the deployment name will only be used as the region prefix if you don't supply one. So, to make it less verbose you could do this:

                  Properties [
                   .....
                  
                   hibernate.cache.region_prefix: myprefix
                  
                   .....
                  ]
                  


                  <attribute name="EvictionPolicyConfig">
                   <config>
                   <attribute name="wakeUpIntervalSeconds">5</attribute>
                   <!-- Cache wide default -->
                   <region name="/_default_">
                   <attribute name="maxNodes">5000</attribute>
                   <attribute name="timeToLiveSeconds">0</attribute>
                   <attribute name="maxAgeSeconds">60</attribute>
                   </region>
                   <region name="/myprefix/catalog/persistent">
                   <attribute name="maxNodes">5000</attribute>
                   <attribute name="timeToLiveSeconds">0</attribute>
                   <attribute name="maxAgeSeconds">7200</attribute>
                   </region>
                   </config>
                   </attribute>
                  


                  The reason for forcing use of a region prefix is it's needed to ensure proper classloader isolation between different deployments using the same cache.