7 Replies Latest reply on Apr 21, 2011 8:11 PM by pferraro

    Infinispan as a L2C

    thammoud

      Hello,

       

      Using JBOSS 61 on Linux.

       

      Below is our persistence.xml:

       

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

      <persistence

          xmlns="http://java.sun.com/xml/ns/persistence"

          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

          xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"

          version="1.0">

         <persistence-unit name="FinancialDataServer">

            <jta-data-source>java:/FinancialDataServerDS</jta-data-source>

            <properties>

       

            <property name="jboss.entity.manager.jndi.name" value="java:/FinancialDataServerManager"/>

            <property name="jboss.entity.manager.factory.jndi.name" value="java:/FinancialDataServerManagerFactory"/>

       

            <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory"/>              

            <property name="hibernate.cache.use_query_cache" value="true"/>

            <property name="hibernate.cache.use_second_level_cache" value="true"/>     

            <property name="hibernate.cache.infinispan.cachemanager" value="java:CacheManager"/>

       

           </properties>

         </persistence-unit>

      </persistence>

       

      In deploy/cluster/infinispan-cache-registry.sar/infinispan-configs.xml, I changed "entity", "local-query" to never evict with the following:

       

        <eviction wakeUpInterval="0" strategy="NONE"/>

       

      Running our code the first time, yields the expected behavior (i.e SQL). Running it again right away, also yields the expected results. i.e Everything from the cache confirmed from the hibernate logging. After a while a couple of minutes or so, the logging from hibernate claims not to find the results and fires SQL clearly not what we expect. It looks like the items are being evicted (nothing from the infinispan log) and we are not doing any writes to force the evictions. Any ideas on why it hit some cache first and none later?

       

      One thing I did notice (that I thought was strange) in the JMX console is the CacheManager status was "INSTANTIATED" and not "STARTED". Also the "DefinedCacheNames" had none of the caches "created".

       

      Thanks for your help.

        • 1. Infinispan as a L2C
          thammoud

          One thing I do see when I manually start the Cache mbean:

           

          9:23:54,117 INFO  [class com.enfusion.fas.feeds.report.Report:TRS] Sending Sync 2 rows

          09:25:54,155 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] deploy, ctxPath=/jmx-console

          09:26:05,147 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] Starting JGroups Channel                                                                           

          09:26:05,147 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] Starting JGroups Channel                                                                           

          09:26:05,200 INFO  [STDOUT]                                                                                                                                                        

          09:26:05,200 INFO  [STDOUT] -------------------------------------------------------------------                                                                                    

          09:26:05,200 INFO  [STDOUT] GMS: address=tarek02:1099, cluster=DefaultPartition-Hibernate, physical address=192.168.1.20:55200                                                     

          09:26:05,200 INFO  [STDOUT] -------------------------------------------------------------------                                                                                    

          09:26:07,203 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] Received new cluster view: [tarek02:1099|0] [tarek02:1099]                                         

          09:26:07,203 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] Received new cluster view: [tarek02:1099|0] [tarek02:1099]                                         

          09:26:07,203 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] Cache local address is tarek02:1099, physical addresses are [192.168.1.20:55200]                   

          09:26:07,203 INFO  [org.infinispan.remoting.transport.jgroups.JGroupsTransport] Cache local address is tarek02:1099, physical addresses are [192.168.1.20:55200]                   

          09:26:07,203 INFO  [org.infinispan.factories.GlobalComponentRegistry] Infinispan version: Infinispan 'Ursus' 4.2.0.FINAL                                                           

          09:26:07,203 INFO  [org.infinispan.factories.GlobalComponentRegistry] Infinispan version: Infinispan 'Ursus' 4.2.0.FINAL                                                           

          09:26:07,222 INFO  [org.infinispan.jmx.ComponentsJmxRegistration] Could not register object with name: org.infinispan:type=Cache,name="___defaultcache(local)",manager="hibernate",component=Cache                                                                                                                                                                     

          09:26:07,222 INFO  [org.infinispan.jmx.ComponentsJmxRegistration] Could not register object with name: org.infinispan:type=Cache,name="___defaultcache(local)",manager="hibernate",component=Cache                                                                                                                                                                     

          09:26:07,222 INFO  [org.infinispan.jmx.CacheJmxRegistration] MBeans were successfully registered to the platform mbean server.                                                     

          09:26:07,222 INFO  [org.infinispan.jmx.CacheJmxRegistration] MBeans were successfully registered to the platform mbean server.                                                     

          09:26:07,222 INFO  [org.infinispan.factories.ComponentRegistry] Infinispan version: Infinispan 'Ursus' 4.2.0.FINAL                                                                 

          09:26:07,222 INFO  [org.infinispan.factories.ComponentRegistry] Infinispan version: Infinispan 'Ursus' 4.2.0.FINAL                                                                 

          09:26:07,222 INFO  [org.jboss.ha.ispn.DefaultCacheContainerFactory] Started "___defaultcache" cache from "hibernate" container                                                     

          • 2. Infinispan as a L2C
            pferraro

            You're using the wrong region factory class.  Try this one instead: org.hibernate.cache.infinispan.JndiInfinispanRegionFactory

            Otherwise, hibernate will use an internal set of infinispan defaults, instead of the configuration contained in the "hibernate" container from infinispan-configs.xml.

            • 3. Infinispan as a L2C
              thammoud

              Hi Paul,

               

              I did change that as you suggested and it does start the mbean. This is what I see:

               

              1. In component=CacheManager,name="hibernate",type=CacheManager, I do see the mbean is in RUNNING state and many "DefinedCacheNames" that correspond to each of our cached domain objects. Why it creates a separate cache name for each class is something I do not understand. I assumed it will use entity for all our classes.
              2. For each of our domain objects, I see an mbean of type=Cache, invalidation_sync that Ido notunderstand. component=Cache,manager="hibernate",name="persistence.unit:unitName=FinancialDataServer.ear/FinancialDataServerEJB.jar#FinancialDataServer.com.enfusion.fds.trade.AccountAllocation(invalidation_sync)",type=Cache
              3. The main problem of "sudden" disappearance from the query cache has not gone away. After a few minutes, I see hibernate spit out [org.hibernate.cache.StandardQueryCache] query results were not found in cache and this is very frustrating given that we can not dump the query cache from JMX to see its contents

               

              Any help will be greatly appreciated.


              • 4. Infinispan as a L2C
                thammoud

                The "sudden" disappearance was caused by having a maxIdle set to 10000 rather than -1 which was the intention. Confused eviction (We turned that off) with maxIdle time. We still need to understand 1 and 2 from above.

                • 5. Infinispan as a L2C
                  pferraro

                  The Infinispan-based Hibernate 2LC uses a separate cache instance for each entity class.  The objects are stored in their cache using the @Id as the key.  The "entity" cache name identifies the cache configuration for the entity (and collection) cache regions.  The cache instances for each entity (and collection) all share the same cache configuration.  Does that make sense?

                  • 6. Infinispan as a L2C
                    thammoud

                    Thanks for the explanation. HI can not get my head around understanding item 2 for the invalidation-sync. Why are those created? Thanks for your prompt replies.

                    • 7. Infinispan as a L2C
                      pferraro

                      I'm not sure I understand your question, but I'll try to elaborate...

                      The object name you listed corresponds to the cache where your AccountAllocation entities are stored.  invalidation-sync refers to the cache mode.  Invalidation caches do not replicate individual cache entries - only invalidation messages.  So if node1 and node2 happen to cache the same entity instance, and the entity is updated on node1, node2 will receive an eviction message for that entity (since its cached copy would be out of date otherwise).  The "sync" means that the eviction message is processed before node1's cache entry is updated.

                      Each entity type gets a separate cache instance.  These cache instances are created from the "entity" cache configuration.