4 Replies Latest reply on Sep 7, 2016 9:43 PM by rjack2

    Migrating from EmbeddedCacheMangager to RemoteCacheManager

    rjack2

      Folks,

       

      I migrating our Embedded Cache Manager to a Remote Cache Manager. I'm using Infinispan 8.2.4 final. The original code was 6.x?

       

      Here is the original code:

       

         public void configure(EmbeddedCacheManager manager) {

                      //@formatter:off

                      ConfigurationBuilder builder = new ConfigurationBuilder();

                      builder

                      .clustering().cacheMode(CacheMode.REPL_SYNC)

                      .invocationBatching().enable(true)

                      .persistence()

                      .passivation(false)

                      .addSingleFileStore()

                      .preload(true)

                      .shared(false)

                      .fetchPersistentState(true)

                      .ignoreModifications(false)

                      .purgeOnStartup(false)

                      .location(centralCachePath)

                      .eviction().strategy(EvictionStrategy.NONE)

                      .expiration().lifespan(-1L).maxIdle(-1L);

                      manager.defineConfiguration(IEcommerceConstants.CUSTOM_CACHE,

                              builder.build());

                      //@formatter:on

       

       

      Here is my attempt at configuring the cache for a Remote Cache Manager:

       

                      <replicated-cache name="CustomCache" mode="SYNC" segments="20" owners="2" remote-timeout="30000" start="EAGER">

                          <transaction mode="BATCH"/>

                          <persistence passivation="false">

                              <!-- note that class is missing and is induced by the fileStore element name -->

                              <file-store

                                      shared="false" preload="true"

                                      fetch-state="true"

                                      read-only="false"

                                      purge="false"

                                      path="${java.io.tmpdir}">

                                  <write-behind flush-lock-timeout="15000" thread-pool-size="5" />

                              </file-store>

                          </persistence>

                          <eviction strategy="LIRS" max-entries="5000"/>

                          <!--Lifespan- 7 Days in ms -->

                          <expiration lifespan="604800000" interval="5000" />

                      </replicated-cache>

       

      1) Is this correct?

       

      2) I have to create several replicated caches, can I use replicated-cache-configuration to default most of the settings. Is this default automatic (i.e. inherited by all replicated caches)? And if I set a value in a replicated-cache will it be override a value set here?

       

                      <replicated-cache name"CustomCache" >

                      </replicated-cache>

       

                      <replicated-cache-configuration name="replicated" mode="SYNC"segments="20" owners="2" remote-timeout="30000" start="EAGER">

                          <transaction mode="BATCH"/>

                          <persistence passivation="false">

                              <!-- note that class is missing and is induced by the fileStore element name -->

                              <file-store

                                      shared="false" preload="true"

                                      fetch-state="true"

                                      read-only="false"

                                      purge="false"

                                      path="${java.io.tmpdir}">

                                  <write-behind flush-lock-timeout="15000" thread-pool-size="5" />

                              </file-store>

                          </persistence>

                          <eviction strategy="LIRS" max-entries="5000"/>

                          <!--Lifespan- 7 Days in ms -->

                          <expiration lifespan="604800000" interval="5000" />

                      </replicated-cache-configuration>

       

      3) Can I just remove all the "distributed cache" tags since I'm not using distributed caches? I using "cluster.xml" as my base configuration file.

       

      Regards,

       

      Robert

        • 1. Re: Migrating from EmbeddedCacheMangager to RemoteCacheManager
          rjack2

          This seems to be working, but I have to define many caches with pretty much the same configs. Can I use replicate-cache-configuration to define multiple caches with pretty much the same info? I haven't had any luck getting

          a replicated-cache-configuration to work? What is the connection between a replicated-cache and a replicated-configuration-cache?

           

                          <replicated-cache name="CustomCache" mode="SYNC" remote-timeout="30000" start="EAGER" batching="true">

                              <transaction mode="NONE"/>

                              <eviction strategy="LIRS" size="5000" type="COUNT"/>

                              <file-store

                                      shared="false" preload="true"

                                      fetch-state="true"

                                      read-only="false"

                                      purge="false"

                                      path="${java.io.tmpdir}" passivation="false">

                                  <write-behind flush-lock-timeout="15000" thread-pool-size="5" />

                              </file-store>

           

           

                              <!--Lifespan- 7 Days in ms -->

                              <expiration lifespan="604800000" interval="5000" />

                          </replicated-cache>

          • 2. Re: Migrating from EmbeddedCacheMangager to RemoteCacheManager
            nadirx

            Hi Robert,

             

            just define your configuration as:

             

            <replicated-cache-configuration name="baseconfig" ... >....</replicated-cache-configuration>

             

            and your caches as

             

            <replicated-cache name="cache1" configuration="baseconfig"/>

            <replicated-cache name="cache2" configuration="baseconfig"/>

            ...

             

            Tristan

            1 of 1 people found this helpful
            • 3. Re: Migrating from EmbeddedCacheMangager to RemoteCacheManager
              rjack2

              Tristan,

               

              Thank you that seems to be working if I just inherit the configuration. Is it possible to "override"  a setting like customcache2 below? When I try, I'm getting an error.

               

              --------------------

                              <replicated-cache-configuration name="baseconfig" mode="SYNC" remote-timeout="30000" start="EAGER" batching="true">

                                  <transaction mode="NONE"/>

                                  <eviction strategy="LIRS" size="5000" type="COUNT"/>

                                  <file-store

                                          shared="false" preload="true"

                                          fetch-state="true"

                                          read-only="false"

                                          purge="false"

                                          path="${java.io.tmpdir}" passivation="false">

                                      <write-behind flush-lock-timeout="15000" thread-pool-size="5" />

                                  </file-store>

               

               

                                  <!--Lifespan- 7 Days in ms -->

                                  <expiration lifespan="604800000" interval="5000" />

                              </replicated-cache-configuration>

               

               

                              <replicated-cache name="customcache1" configuration="baseconfig">

                              </replicated-cache>

                              <replicated-cache name="customecache2" configuration="baseconfig">

                                  <!--Lifespan-indefinite -->

                                  <expiration lifespan="-1" interval="-1" />

                              </replicated-cache>

              ---------------------------------------------------------------------------

              source [java:jboss/datasources/ExampleDS]

              10:00:17,820 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 19) WFLYCTL0013: Operation ("add") failed - address: ([

                  ("subsystem" => "datagrid-infinispan"),

                  ("cache-container" => "clustered"),

                  ("configurations" => "CONFIGURATIONS"),

                  ("replicated-cache-configuration" => "customecache2")

              ]): java.lang.IllegalArgumentException: No enum constant org.jboss.as.clustering.infinispan.subsystem.Mode.undefined

              • 4. Re: Migrating from EmbeddedCacheMangager to RemoteCacheManager
                rjack2

                Here's what I've found during this effort with help from Tristan and other member of Infinispan on IRC.

                 

                1) The correct schema for the RemoteCachManager/RemoteCache file (e.g. cluster.xml) is:

                 

                infinispan/jboss-infinispan-core_8_2.xsd

                 

                2) The RemoteCacheManger does not support batching or transactions

                 

                3) I only got the replicated-cache-configuration replicated-cache using is empty except for the name and configuration.  So I used configurations for multiple caches there are identical and just put the information in the replicated cache for ones that were unique.