5 Replies Latest reply on Jul 31, 2012 7:42 AM by mircea.markus

    Cache replication on four nodes

    mborra

      Hi all,

       

      I have a problem with cache replication on four nodes (A, B, C, D).

       

      When put the value in the cache of node A, the value is not sent immediately to nodes B, C, D. If I make a request to node C with the same key, then the cache of node C is aligned with cache on node A (and lose a lot of time).

       

      Below the configuration:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <infinispan
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd"
            xmlns="urn:infinispan:config:5.1">
      
          <!-- [staging] -->
      
      
          <!-- ..:: GLOBAL ::.. -->
          <global>
              <globalJmxStatistics enabled="true" />
      
              <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
                  <properties><property name="threadNamePrefix" value="EvictionThread" /></properties>
              </evictionScheduledExecutor>
      
              <transport transportClass="org.infinispan.remoting.transport.jgroups.JGroupsTransport"
                  clusterName="infinispan-spring-cluster"
                  distributedSyncTimeout="2000"
                  strictPeerToPeer="false">
                  <properties>
                      <property name="configurationFile" value="jgroups-udp.xml" />
                  </properties>
              </transport>
      
              <shutdown hookBehavior="DEFAULT" />
          </global>
      
      
          <!-- ..:: DEFAULT ::.. -->
          <default> 
      
              <jmxStatistics enabled="true" />
      
              <locking useLockStriping="false"/>
      
              <eviction strategy="LRU" maxEntries="100" />
      
              <loaders passivation="true" preload="true" shared="false">
                  <loader class="org.infinispan.loaders.file.FileCacheStore"
                          purgeSynchronously="true"
                          purgeOnStartup="false"
                          fetchPersistentState="true"
                          ignoreModifications="false">
                      <properties>
                          <property name="location" value="${java.io.tmpdir}/infinispan" />
                      </properties>
                      <async enabled="true" flushLockTimeout="15000" threadPoolSize="3" />
                  </loader>
              </loaders>
      
              <clustering mode="replication">
                  <sync /> 
                  <stateTransfer timeout="5000" fetchInMemoryState="true"/>
              </clustering>
          </default>
      
      
          <!-- ..:: NAMEDCACHE ::.. -->
          <namedCache name="searchResult">
              <!-- LRU: least-recently-used pattern -->
              <eviction maxEntries="10" strategy="LRU" />
      
              <expiration maxIdle="300000" wakeUpInterval="300000" lifespan="600000" />
      
              <jmxStatistics enabled="true"/>
      
              <loaders passivation="true" preload="true" shared="false">
                  <loader class="org.infinispan.loaders.file.FileCacheStore" purgeOnStartup="false" fetchPersistentState="true"
                          ignoreModifications="false">
                      <properties>
                          <property name="location" value="${java.io.tmpdir}/infinispan" />
                      </properties>
                  </loader>
              </loaders>
      
              <clustering mode="replication">
                  <stateTransfer timeout="5000" fetchInMemoryState="true"/>
              </clustering>
          </namedCache>
      
      </infinispan>
      
        • 1. Re: Cache replication on four nodes
          galder.zamarreno

          Which cache?

           

          How do you know it's not sent immediately?

          • 2. Re: Cache replication on four nodes
            mborra

            Both, default and searchResult.

             

            From the logs (trace) i see the JGroups startup and synchronization of the node C, only after sending the request to the node C.

            I have extended the integration of Spring (infinispan-spring) to load a simple cache-level log listener (@Listener). Surprise! Now JGroups start on Tomcat startup, and the request sent to node A synchronize the node C

            immediately.


            Why without Infinispan Listener JGroups (
            subordinate to Infinispan) does not create a channel?

             

            Thanks

            • 3. Re: Cache replication on four nodes
              galder.zamarreno

              Right, I see what you mean now. I don't know how you're constructing the cache manager, but if after creating it, you call getCache() on the cache manager, the JGroups transport will start.

               

              So, assuming you create the cache manager on startup, add the getCache() call to and that should work.

              1 of 1 people found this helpful
              • 4. Re: Cache replication on four nodes
                mborra

                Thanks, it's clear now. The creation of the CacheManager is done by Spring. Leave out the manner in which Spring creates the CacheManger, it's possible to configure Infinispan so that one of the cache is enabled (getCache () or other) and synchronized at startup? Or at creation of the CacheManager?

                • 5. Re: Cache replication on four nodes
                  mircea.markus

                  you'd have to start the cache explicitly by calling CacheManager.getCache(). That cache would form a cluster over all nodes where the method is invoked.