9 Replies Latest reply on Apr 19, 2017 8:21 AM by Ulab S

    infinispan as hibernate 2LC in wildfly 10

    Ulab S Newbie

      Hi,

      I'm trying to migrate jboss cache (JBoss 5) to infinispan (wildfly 10) and I see existing  jboss-cache-manager-jboss-beans.xml has lot of "cache" beans defined in it and I have no idea if that is ever useful. This is the default jboss cache configuration.

      The environment is standalone server with single node configuration. Now, with the migration to infinispan, do I need to specify the infinispan-config.xml for 2LC to work ? Does the infinispan subsystem (along with cache configuration in persistence.xml) is not enough to use the default cache ? What is the use of infinispan-config.xml in terms of 2LC for hibernate ?

       

      My purpose of using inifinispan is only to use as 2LC for hibernate. I'm quite new to this 2LC and would need your suggestions. Thanks.

        • 1. Re: infinispan as hibernate 2LC in wildfly 10
          Radim Vansa Master

          The configuration in standalone.xml is enough as long as you don't need to fine-tune something (and for some tuning such as expiration you can still manage in persistence.xml). When deploying on WildFly, you don't set infinispan-config.xml at all; any configuration should be set in standalone.xml.

          The linked file contains pre-configured variants for certain use cases. WF default configuration (the 'entities') cache should work for you; just size the caches (evicition settings) according to your needs as the default 10,000 is more of an example of a configuration.

          • 2. Re: infinispan as hibernate 2LC in wildfly 10
            Ulab S Newbie

            Thank you for the response.

            I had tried to "switch off" the 2LC cache entirely and see the application performance.

             

            persistence.xml

              <properties>

              <!-- SQL debug/formatting -->

              <property name="hibernate.show_sql" value="false"/>

              <property name="hibernate.format_sql" value="false"/>

              <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>

              <property name="hibernate.generate_statistics" value="true" />

              <property name="hibernate.use_sql_comments" value="true"/>

             

              <!-- hibernate 2nd level caching -->

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

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

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

              </properties>

             

            But still on application restart and access, I see below entries. If I understand correctly, it still create cache region ? for 2LC ? Should i have to remove <cache-container name='hibernate'> in standalone.xml to disable caching entirely ?

             

            log

            15:53:40,162 INFO  [org.hibernate.cache.internal.StandardQueryCache] (default task-8) HHH000248: Starting query cache at region: appls-2.0-SNAPSHOT.ear/entity.jar#entity.data-region

            15:53:40,193 INFO  [org.jboss.as.clustering.infinispan] (default task-8) WFLYCLINF0002: Started appls-2.0-SNAPSHOT.ear/entity.jar#entity.data-region cache from hibernate container

            • 3. Re: infinispan as hibernate 2LC in wildfly 10
              Radim Vansa Master

              The configuration from persistence.xml should be sufficient to disable caching, so either you've misconfigured it or it is a bug (reproducers are welcome).

              Btw., don't set 'hibernate.cache.use_minimal_puts' to true for Infinispan, it does more harm than good (perf-wise).

              • 4. Re: infinispan as hibernate 2LC in wildfly 10
                Ulab S Newbie

                Thanks. you are right. It looks like maven problem and new change containing persistence.xml did not get through.

                • 5. Re: infinispan as hibernate 2LC in wildfly 10
                  Ulab S Newbie

                  Hi Radim,

                  Does this infinispan-config define default configuration ? So adding this in application does not add any benefit ?

                  Where can I find the default configs? Thanks.

                   

                  For example I want to compare these existing JBoss cache configuration with infinispan and add appropriately.

                   

                  jboss-cache-manager-jboss-beans.xml

                  <!-- Node locking scheme -->

                           <property name="nodeLockingScheme">OPTIMISTIC</property>

                   

                   

                           <!-- Mode of communication with peer caches.       

                                INVALIDATION_SYNC is highly recommended as the mode for use

                                with entity and collection caches.     -->

                           <property name="cacheMode">INVALIDATION_SYNC</property>

                           <property name="useLockStriping">false</property>

                   

                   

                           <!-- Name of cluster. Needs to be the same for all members -->

                           <property name="clusterName">${jboss.partition.name:DefaultPartition}-app-entity</property>       

                           <!-- Use a UDP (multicast) based stack. A udp-sync stack might be

                                slightly better (no JGroups FC) but we stick with udp to

                                help ensure this cache and others like timestamps-cache

                                that require FC can use the same underlying JGroups resources. -->

                           <property name="multiplexerStack">${jboss.default.jgroups.stack:udp}</property>

                           <!-- Whether or not to fetch state on joining a cluster. -->

                           <property name="fetchInMemoryState">false</property>

                   

                   

                           <!-- The max amount of time (in milliseconds) we wait until the

                             state (ie. the contents of the cache) are retrieved from

                             existing members at startup. Ignored if FetchInMemoryState=false. -->

                           <property name="stateRetrievalTimeout">60000</property>

                   

                   

                           <!-- Number of milliseconds to wait until all responses for a

                                 synchronous call have been received. -->

                           <property name="syncReplTimeout">17500</property>

                   

                   

                           <!-- Max number of milliseconds to wait for a lock acquisition -->

                           <property name="lockAcquisitionTimeout">15000</property>

                   

                   

                           <!-- Hibernate 2LC can replicate custom types, so we use marshalling -->

                           <property name="useRegionBasedMarshalling">true</property>

                           <!-- Must match the value of "useRegionBasedMarshalling" -->

                           <property name="inactiveOnStartup">true</property>

                   

                   

                           <!-- Disable asynchronous RPC marshalling/sending -->

                           <property name="serializationExecutorPoolSize">0</property>       

                           <!-- We have no asynchronous notification listeners -->

                           <property name="listenerAsyncPoolSize">0</property>

                          

                           <property name="evictionConfig">

                               <bean class="org.jboss.cache.config.EvictionConfig">

                                 <property name="wakeupInterval">5000</property>

                                 <!--  Overall default -->

                                 <property name="defaultEvictionRegionConfig">

                                    <bean class="org.jboss.cache.config.EvictionRegionConfig">

                                       <property name="regionName">/</property>

                                       <property name="evictionAlgorithmConfig">

                                          <bean class="org.jboss.cache.eviction.LRUAlgorithmConfig">

                                             <!-- Evict LRU node once we have more than this number of nodes -->

                                             <property name="maxNodes">10000</property>

                                             <!-- And, evict any node that hasn't been accessed in this many seconds -->

                                             <property name="timeToLiveSeconds">1000</property>

                                             <!-- Don't evict a node that's been accessed within this many seconds.

                                                  Set this to a value greater than your max expected transaction length. -->

                                             <property name="minTimeToLiveSeconds">120</property>

                                          </bean>

                                       </property>

                                    </bean>

                                 </property>

                                 <property name="evictionRegionConfigs">

                                    <list>

                                       <!--  Don't ever evict modification timestamps -->

                                       <bean class="org.jboss.cache.config.EvictionRegionConfig">

                                          <property name="regionName">/app-cache/reference-data-region</property>

                                          <property name="evictionAlgorithmConfig">

                                           <bean class="org.jboss.cache.eviction.LRUAlgorithmConfig">

                                              <!-- Evict LRU node once we have more than this number of nodes -->

                                              <property name="maxNodes">-1</property> <!-- -1 means cache everything -->

                                              <!-- And, evict any node that hasn't been accessed in this many seconds -->

                                              <property name="timeToLiveSeconds">14400</property> <!-- 4 hours -->

                                              <!-- Don't evict a node that's been accessed within this many seconds.

                                                   Set this to a value greater than your max expected transaction length. -->

                                              <property name="minTimeToLiveSeconds">120</property>

                                              <property name="maxAge">86400000</property> <!-- in ms: 1 day refresh -->

                                           </bean>

                                          </property>

                                       </bean>

                                       <bean class="org.jboss.cache.config.EvictionRegionConfig">

                                          <property name="regionName">/TS</property>

                                          <property name="evictionAlgorithmConfig">

                                             <bean class="org.jboss.cache.eviction.NullEvictionAlgorithmConfig"/>

                                          </property>

                                       </bean>

                  • 6. Re: infinispan as hibernate 2LC in wildfly 10
                    Radim Vansa Master

                    The default in embedded mode is here:  hibernate-orm/infinispan-configs.xml at master · hibernate/hibernate-orm · GitHub - just adding a XML file onto the classpath is not sufficient (though you probably can somehow shadow the default config). In standalone application, that would be defined by hibernate.cache.infinispan.cfg property. When deployed into WF, it just takes the definitions of caches provided by WF (from standalone.xml), or the default from the above mentioned file.

                    • 7. Re: infinispan as hibernate 2LC in wildfly 10
                      Ulab S Newbie

                      Thanks.

                      Is the below configuration is required while running in WF 10? I see many posts like this describing to add these to persistence.xml.

                      But I remember somewhere in an article it is mentioned that it is not required since WF.

                       

                      <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
                      <property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/container/hibernate" />