4 Replies Latest reply on Aug 5, 2014 2:39 PM by javapapo

    Wildfly 8.1, standalone-ha, use of Infinispan (lib mode) - simple clustering- any hints? tips?

    javapapo

      Hello in my local machine I am spawning 2 instances of a standard Wildfly 8.1 server (MacoSX. JDK7)

       

      Start server one : standalone.sh --server-config=standalone-ha.xml -Djboss.node.name=nodeOne
      Start server two : standalone.sh --server-config=standalone-ha.xml -Djboss.node.name=nodeTwo -Djboss.socket.binding.port-offset=100
      
      

       

      No problem with the above, I am deploying a fairly complex ear, that is using infinispan in library mode in order to configure 2 named-caches that I want to be 'replicated'. I am using Wildfly libs (so I am exposing the jars bundled with the server in order to be used in my code imports).

       

      <sub-deployment name="xxx-cache.jar">
              <dependencies>
                  <module name="org.infinispan" services="import"/>
                  <module name="org.infinispan.commons" services="import"/>
              </dependencies>
          </sub-deployment>
      
      

      In order to configure my caches I am not using the standalone.xml files but a specific infinispan-config.xml , the reason is that the same configuration and ear is currently being deployed on another application server, so I want to keep some sort of common config/code base. Up until now the caches configured by the file below in Local non relicated mode, where working very well. The server was picking my configuration, from a startup ejb at the moment, and was initialising the 2 caches.

       

      I need some hints or help with the configuration on clusterd mode, this is my infinispan-cofig.xml

       

      <global>
              <transport  clusterName="omniacluster"/>
          </global>
          <default />
          <namedCache name="restSessionCache">
              <eviction strategy="LIRS" maxEntries="2000"/>
              <clustering mode="REPL">
                  <stateTransfer  chunkSize="0"  fetchInMemoryState = "false"  timeout ="2000"/>
                  <sync replTimeout="2000"/>
              </clustering>
          </namedCache>
          <namedCache name="environmentCache">
              <clustering mode="REPL">
                  <stateTransfer  chunkSize="0"  fetchInMemoryState = "false"  timeout ="2000"/>
                  <sync replTimeout="2000"/>
              </clustering>
              <eviction strategy="NONE"/>
          </namedCache>
      
      

      It is being initialised like that in a @Startup Bean

       

      @PostConstruct
          private void createManager(){
              try{
                  manager = new DefaultCacheManager("infinispan-config.xml");
              } catch (IOException e){
                  e.printStackTrace();
      
      
              }
              restSessionCache = manager.getCache("restSessionCache");
              environmentCache = manager.getCache("environmentCache");
              /*  methods to load data from the DB to the cache */
      

       

      I need some hints or help with the configuration on clusterd mode . My questions are

       

      1. Is there the proper way on a 2 node standalone-ha cluster to use the bundled Infinispan jars to configure my replicated caches?

      2. Do I need to provide any extra jgroups.xml configuration?

       

      At the time being, I can not see my caches on the 2 nodes to replicate data. Any tips or hints to the right direction would be much appreciated!

       

      Many thanks!

        • 1. Re: Wildfly 8.1, standalone-ha, use of Infinispan (lib mode) - simple clustering- any hints? tips?
          pferraro

          1. What do you mean by, "cannot see my cachens on the 2 nodes"?  Is your @Startup @Singletion throwing an exception?  Are you certain that Infinispan is able to locate your "infinispan-config.xml" file?

          Since you asked, the "proper" way to use Infinispan in WildFly is to define the cache-container and caches via the infinispan subsystem.  If you were using domain mode, there would be no issue with ensuring each node has the same configuration.  This approach also has the advantage of automatically managing the lifecycle of the caches and channel - and lets you manage these resources at runtime via WildFly's management interface.  To reference the caches, you would simply inject the cache instance where needed - just as you would any other server-managed resource.

           

          2. If you are OK with using infinispan's default protocol stack, then you shouldn't need to specify anything.  By default, this stack is used: infinispan/jgroups-udp.xml at 6.0.x · infinispan/infinispan · GitHub

           

          Also, don't forget to create a @PreDestroy method that stops the caches and cache manager created in your @PostConstruct method.

          1 of 1 people found this helpful
          • 2. Re: Wildfly 8.1, standalone-ha, use of Infinispan (lib mode) - simple clustering- any hints? tips?
            javapapo

            Hello Paul, thanks for your prompt reply my updates are the following

             

            Using jconsole and the MBEAN server on both instances - I can see the statistics of the caches , and they seem to communicate (replication works).

             

            Question1: If I dont use standalone-ha config, since I am using the default config of infinispan, is jgroups going to 'run' within the infinispan (context) or it is working because of the standalone-ha profile?

             

            I am using a @PreDestroy method as indicated.

            • 3. Re: Wildfly 8.1, standalone-ha, use of Infinispan (lib mode) - simple clustering- any hints? tips?
              pferraro

              Your private Infinispan instance will create its own channel from the default jgroups configuration shipped within the infinispan-core jar from the org.infinispan module.  Since you don't seem to be using the resources from the jgroups or infinispan subsystems, there's no reason to use standalone-ha.xml - you could just as easily use standalone.xml (the appropriate modules are available either way).  Alternatively, you could wire your cache manager to use a protocol stack from the jgroups subsystem, but this will require a ServiceActivator and programmatic cache configuration.

              • 4. Re: Wildfly 8.1, standalone-ha, use of Infinispan (lib mode) - simple clustering- any hints? tips?
                javapapo

                Clean enough, many thanks