0 Replies Latest reply on Dec 19, 2012 5:17 AM by tommy17

    JBOSS 7 + HIBERNATE 4 + INFINISPAN 5.2 CLUSTERING QUESTION

    tommy17

      Hi.

       

      Sorry for all the mistakes I'm gonna do but this is actually my very first post here. I've been reading jboss community for a long time but now I absolutely need to ask you a question, 'cause I'm stuck and I've a deadline for Christmas.

      I'm testing hibernate+ infinispan clustering cache replication in jboss  and my architecture consist of two hosts with two server each (each host has the one server of the server group "Video" and one the server group "Audio"), all with the same application (war in clustered mode with  <distributable/> tag in web.xml) which is using  JPA. I have to entities inside and yesterday I was trying to understand how the cache for hibernate is really working.

      First of all I activated the second level cache and this is my persistence.xml file:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="2.0"
      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_2_0.xsd">
      <persistence-unit name="jpa_test"  transaction-type="JTA">
         <description>first jpa test</description>
         <provider>org.hibernate.ejb.HibernatePersistence</provider>
         <jta-data-source>java:jboss/datasources/MySqlDS</jta-data-source>
         <class>test.Premium</class>
         <class>test.Standard</class>
         <shared-cache-mode>ALL</shared-cache-mode>
         <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
         <property name="hibernate.show.sql" value="true"></property>
         <property name="hibernate.cache.use_second_level_cache" value="true"/>
         <property name="hibernate.cache.use_query_cache" value="true" />
         </properties>
      </persistence-unit>
      </persistence>
      
      

       

       

      and this is my domail.xml focusing on my cache configuration (ha profile):

       

       

      <subsystem xmlns="urn:jboss:domain:infinispan:1.4" default-cache-container="cluster"> 
                      <cache-container name="cluster" aliases="ha-partition" default-cache="default">
                          <transport lock-timeout="60000"/>
                          <replicated-cache name="default" mode="SYNC" batching="true">
                              <locking isolation="REPEATABLE_READ"/>
                          </replicated-cache>
                      </cache-container>
                      <cache-container name="web" aliases="standard-session-cache" default-cache="repl" module="org.jboss.as.clustering.web.infinispan">
                          <transport lock-timeout="60000"/>
                          <replicated-cache name="repl" mode="ASYNC" batching="true">
                              <file-store/>
                          </replicated-cache>
                          <replicated-cache name="sso" mode="SYNC" batching="true"/>
                          <distributed-cache name="dist" l1-lifespan="0" mode="ASYNC" batching="true">
                              <file-store/>
                          </distributed-cache>
                      </cache-container>
                      <cache-container name="ejb" aliases="sfsb sfsb-cache" default-cache="repl" module="org.jboss.as.clustering.ejb3.infinispan">
                          <transport lock-timeout="60000"/>
                          <replicated-cache name="repl" mode="ASYNC" batching="true">
                              <eviction strategy="LRU" max-entries="10000"/>
                              <file-store/>
                          </replicated-cache>
                          <replicated-cache name="remote-connector-client-mappings" mode="SYNC" batching="true"/>
                          <distributed-cache name="dist" l1-lifespan="0" mode="ASYNC" batching="true">
                              <eviction strategy="LRU" max-entries="10000"/>
                              <file-store/>
                          </distributed-cache>
                      </cache-container>
                               <cache-container name="hibernate" default-cache="local-query" module="org.jboss.as.jpa.hibernate:4">
                          <local-cache name="local-query">
                              <transaction mode="NONE"/>
                              <eviction strategy="LRU" max-entries="1000"/>
                              <expiration max-idle="10000"/>
                          </local-cache>
                          <invalidation-cache name="entity" mode="SYNC">
                              <transaction mode="NON_XA"/>
                              <eviction strategy="LRU" max-entries="100"/>
                              <expiration max-idle="10000"/>
                          </invalidation-cache>
                          <replicated-cache name="timestamps" mode="ASYNC">
                              <transaction mode="NONE"/>
                              <eviction strategy="NONE"/>
                          </replicated-cache>
                       </cache-container
      </subsystem>
      
      

       

       

       

      and my server configuration still in domain.xml:

       

      <server-groups>
             <server-group name="Video" profile="ha">
                  <jvm name="default">
                      <heap size="64m" max-size="512m"/>
                  </jvm>
                  <socket-binding-group ref="ha-sockets_V"/>
                </server-group>
              <server-group name="Audio" profile="ha">
                  <jvm name="default">
                      <heap size="64m" max-size="512m"/>
                  </jvm>
                  <socket-binding-group ref="ha-sockets_A"/>
              </server-group>
      </server-groups>
      </domain>
      
      

       

       

       

      I opened two browsers and navigated to my application on the same jboss instance (on the same host) so to be sure that, ones I changed one property of an entity with a simple command button in jsf in one browser, the new value appear on the other browser after updating the page, always referring to the same entity and most important without flushing or updating the state of it in the database. Everything worked fine as expected luckly

      But now we come to my real question: why the value of entity is not replicated over the cluster if I'm in the situation where the two browser are connected to the two different host but still on the same server group? I thought that, by changing the value on the first instance of the application on the first host, after updating the page on the other browser connected to the other application instance on the other host I would have seen the value updated? Instead this didn't happen sadly.

      I also tried to wait  a couple of minutes to see if it was a problem of cache invalidation and expiration, but nothing.

      I also tried to change  <cache-container name="hibernate" default-cache="local-query" to  <cache-container name="hibernate" default-cache="replicated-cache" but nothing changed.

      If it can help you, fail over test from one host to the other was successful and the value was kept without any problem (I mean by killing the first instance of jboss to which the first browser was connected to after having changed the value of the entity and immediately updating the page, which brought  to be called the other jboss instance  of the same server group on the other host).

      I know that I'm definitely not good at describing problem, but I did my best. Could you please help to figure out if what I'm asking to feasible, 'cause I'm really running out of time.

      Thank you anyway !!